From 551e536f3e7841b6ee7911da560f11b70a227292 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Sat, 11 May 2013 10:36:11 -0600 Subject: [PATCH] bitmap-dc% respective alpha channel in get/set-pixel --- collects/racket/draw/private/bitmap-dc.rkt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/collects/racket/draw/private/bitmap-dc.rkt b/collects/racket/draw/private/bitmap-dc.rkt index 08bb51c3c3..5d9e241b7f 100644 --- a/collects/racket/draw/private/bitmap-dc.rkt +++ b/collects/racket/draw/private/bitmap-dc.rkt @@ -119,14 +119,18 @@ (internal-get-bitmap)) (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))) (define/public (get-pixel x y c) (let-values ([(w h) (get-size)]) (let ([b (make-bytes 4)]) (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))))) (define/public (set-argb-pixels x y w h bstr