I am afraid this is the property of dual source blending - your
background must be opaque. If you can't satisfy this condition your
only option is to store the three alpha channels obtained from FT and
blend them with background later, when it is opaque (and eventually it
will be), or use normal alpha blending (one alpha channel).

regards

2015-11-03 23:08 GMT+01:00 John Found <[email protected]>:
> Hi. Thanks for the answer.
>
> On Tue, 3 Nov 2015 20:44:27 +0100
> Wojciech Mamrak <[email protected]> wrote:
>
>> Assuming C is non-pre-multiplied by alpha:
>> Fr = Fr/255 * Ca
>> Dr = Cr * Fr + Dr * (1 - Fr)
>> Da = Ca + Da * (1 - Ca)
>>
>> Assuming C is pre-multiplied by alpha:
>> Fr = Fr/255
>> Dr = Cr * Fr + Dr * (1 - Fr * Ca)
>> Da = Ca + Da * (1 - Ca)
>>
>
> Here is something wrong with these equations. (or with my understanding...)
>
> If we have fully transparent background:
>
> Da = 0, Drgb = 0
>
> and black color:
>
> Ca = 1, Crgb = 0
>
> ...then regardless of the values of Frgb, the result is always:
>
> Drgb=0 and Da = 1;
>
> i.e. we get black rectangles instead of glyphs.
>
> See the attachment for example. On this picture, the result bitmap is later 
> blended on gray background in order to make the result visible.
>
>
>> 2015-11-03 15:26 GMT+01:00 John Found <[email protected]>:
>> > I need to draw text on a transparent image with format ARGB, 
>> > pre-multiplied alpha.
>> >
>> > The rendered FT_Bitmap has format FT_PIXEL_MODE_LCD and I want the glyph 
>> > to be displayed in some color with transparency.
>> >
>> > So, for every pixel I have 3 numbers:
>> >
>> > Da, Dr, Dg, Db - destination pixel ARGB (the background image).
>> >     Fr, Fg, Fb - FreeType rendered pixel (FT_Bitmap rendered with 
>> > FT_RENDER_MODE_LCD)
>> > Ca, Cr, Cg, Cb - The color I want the glyph to be drawn.
>> >
>> > So, the question: How to properly combine these 3 numbers in order to get 
>> > the result bitmap pixel.
>> >
>> > A theory and math are welcome. If I understand the theory, I can write the 
>> > code.
>> >
>> > Best Regards.
>> > --
>> > http://fresh.flatassembler.net
>> > http://asm32.info
>> > John Found <[email protected]>
>> >
>> > _______________________________________________
>> > Freetype mailing list
>> > [email protected]
>> > https://lists.nongnu.org/mailman/listinfo/freetype
>
>
> --
> http://fresh.flatassembler.net
> http://asm32.info
> John Found <[email protected]>

_______________________________________________
Freetype mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype

Reply via email to