From 1d1972fce1db0ae559433967255ce486b0d7494a Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 23 Aug 2006 01:52:20 +0000 Subject: [PATCH] Premultiply the alpha on wxMSW in the BitmapFromBuffer* functions so the programmers don't have to worry about it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40764 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/_bitmap.i | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/wxPython/src/_bitmap.i b/wxPython/src/_bitmap.i index 8aa329e133..fcb37d0a41 100644 --- a/wxPython/src/_bitmap.i +++ b/wxPython/src/_bitmap.i @@ -317,6 +317,18 @@ the ``type`` parameter.", ""); // use the Abstract Pixel API to be able to set RGB and A bytes directly into // the wxBitmap's pixel buffer. +%{ +// See http://tinyurl.com/e5adr for what premultiplying alpha means. It +// appears to me that the other platforms are already doing it, so I'll just +// automatically do it for wxMSW here. +#ifdef __WXMSW__ +#define wxPy_premultiply(p, a) ((p) * (a) / 256) +#else +#define wxPy_premultiply(p, a) (p) +#endif +%} + + %newobject _BitmapFromBufferAlpha; %newobject _BitmapFromBuffer; %inline %{ @@ -348,10 +360,11 @@ the ``type`` parameter.", ""); for (int y=0; y