>>>>> "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


|