Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Idl-pvware > Re: Jpeg in a ....
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 8 Topic 5531 of 6400
Post > Topic >>

Re: Jpeg in a .sav file

by mmiller3@[EMAIL PROTECTED] (Michael A. Miller) Mar 13, 2008 at 04:37 PM

>>>>> "Rick" == Rick Towler <rick.towler@[EMAIL PROTECTED]
> writes:

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

    >
http://www.acoustics.wa****ngton.edu/~towler/programs/make_imageFunction.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
 




 8 Posts in Topic:
Jpeg in a .sav file
Dan Larson <dlarson@[E  2008-03-13 10:19:11 
Re: Jpeg in a .sav file
David Fanning <news@[E  2008-03-13 11:33:50 
Re: Jpeg in a .sav file
Rick Towler <rick.towl  2008-03-13 13:16:47 
Re: Jpeg in a .sav file
David Fanning <news@[E  2008-03-13 14:53:45 
Re: Jpeg in a .sav file
mmiller3@[EMAIL PROTECTED  2008-03-13 16:37:18 
Re: Jpeg in a .sav file
Dan Larson <dlarson@[E  2008-03-13 14:05:35 
Re: Jpeg in a .sav file
David Fanning <news@[E  2008-03-13 16:24:04 
Re: Jpeg in a .sav file
Rick Towler <rick.towl  2008-03-13 17:05:34 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Nov 19 10:18:42 CST 2008.