[wx-dev] bug in wxAlphaPixelData in wxMac and wxGTK?
Vadim Zeitlin
vadim at wxwindows.org
Sun Mar 4 11:23:35 PST 2007
On Thu, 01 Mar 2007 21:53:39 -0800 Robin Dunn <robin at alldunn.com> wrote:
RD> Andrew Trevorrow wrote:
RD> > I'm trying to use wxAlphaPixelData to create a semi-transparent bitmap
RD> > for use as a selection rectangle, but for some reason I'm getting
RD> > different results on each platform (Win XP, Mac OS 10.4.8 Intel, and
RD> > Debian Linux):
RD> >
RD> > http://www.trevorrow.com/wx/alpha-bug.png
RD> >
RD> > Note that I'm using wxWidgets 2.8.0 on each platform. Only the wxMSW
RD> > result looks correct. The wxMac and wxGTK results look similar but
RD> > are slightly different shades of green.
RD>
RD> Only do the premultiplication on wxMSW. The others can take the
RD> unmultiplied values. I have some macros to help me with this:
RD>
RD> #ifdef __WXMSW__
RD> #define wxPy_premultiply(p, a) ((p) * (a) / 0xff)
RD> #define wxPy_unpremultiply(p, a) ((a) ? ((p) * 0xff / (a)) : (p))
RD> #else
RD> #define wxPy_premultiply(p, a) (p)
RD> #define wxPy_unpremultiply(p, a) (p)
RD> #endif
Ugh, this is pretty bad. I remember past discussions about this but, as
usual, I don't remember if we reached an agreement about how should this
work. In any case, using different conventions for different platforms
hardly looks acceptable.
But as you're probably not alone using this workaround I'm not even sure
any more how exactly can we fix this without breaking the existing code. We
probably need to add wxPremultAlphaPixelData and wxNormalAlphaPixelData and
leave the existing class as is...
Regards,
VZ
More information about the wx-dev
mailing list