[racket] Problem loading a bitmap% to use for a cursor%

From: Kieron Hardy (kieron.hardy at gmail.com)
Date: Thu Oct 11 17:18:13 EDT 2012

Hi all,

I'm having trouble loading a 16x16 monochrome image such that it can be
used as a cursor%.

The documentation states that using load-file with a kind of 'bmp always
loads as colour, but it would be nice to have a new kind (perhaps
'monochrome-bmp) that loads monochrome images to monochrome bitmaps.

The documentation also states that a monochrome png will load as a
monochrome bitmap%, but it seems to always load as colour (changing the bit
depth from 1 to 32 during the load-file, regardless of the value specified
for kind). Perhaps there's something wrong with my image file (attached)
but gimp and Windows both show a 1-bit colour depth.

I have a work-around, in that converting the image to xbm seems to work.
But I'm still interested to know what I was doing wrong, anyone have any
ideas?

Cheers,

Kieron.

****

#lang racket

(require racket/gui)

(define bm (make-object bitmap% 16 16 #t #f))
(printf "  ~a ~a ~a ~a~n" (send bm get-width) (send bm get-height) (send bm
get-depth) (send bm is-color?))

(send bm load-file "test-icon.png" 'png #f #t)
;(send bm load-file "test-icon.xbm" 'xbm #f #t)
(printf "  ~a ~a ~a ~a~n" (send bm get-width) (send bm get-height) (send bm
get-depth) (send bm is-color?))

(define cursor (make-object cursor% bm bm 0 0))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121011/192f4df6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-icon.png
Type: image/png
Size: 177 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20121011/192f4df6/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-icon.xbm
Type: image/x-xbitmap
Size: 302 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20121011/192f4df6/attachment.xbm>

Posted on the users mailing list.