fix bug in the loading of non-alpha bitmaps (also: minor Rackety)
This commit is contained in:
parent
f85c73f83d
commit
b425ca90d2
|
@ -1407,6 +1407,11 @@
|
||||||
=>
|
=>
|
||||||
#t))
|
#t))
|
||||||
|
|
||||||
|
(let ()
|
||||||
|
(define i1 (rotate 0 (make-object bitmap% u.png 'unknown/mask)))
|
||||||
|
(define i2 (rotate 0 (make-object bitmap% u.png 'unknown/alpha)))
|
||||||
|
(test (equal? i1 i2) => #t))
|
||||||
|
|
||||||
(define (get-from-file f)
|
(define (get-from-file f)
|
||||||
(define t (new text%))
|
(define t (new text%))
|
||||||
(send t load-file f)
|
(send t load-file f)
|
||||||
|
|
|
@ -1014,15 +1014,14 @@ the mask bitmap and the original bitmap are all together in a single bytes!
|
||||||
;; don't rotate anything in this case.
|
;; don't rotate anything in this case.
|
||||||
bitmap-obj]
|
bitmap-obj]
|
||||||
[else
|
[else
|
||||||
(let ([θ (degrees->radians (ibitmap-angle bitmap))])
|
(define θ (degrees->radians (ibitmap-angle bitmap)))
|
||||||
(let-values ([(bytes w h) (bitmap->bytes bitmap-obj #f)])
|
(define-values (bytes w h) (bitmap->bytes bitmap-obj #f))
|
||||||
(let-values ([(rotated-bytes rotated-w rotated-h)
|
(define-values (rotated-bytes rotated-w rotated-h) (rotate-bytes bytes w h θ))
|
||||||
(rotate-bytes bytes w h θ)])
|
(define flipped-bytes (if flip?
|
||||||
(let* ([flipped-bytes (if flip?
|
(flip-bytes rotated-bytes rotated-w rotated-h)
|
||||||
(flip-bytes rotated-bytes rotated-w rotated-h)
|
rotated-bytes))
|
||||||
rotated-bytes)]
|
(define bm (bytes->bitmap flipped-bytes rotated-w rotated-h))
|
||||||
[bm (bytes->bitmap flipped-bytes rotated-w rotated-h)])
|
bm]))
|
||||||
bm))))]))
|
|
||||||
|
|
||||||
(define (do-scale bitmap orig-bm)
|
(define (do-scale bitmap orig-bm)
|
||||||
(define x-scale (ibitmap-x-scale bitmap))
|
(define x-scale (ibitmap-x-scale bitmap))
|
||||||
|
@ -1178,17 +1177,16 @@ the mask bitmap and the original bitmap are all together in a single bytes!
|
||||||
(define h (send bm get-height))
|
(define h (send bm get-height))
|
||||||
(define alpha-bm
|
(define alpha-bm
|
||||||
(cond
|
(cond
|
||||||
[(and (is-a? bm bitmap%)
|
[(send bm has-alpha-channel?)
|
||||||
(send bm has-alpha-channel?))
|
|
||||||
bm]
|
bm]
|
||||||
[else
|
[else
|
||||||
(define bm (make-bitmap w h))
|
(define new-bm (make-bitmap w h))
|
||||||
(define bdc (make-object bitmap-dc% bm))
|
(define bdc (make-object bitmap-dc% new-bm))
|
||||||
(send bdc draw-bitmap bm 0 0 'solid
|
(send bdc draw-bitmap bm 0 0 'solid
|
||||||
(send the-color-database find-color "black")
|
(send the-color-database find-color "black")
|
||||||
mask-bm)
|
mask-bm)
|
||||||
(send bdc set-bitmap #f)
|
(send bdc set-bitmap #f)
|
||||||
bm]))
|
new-bm]))
|
||||||
(make-image (make-translate (/ w 2)
|
(make-image (make-translate (/ w 2)
|
||||||
(/ h 2)
|
(/ h 2)
|
||||||
(make-ibitmap alpha-bm 0 1 1 (make-hash)))
|
(make-ibitmap alpha-bm 0 1 1 (make-hash)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user