[BUG] alphaBlendScaled:with:
Bob Arning
arning at charm.net
Wed Sep 15 12:34:22 UTC 1999
In exploring translucent BitBlts, I ran across the following:
1. If the combination rule is 34 and
2. The conditions are not met for one of the accelerated versions and
3. The source pixel is transparent,
then the destination pixel gets a bit darker. This is due to the fact that
x * 255 >> 8 is not quite x
-----snippet----
alphaBlendScaled: sourceWord with: destinationWord
"Blend sourceWord with destinationWord using the alpha value from sourceWord.
Alpha is encoded as 0 meaning 0.0, and 255 meaning 1.0.
In contrast to alphaBlend:with: the color produced is
srcColor + (1-srcAlpha) * dstColor
e.g., it is assumed that the source color is already scaled."
| unAlpha dstMask srcMask b g r a |
self inline: false. "Do NOT inline this into optimized loops"
unAlpha _ 255 - (sourceWord >> 24). "High 8 bits of source pixel"
dstMask _ destinationWord.
srcMask _ sourceWord.
b _ (dstMask bitAnd: 255) * unAlpha >> 8 + (srcMask bitAnd: 255).
[...]
------snippet-----
It would seem that
unAlpha = 255 ifTrue: [^destinationWord].
would be a useful addition here (and a bit faster).
Cheers,
Bob
More information about the Squeak-dev
mailing list
|