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