comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Jpeg in a .sav file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Jpeg in a .sav file [message #59241] Thu, 13 March 2008 17:05
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
Dan Larson wrote:

> am I missing something here, in terms of IDL design? Is there some
> philosophical reason why one *shouldn't* want to include an embedded
> image in a .sav file?

No. I can't see any philosophical reason why and there are no general
technical reasons why one couldn't do this. I can't think of any
specific technical hurdles for IDL except that it would (probably)
require a change to the .sav file format breaking forward compatibility.

There are certainly cases where this would be useful. Embedding logos
or icons is one, or LUT's or... Sometimes you want to distribute an
application with data that is not accessible to the user so packaging
them with image files or .dat files or even other .sav files isn't
ideal. Though without further changes to the .sav file format data
stored in a "hybrid" format wouldn't be protected whereas now at least
the data is obfuscated inside a function.

I doubt any of the reasons would justify breaking forward compatibility.
For the 10 users ITT makes happy, there will be hundreds bent that
they can no longer load IDL 8 .sav files in their older versions. So I
think that variations on the hack I posted are going to be the only
route, for now.

-Rick
Re: Jpeg in a .sav file [message #59242 is a reply to message #59241] Thu, 13 March 2008 15:24 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Dan Larson writes:

> Is there some
> philosophical reason why one *shouldn't* want to include an embedded
> image in a .sav file?

Well, I guess in this sense PostSript files are carrying
around "embedded" images. So, if you don't mind the size
of those, a bloated save file is not going to make much
difference to you.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Jpeg in a .sav file [message #59243 is a reply to message #59242] Thu, 13 March 2008 14:05 Go to previous message
Dan Larson is currently offline  Dan Larson
Messages: 21
Registered: March 2002
Junior Member
On Mar 13, 4:53 pm, David Fanning <n...@dfanning.com> wrote:
> Rick Towler writes:
>> Well, maybe he wants to embed an emblem or logo in a .sav file.
>> Something a bit more "professional" than simply distributing a separate
>> file.  I mean, *anyone* can do that!
>
>> The trick is encoding the image into a function.  Like so:
>
>> http://www.acoustics.washington.edu/~towler/programs/make_im ageFuncti...
>
>> Like the header says, there are I'm sure a load of issues you could run
>> into.  I've used this on a number of smaller images and it works but I
>> would expect this to fail with even "medium" resolution images.  Also
>> you'll want to tweak this a bit as I was working with .png files.
>
> Well, I'm sure this has a use somewhere. I'm not sure "professional"
> is the word I would use to describe it, though. "Rube Goldberg
> solution" comes to mind. ;-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming (www.dfanning.com)
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")


Hi -

Rick is correct -- I wanted the image to be embedded, not simply
included as a separate file which can be deleted, moved, etc. And the
Rube Goldberg methods seems to be the only option available. So i
have hard-coded the image, similar to what was suggested. But am I
missing something here, in terms of IDL design? Is there some
philosophical reason why one *shouldn't* want to include an embedded
image in a .sav file?

thanks for the input.

dan
Re: Jpeg in a .sav file [message #59244 is a reply to message #59243] Thu, 13 March 2008 13:53 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Rick Towler writes:

> Well, maybe he wants to embed an emblem or logo in a .sav file.
> Something a bit more "professional" than simply distributing a separate
> file. I mean, *anyone* can do that!
>
> The trick is encoding the image into a function. Like so:
>
> http://www.acoustics.washington.edu/~towler/programs/make_im ageFunction.pro
>
> Like the header says, there are I'm sure a load of issues you could run
> into. I've used this on a number of smaller images and it works but I
> would expect this to fail with even "medium" resolution images. Also
> you'll want to tweak this a bit as I was working with .png files.

Well, I'm sure this has a use somewhere. I'm not sure "professional"
is the word I would use to describe it, though. "Rube Goldberg
solution" comes to mind. ;-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Jpeg in a .sav file [message #59245 is a reply to message #59244] Thu, 13 March 2008 13:37 Go to previous message
mmiller3 is currently offline  mmiller3
Messages: 81
Registered: January 2002
Member
>>>> > "Rick" == Rick Towler <rick.towler@nomail.noaa.gov> writes:

> The trick is encoding the image into a function. Like so:

> http://www.acoustics.washington.edu/~towler/programs/make_im ageFunction.pro

Nice one Rick - I've done a similar thing for widget bitmaps.
Probably it was originally based on something I saw from you or
someone else on this newsgroup, but I was bad and did not comment
my code.

Mike



pro bmp_to_function, bmp_file, function_name
print, 'reading bitmap from ', bmp_file

test = query_bmp(bmp_file, info)
case info.channels of
3: begin
;; 3 channel bit map, so use it as is...
bmp = read_bmp(bmp_file)
result = bytarr(info.dimensions[0], info.dimensions[0], 3)
result[*,*,0] = bmp[0,*,*]
result[*,*,1] = bmp[1,*,*]
result[*,*,2] = bmp[2,*,*]
end
1: begin
;; single channel bit map ==> use RGB colors
bmp = read_bmp(bmp_file, R, G, B)
result = [[[R[bmp]]], [[G[bmp]]], [[B[bmp]]]]
end
endcase

print, 'writing function ', function_name, ' to ', function_name+'.pro'
openw, lun, function_name+'.pro', /get_lun
printf, lun, 'function ' + function_name
printf, lun, 'bmp = bytarr(' + strtrim(info.dimensions[0],2) + ',' + strtrim(info.dimensions[1],2) + ',3)'
for x = 0, info.dimensions[0]-1 do begin
for y = 0, info.dimensions[1]-1 do begin
for c = 0, 2 do begin
printf, lun, 'bmp[' + strtrim(x,2) + ','+ strtrim(y,2) + ','+ strtrim(c,2) + '] = ' + strtrim(fix(result[x,y,c]),2)
endfor
endfor
endfor
printf, lun, 'return, bmp'
printf, lun, 'end'
free_lun, lun

end
Re: Jpeg in a .sav file [message #59247 is a reply to message #59245] Thu, 13 March 2008 13:16 Go to previous message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
Well, maybe he wants to embed an emblem or logo in a .sav file.
Something a bit more "professional" than simply distributing a separate
file. I mean, *anyone* can do that!

The trick is encoding the image into a function. Like so:

http://www.acoustics.washington.edu/~towler/programs/make_im ageFunction.pro

Like the header says, there are I'm sure a load of issues you could run
into. I've used this on a number of smaller images and it works but I
would expect this to fail with even "medium" resolution images. Also
you'll want to tweak this a bit as I was working with .png files.

Enjoy!

-Rick


David Fanning wrote:
> Dan Larson writes:
>
>> I am trying to put a jpeg into a .sav file for distribution. I know
>> that variables and routines cannot be in the same .sav file, and I
>> know this issue has been addressed over the years in this forum. BUT,
>> most of the posts I found were quite old (1996, 1998), and I was
>> wondering if newer versions of IDL have somehow corrected this problem
>> or if there is a fix of which I am not aware.
>
> You must be thinking of a zip file. What would a
> JPEG file even look like in the context of an IDL
> session? A JPEG file is something that exists on
> disk. It has nothing to do with IDL. If you read
> a JPEG file off the disk in IDL, of course, you
> have an image. You could certainly save an image
> in a save file.
>
> Cheers,
>
> David
Re: Jpeg in a .sav file [message #59252 is a reply to message #59247] Thu, 13 March 2008 10:33 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Dan Larson writes:

> I am trying to put a jpeg into a .sav file for distribution. I know
> that variables and routines cannot be in the same .sav file, and I
> know this issue has been addressed over the years in this forum. BUT,
> most of the posts I found were quite old (1996, 1998), and I was
> wondering if newer versions of IDL have somehow corrected this problem
> or if there is a fix of which I am not aware.

You must be thinking of a zip file. What would a
JPEG file even look like in the context of an IDL
session? A JPEG file is something that exists on
disk. It has nothing to do with IDL. If you read
a JPEG file off the disk in IDL, of course, you
have an image. You could certainly save an image
in a save file.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: unsigned long long and min/max operator
Next Topic: Re: WindowsXP IDLWorkbench hang issue

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:12:09 PDT 2025

Total time taken to generate the page: 0.00503 seconds