bitmap-dc% respective alpha channel in get/set-pixel

This commit is contained in:
Jay McCarthy 2013-05-11 10:36:11 -06:00
parent a80e04136b
commit 551e536f3e

View File

@ -119,14 +119,18 @@
(internal-get-bitmap)) (internal-get-bitmap))
(define/public (set-pixel x y c) (define/public (set-pixel x y c)
(let ([s (bytes 255 (color-red c) (color-green c) (color-blue c))]) (let ([s (bytes (inexact->exact (round (* 255 (color-alpha c))))
(color-red c)
(color-green c)
(color-blue c))])
(set-argb-pixels x y 1 1 s))) (set-argb-pixels x y 1 1 s)))
(define/public (get-pixel x y c) (define/public (get-pixel x y c)
(let-values ([(w h) (get-size)]) (let-values ([(w h) (get-size)])
(let ([b (make-bytes 4)]) (let ([b (make-bytes 4)])
(get-argb-pixels x y 1 1 b) (get-argb-pixels x y 1 1 b)
(send c set (bytes-ref b 1) (bytes-ref b 2) (bytes-ref b 3)) (send c set (bytes-ref b 1) (bytes-ref b 2) (bytes-ref b 3)
(/ (bytes-ref b 0) 255))
(and (<= 0 x w) (<= 0 y h))))) (and (<= 0 x w) (<= 0 y h)))))
(define/public (set-argb-pixels x y w h bstr (define/public (set-argb-pixels x y w h bstr