Reputation: 103
I am new to Racket and StackOverflow. I am trying to use IMAGE.png as cursor. But the white part of cursor is merged by background color. If i hover the cursor on black-thick lines, the cursor is totally invisible as the white color become transparent. The white color is supposed to be opaque.
First, I use this ,which has 256x256 dimensions, 32 bit depth. I resized the dimensions to 16x16 with the following codes.
(require 2htdp/image)
(define mag IMAGE.png);; acutally, I used "insert image" in DrRacket IDE
(define new-mag (scale (/ 1 16) mag))
(save-image new-mag "mag.png")
new-mag
(image-width new-mag)
(image-height new-mag)
According to the documentation of cursor%, the bitmap file with 16x16 bit depth 1 must be used to create cursor. To change the bit depth to 1, following codes are applied.
(require racket/gui/base)
(define bm1 (read-bitmap "mag.png"))
(define bm2 (make-object bitmap% 16 16 #t #f 1.0))
(send (send bm2 make-dc)draw-bitmap bm1 0 0)
(send bm2 save-file "mag2use.png" 'png)
(define bm (read-bitmap "mag2use.png"))
(printf "~a ~a ~a ~a~n"
(send bm get-width)
(send bm get-height)
(send bm get-depth)
(send bm is-color?))
Then I used the bitmap mag2use.png as cursor.
(define zoom-cursor (make-object cursor% bm bm 0 0))
Upvotes: 1
Views: 118
Reputation: 66421
It's unfortunate that the documentation doesn't mention that the mask parameter is a transparency mask.
White pixels in the mask become transparent in the cursor, and you're using the bitmap itself as mask.
Fill the parts you want to be opaque with black in the mask.
Upvotes: 1