BMP to cursor bitmap [message #56066] |
Thu, 27 September 2007 13:55 |
markb77
Messages: 217 Registered: July 2006
|
Senior Member |
|
|
While figuring out how to change the mouse cursor in an IDLgrWindow
object, I wrote this little routine which others may find useful. The
input BMP file should be a 16x16 grayscale image. The outputs can be
used for the IMAGE and MASK parameters to and IDLgrWindow object.
cheers,
Mark Bates
Dept. of Chemistry
Harvard University
;ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc cccccc
;
; load_cursor_bitmap.pro
;
; Generate bitmap images suitable for and IDL cursor, given an input
; BMP file
;
; Black and white parts of the BMP are preserved in the cursor image
;
; Any other color will appear transparent
;
; Note that the BMP file must be a 16x16 greyscale image
;
; Use it like this:
;
; myfile = 'arrow.bmp'
;
; load_cursor_bitmap, myfile, cursor_bitmap, mask_bitmap
;
; oMyWindow -> SetCurrentCursor, IMAGE=cursor_bitmap, $
; MASK=mask_bitmap
;
;ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc cccccc
pro load_cursor_bitmap, bmpfile, cursor_bitmap, mask_bitmap
cursor_img = read_bmp(bmpfile)
mask_img = (cursor_img eq 0) or (cursor_img eq 255)
white_part = (cursor_img eq 255)
black_part = (cursor_img eq 0)
cursor_img = fix(black_part * 255)
cursor_byt = cvttobm(cursor_img)
cursor_bitmap = 256*cursor_byt[0,*] + cursor_byt[1,*]
mask_byt = cvttobm(mask_img)
mask_bitmap = 256*mask_byt[0,*] + mask_byt[1,*]
end
|
|
|