Bug in Bitmap / PNG Transparency?

Hi,

When trying to display a PNG via wx.Image and wx.BitmapFromImage, it
appears as though the alpha channel isn't rendered properly. I have
attached a sample image and test-case, which is a white-to-transparent
gradient on top, and a solid white color on the bottom. That image
/should/ render as solid white when the background is white, however it
instead renders a greyish-gradient. Is this a bug in wxPython, or
wxWidgets, or am I doing something wrong?

Attached are white_gradient.png (the 32-bit gradient/white PNG), test.py
(an example), and result_output.png (a screenshot of the example as
taken on WinXP).

Thanks,

Marcus

white_gradient.png

result_output.png

test.py (538 Bytes)

Marcus wrote:

When trying to display a PNG via wx.Image and wx.BitmapFromImage, it
appears as though the alpha channel isn't rendered properly. I have
attached a sample image and test-case, which is a white-to-transparent
gradient on top, and a solid white color on the bottom. That image
/should/ render as solid white when the background is white, however it
instead renders a greyish-gradient. Is this a bug in wxPython, or
wxWidgets, or am I doing something wrong?

Attached are white_gradient.png (the 32-bit gradient/white PNG), test.py
(an example), and result_output.png (a screenshot of the example as
taken on WinXP).

It will probably ring like one of those annoyingly-spot-on commercials, but your test case renders perfectly on Mac.

···

--
pkm ~ http://paulmcnett.com

Marcus wrote:

Hi,

When trying to display a PNG via wx.Image and wx.BitmapFromImage, it
appears as though the alpha channel isn't rendered properly. I have
attached a sample image and test-case, which is a white-to-transparent
gradient on top, and a solid white color on the bottom. That image
/should/ render as solid white when the background is white, however it
instead renders a greyish-gradient. Is this a bug in wxPython, or
wxWidgets, or am I doing something wrong?

Attached are white_gradient.png (the 32-bit gradient/white PNG), test.py
(an example), and result_output.png (a screenshot of the example as
taken on WinXP).

Have you tried drawing the image yourself instead of letting the static bitmap widget do it?

···

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

Robin Dunn wrote:

Have you tried drawing the image yourself instead of letting the static
bitmap widget do it?

Good idea. It works fine when doing that, or using a wx.lib.statbmp
control instead... so it must be a problem with wxWidgets itself.

Marcus wrote:

Robin Dunn wrote:

Have you tried drawing the image yourself instead of letting the static
bitmap widget do it?

Good idea. It works fine when doing that, or using a wx.lib.statbmp
control instead... so it must be a problem with wxWidgets itself.

More likely with the native static bitmap widget, or that its interpretation of the alpha data is different than normal, or something.

···

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