[QUESTION] Squeak Alpha Transparency methods...

Bob Arning arning at charm.net
Mon Dec 6 03:27:26 UTC 1999


On Sun, 5 Dec 1999 18:46:09 -0800  "Raab, Andreas" <Andreas.Raab at disney.com> wrote:
>Note to Dan: why does ColorForm>>colorMapIfNeededForDepth: use
>Color>>pixelValueForDepth: and why does
>TranslucentColor>>pixelValueForDepth: return just the RGB part for 32bit
>depths?!

There are several oddities WRT translucency. 

1. In the case of TranslucentColor>>pixelValueForDepth:, I have used for some time without apparent ill effects:
===============
pixelValueForDepth: d
	"Return the pixel value for this color at the given depth. Translucency only works in RGB; this color will appear either opaque or transparent at all other depths."

	alpha = 0 ifTrue: [^ 0].
	^d = 32 ifTrue: [
		((super pixelValueForDepth: d) bitAnd: 16rFFFFFF) bitOr: (alpha bitShift: 24)
	] ifFalse: [
		super pixelValueForDepth: d
	]
==============

2. Drawing rule "Form blend" doesn't work for differing source and destination depths. Rule "34" is a fallback in those cases, but it produces a different result (though better than nothing).

3. Rule 34 doesn't get always transparency quite right since it uses code like:

	b _ (dstMask bitAnd: 255) * unAlpha >> 8 + (srcMask bitAnd: 255).

where <unAlpha> is in the range 0..255. If <unAlpha> is 255 (meaning the source was completely transparent), then the result is 99.609375% (i.e. 255/256) of the destination, which results in a slight darkening. This occurs only for certain source and destination bit depths since there are several optimizations that work differently.

Cheers,
Bob





More information about the Squeak-dev mailing list