fix alpha mult in `set-argb-pixels'
This commit is contained in:
parent
290fe066b6
commit
cc82506be5
|
@ -64,6 +64,13 @@
|
||||||
(define fx+ unsafe-fx+)
|
(define fx+ unsafe-fx+)
|
||||||
(define fx* unsafe-fx*)
|
(define fx* unsafe-fx*)
|
||||||
|
|
||||||
|
(define (alpha-mult al v)
|
||||||
|
(unsafe-fl->fx
|
||||||
|
(unsafe-flround
|
||||||
|
(unsafe-fl/
|
||||||
|
(unsafe-fx->fl (fx* al v))
|
||||||
|
255.0))))
|
||||||
|
|
||||||
(define png-convertible<%>
|
(define png-convertible<%>
|
||||||
(interface* ()
|
(interface* ()
|
||||||
([prop:convertible
|
([prop:convertible
|
||||||
|
@ -422,12 +429,7 @@
|
||||||
255)]
|
255)]
|
||||||
[premult (lambda (al v)
|
[premult (lambda (al v)
|
||||||
(if pre?
|
(if pre?
|
||||||
(unsafe-fl->fx
|
(alpha-mult al v)
|
||||||
(unsafe-flround
|
|
||||||
(unsafe-fl/
|
|
||||||
(unsafe-fx->fl (fx* al v))
|
|
||||||
255.0)))
|
|
||||||
#;(unsafe-fxquotient (fx* al v) 255)
|
|
||||||
v))])
|
v))])
|
||||||
(unsafe-bytes-set! dest (fx+ pos A) al)
|
(unsafe-bytes-set! dest (fx+ pos A) al)
|
||||||
(unsafe-bytes-set! dest (fx+ pos R) (premult al (unsafe-bytes-ref r spos)))
|
(unsafe-bytes-set! dest (fx+ pos R) (premult al (unsafe-bytes-ref r spos)))
|
||||||
|
@ -633,9 +635,12 @@
|
||||||
255
|
255
|
||||||
;; `min' shouldn't be necessary, but it's
|
;; `min' shouldn't be necessary, but it's
|
||||||
;; just in case the data is ill-formed
|
;; just in case the data is ill-formed
|
||||||
(unsafe-fxmin 255 (unsafe-fxquotient
|
(unsafe-fxmin 255
|
||||||
(unsafe-fx* v 255)
|
(unsafe-fl->fx
|
||||||
a)))
|
(unsafe-flround
|
||||||
|
(unsafe-fl/
|
||||||
|
(unsafe-fx->fl (fx* 255 v))
|
||||||
|
(unsafe-fx->fl a))))))
|
||||||
v)])])
|
v)])])
|
||||||
(when set-alpha?
|
(when set-alpha?
|
||||||
(unsafe-bytes-set! bstr pi a))
|
(unsafe-bytes-set! bstr pi a))
|
||||||
|
@ -696,7 +701,7 @@
|
||||||
[pm (lambda (a v)
|
[pm (lambda (a v)
|
||||||
(if pre-mult?
|
(if pre-mult?
|
||||||
(min a v)
|
(min a v)
|
||||||
(quotient (* a v) 255)))])
|
(alpha-mult a v)))])
|
||||||
(bytes-set! data (+ ri A) a)
|
(bytes-set! data (+ ri A) a)
|
||||||
(bytes-set! data (+ ri R) (pm a (bytes-ref bstr (+ pi 1))))
|
(bytes-set! data (+ ri R) (pm a (bytes-ref bstr (+ pi 1))))
|
||||||
(bytes-set! data (+ ri G) (pm a (bytes-ref bstr (+ pi 2))))
|
(bytes-set! data (+ ri G) (pm a (bytes-ref bstr (+ pi 2))))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user