« Return to Thread: Blending and Drawing produce different image..

Re: Blending and Drawing produce different image..

by Jim Barry-2 :: Rate this Message:

Reply to Author | View in Thread

Peter Yang wrote:

> Here is situation..
>
> 1. Draw rectangle A with Solid Color RGBA(0,0,255,128)
> 2. Draw rectangle B with solid color RGBA(0,255,0,128) overlapped
> with A
> 3. Draw rectangle C -RGBA(0,255,0,128) in different DIB buffer
>   and blend over rectangle A
>
> all pixel format was agg::pixfmt_bgra32
>
> overllapped area between 1 and 2, 1 and 3 produce different color :(..

This is because your buffers are premultiplied, i.e. for each pixel the RGB values are scaled by the alpha value.

pixfmt_bgra32 blends "plain" (non-premultiplied) source with premultiplied destination.

pixfmt_bgra32_pre blends premultiplied source with premultiplied destination.

pixfmt_bgra32_plain blends plain source with plain destination.

Therefore, to blend two premultiplied buffers you need to use pixfmt_bgra32_pre.

- Jim


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

 « Return to Thread: Blending and Drawing produce different image..