[wx-dev] bug in wxAlphaPixelData in wxMac and wxGTK?

Robin Dunn robin at alldunn.com
Thu Mar 1 21:53:39 PST 2007


Andrew Trevorrow wrote:
> I'm trying to use wxAlphaPixelData to create a semi-transparent bitmap
> for use as a selection rectangle, but for some reason I'm getting
> different results on each platform (Win XP, Mac OS 10.4.8 Intel, and
> Debian Linux):
> 
>    http://www.trevorrow.com/wx/alpha-bug.png
> 
> Note that I'm using wxWidgets 2.8.0 on each platform.  Only the wxMSW
> result looks correct.  The wxMac and wxGTK results look similar but
> are slightly different shades of green.

Only do the premultiplication on wxMSW.  The others can take the 
unmultiplied values.  I have some macros to help me with this:

#ifdef __WXMSW__
#define wxPy_premultiply(p, a)   ((p) * (a) / 0xff)
#define wxPy_unpremultiply(p, a) ((a) ? ((p) * 0xff / (a)) : (p))
#else
#define wxPy_premultiply(p, a)   (p)
#define wxPy_unpremultiply(p, a) (p)
#endif


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wx-dev mailing list