guard against bad pre-mult ARGB

Closes PR 11572
This commit is contained in:
Matthew Flatt 2010-12-28 20:03:56 -07:00
parent 1d89cfc9d7
commit 0476ab4fc4

View File

@ -614,9 +614,13 @@
[a (bytes-ref data (+ ri A))]
[unmult (lambda (a v)
(if use-alpha?
(if (zero? a)
(if (unsafe-fx= 0 a)
255
(unsafe-fxquotient (fx* v 255) a))
;; `min' shouldn't be necessary, but it's
;; just in case the data is ill-formed
(unsafe-fxmin 255 (unsafe-fxquotient
(unsafe-fx* v 255)
a)))
v))])
(when alpha-channel?
(bytes-set! bstr pi a))