[Vm-dev] BitBlt looking for rule blitting an alpha mask +
constant color
Igor Stasenko
siguctua at gmail.com
Sat Jun 20 00:23:09 UTC 2009
2009/6/20 Andreas Raab <andreas.raab at gmx.de>:
>
> Easy. Make a color map that is set up such that
>
> cmap := Bitmap new: 256.
> 0 to: 255 do:[:i|
> cmap at: i+1 put: (constColor alpha: i/255.0) pixelValue32.
> ].
>
That is possible, but the price is generating a color map each time
the color changes :(
Much less price than converting/using 32 bpp, but still is not perfect :)
> Then BitBlt with that color map and Form blend. If you have more than 8 bit
> input, first create a ColorMap which extracts only the alpha component.
>
I found that rule 41 accepts the 8bpp bitmaps, but the problems is,
that its blends with yellow color, no matter
what i put in "A" or "B" (see below).
this is a Form's subclass method:.
blitOn: destForm at: aPoint color: color width: w height: h
| col bitBlt map |
map := Bitmap new: 256.
"A" 0 to: 255 do:[:i | map at: i+1 put: i ].
col := (color pixelValueForDepth: 32).
bitBlt := GrafPort toForm: destForm.
bitBlt colorMap: map.
bitBlt combinationRule: 41.
bitBlt sourceForm: self.
bitBlt destOrigin: aPoint.
bitBlt width: w; height: h.
bitBlt sourceOrigin: 0 at 0.
bitBlt
"B" copyBitsColor: 16r00FF00 "(col bitAnd: 16rFFFFFF)"
alpha: 255 " (col bitAnd: 16rFF000000) >> 24 "
gammaTable: nil
ungammaTable: nil
Any advice, how to force rule 41 work correctly? Or it is impossible? :)
Btw, i don't sure that my VM (windoze) having latest & fixed rule 41.
I remember there were problems with it.
> Cheers,
> - Andreas
>
>
> Igor Stasenko wrote:
>>
>> Hello,
>>
>> to what i see, there is no rule, which can use following formula:
>>
>> result = constanColor * srcAlpha + (destColor * ( 1-srcAlpha))
>>
>> where scrAlpha is taken from source form, and if source form is 8 bit
>> depth, it is assumed that form contains no RGB data, only alpha
>> channel.
>>
>> A rule 41 is more generic, but requires to convert a source form to
>> 32bpp before blitting :(
>> Maybe it worth modifying rule 41 to allow 8bit forms?
>> Or maybe its worth introducing a new one?
>> What you think?
>>
>> This new rule is essentially useful for freetype plugin, which
>> receives an opacity mask from freetype library.
>> But unfortunately, because we don't have such rule, we can't use a
>> bitmap, produced by freetype, directly unless converting it to 32bpp.
>> Or maybe we can, but looking at freetype font cache code, it seems
>> that every form is converted to 32bpp before placing in cache.
>>
>> Being able to operate with 8bpp alpha-masks will reduce a memory
>> footprint & increase rendering speed considerably.
>>
>
--
Best regards,
Igor Stasenko AKA sig.
More information about the Vm-dev
mailing list