How to create a smoothed transparent form?

Raab, Andreas Andreas.Raab at disney.com
Sun Jan 2 23:31:19 UTC 2000


Stafan,

> I ended up fixing the TTFontReader 

Heh, heh. Thanks a lot for fixing up the cmap encodings ;-)

> but actually I wanted to do something
> else, but got distracted.  I'd like to automatically create GIFs from
> morphs, TTSampleStringMorphs actually.  I wrote a method
> 
> Morph>>saveAsGifNamed: aString 
>   GIFReadWriter putForm: self imageForm onFileNamed: aString
> 
> and this works quite well unless it comes to smoothing and 
> transparence.
> The morph is always smoothed towards black which doesn't look right.
> Where's the right place to change this?  When I overwrite
> Morph>>imageForm:forRectangle: to set a background color, everything
> looks fine but that's not the solution I've in mind.

Well, this is sort of the right way to do it. You need to know against which
color to blend since GIF doesn't have per pixel transparency information. In
Squeak, the Balloon engine blends against the background of the Morph which
may be any color. The reason why it looks blended towards black is that the
combination rule which is used in the Balloon engine assumes that the source
is using pre-multiplied alpha (e.g., red <= alpha, blue <= alpha, and green
<= alpha for each color value). Thus, if there is no explicit background
color set it blends with zero, representing color black.

Another way of doing it would be to embed the TTMorph into another morph
that has a plain color (the color against which to blend) and then use
#imageForm:forRectangle: for this background morph.

Hope this helps (if not just drop me a note)

  Andreas





More information about the Squeak-dev mailing list