[Mono-winforms-list] DrawImage alpha blend broken in libgdiplus

Sebastien Pouliot sebastien.pouliot at gmail.com
Wed Apr 8 13:33:43 EDT 2009

Hello Alex,

The patch looks good. However this kind of fix has been known to cause
regression in the past. 

Could you supply unit tests that ensure that the image can be saved and
reloaded correctly ? (modifying your previous sample code should be

With this (and if all existing tests pass successfully) I'll be able to
commit your patch.


On Wed, 2009-04-08 at 18:59 +0300, Alex Shulgin wrote:
> Alex Shulgin wrote:
> > Hi,
> > 
> > I believe that alpha blending is broken in libgdiplus.
> I've located the problem.  It is due to the inconsistent handling of 
> PixelFormat32bppPArgb (premultiplied alpha) in libgdiplus.
> In the attached patch I've added the check on PArgb to DrawImageRect in 
> analogy with texturebrush.c and fixed pngcodec.c to set pixel format to 
> PArgb if premultiplication was done.
> This fixes my demo program and there's no visible regressions in a 
> fairly complex application which originally revealed the problem.
> If the feeling is such that this is appropriate patch, I'd add the same 
> handling for places like this (there's few).
> --
> Regards,
> Alex
> _______________________________________________
> Mono-winforms-list maillist  -  Mono-winforms-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-winforms-list

More information about the Mono-winforms-list mailing list