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

Home » Public Forums » archive » BMP to cursor bitmap
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
BMP to cursor bitmap [message #56066] Thu, 27 September 2007 13:55
markb77 is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: selection box in widget program
Next Topic: How to comment out large section of codes in IDL?

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

Current Time: Wed Oct 08 17:31:23 PDT 2025

Total time taken to generate the page: 0.00591 seconds