wxBitmapButton X PNG images on Win XP

Hi!

Does anybody here have problem with transparent PNGs being used in buttons?
wxPython 2.5.1.5, Python 2.3.3, w/o Unicode.

My images are perfect on Linux, but they have a white background on Windows
XP. I've checked it with Microsoft Picture Editor (something like that) and
it shows me the pictures as being transparent...

The most interesting thing is that there's an wxStaticBitmap that shows up
correctly (i.e. transparent), on the same screen.

Is it known? Is it something unsupported? If I change the PNGs for GIFs,
should it work?

···

--
Godoy. <godoy@ieee.org>

Jorge Godoy writes:

Does anybody here have problem with transparent PNGs being
used in buttons? wxPython 2.5.1.5, Python 2.3.3, w/o Unicode.

I had problems until doing image.SetMask(True), as in:

r = wx.Image(fileName, wx.BITMAP_TYPE_PNG)
r.SetMask(True)

I didn't need to do that in 2.4, but now I do in 2.5. I haven't
tried anything on WinXP yet though, just Linux/Mac/WinNT4.

  But I still have problems with some PNG's on Mac - some don't
appear at all while most do, so I've just ignored it for now,
hoping it'll magically fix itself in the next release. <g>

···

--
Paul
http://www.paulmcnett.com

Interesting. We hadn't this problem with 2.4.2.4 too.

Is there any way to make it standard for all objects that handle images or
we'd have to set up one by one? Due to the repetition of icons in this
particular screen, it would even be interesting to do that only once and
reuse the image, but there are other screens where we have different images
and having to modify one by one would be, at least, slow and
counterproductive...

What I have now is:

        self.btnExit = wxBitmapButton(self.panel_1, btnExit,
(wxBitmap(os.path.sep.join([images, 'exit.png']))))
        self.txtExit = wxStaticText(self.panel_1, -1, "Exit")

I tried changing that to

        self.btnExit = wxBitmapButton(self.panel_1, btnExit,
(wxBitmap(os.path.sep.join([images, 'exit.png'])).SetMask(True)))

But it didn't work (I thought it wouldn't because the return type would be
different, but I was just being optimistic... :-)). I also tried setting up
the wxBITMAP_TYPE_PNG, but it did no difference at all.

I also tried this:

        bmpExit = wxImage(os.path.sep.join([images, 'exit.png']),
wxBITMAP_TYPE_PNG)
        bmpExit.SetMask(True)
        bmpExit = bmpExit.ConvertToBitmap()

but the problem persisted and I got the white background.

The same happens with wxBitmapFromImage()...

I think this is something related to the conversion to Bitmap.

Be seeing you,

···

On Ter 25 Mai 2004 20:08, Paul McNett wrote:

Jorge Godoy writes:

Does anybody here have problem with transparent PNGs being
used in buttons? wxPython 2.5.1.5, Python 2.3.3, w/o Unicode.

I had problems until doing image.SetMask(True), as in:

r = wx.Image(fileName, wx.BITMAP_TYPE_PNG)
r.SetMask(True)

I didn't need to do that in 2.4, but now I do in 2.5. I haven't
tried anything on WinXP yet though, just Linux/Mac/WinNT4.

  But I still have problems with some PNG's on Mac - some don't
appear at all while most do, so I've just ignored it for now,
hoping it'll magically fix itself in the next release. <g>

--
Godoy. <godoy@ieee.org>

Jorge Godoy wrote:

Hi!

Does anybody here have problem with transparent PNGs being used in buttons?
wxPython 2.5.1.5, Python 2.3.3, w/o Unicode.

My images are perfect on Linux, but they have a white background on Windows
XP. I've checked it with Microsoft Picture Editor (something like that) and
it shows me the pictures as being transparent...

The most interesting thing is that there's an wxStaticBitmap that shows up
correctly (i.e. transparent), on the same screen.

Is it known? Is it something unsupported? If I change the PNGs for GIFs,
should it work?

The main difference between current and older versions and also between windows and linux in the current version is the support of the alpha channel in PNG images. Prior to 2.5 (and still in wxGTK 2.5) the alpha channel in PNG images was just converted to a mask. Now alpha blending is used and there are some internal changes to the platform specific parts of wxBitmap to support that. My guess is that wxMSW's wxBitmapButton is not doing the right thing with the alpha transparency.

Please enter a bug report about it, with a category of wxMSW Specific, and attach the image you are using that is having the problem.

···

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

File a bug *where*?

···

On Qui 27 Mai 2004 14:36, Robin Dunn wrote:

Please enter a bug report about it, with a category of wxMSW Specific,
and attach the image you are using that is having the problem.

--
Godoy. <godoy@ieee.org>

Jorge Godoy wrote:

···

On Qui 27 Mai 2004 14:36, Robin Dunn wrote:

Please enter a bug report about it, with a category of wxMSW Specific,
and attach the image you are using that is having the problem.

File a bug *where*?

The SourceForge project page for wxWindows. There is a link "Report a Bug" on the wxPython website that will take you there. You must be logged in to a SourceForge account to enter a bug report.

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