We are upgrading a project from wxPython 2.4.x to the latest version and have run into problems with out bitmap loading code which is used for icons and toolbars.
Any bitmap that has been saved as a 32 bit image fails to load - either missing toolbar image or black icon. 24 bit images load fine.
Since we don’t actually use alpha channels (only a magenta mask) converting them all to 24 bit will likely fix the issue but I would prefer to fix it in code.
Our loading code is similar to this:
img = wx.Image(filename, wx.BITMAP_TYPE_BMP)
if mask:
img.SetMaskColour(255, 0, 255)
bmp = wx.BitmapFromImage(img)
I note in the documentation that in 2.5 32 bit alpha support was added to wxImage and wxBitmap so maybe we are not doing something right somewhere.
We are upgrading a project from wxPython 2.4.x to the latest version and have run into problems with out bitmap loading code which is used for icons and toolbars.
Any bitmap that has been saved as a 32 bit image fails to load - either missing toolbar image or black icon. 24 bit images load fine.
Since we don't actually use alpha channels (only a magenta mask) converting them all to 24 bit will likely fix the issue but I would prefer to fix it in code.
Our loading code is similar to this:
img = wx.Image(filename, wx.BITMAP_TYPE_BMP)
if mask:
img.SetMaskColour(255, 0, 255)
bmp = wx.BitmapFromImage(img)
I note in the documentation that in 2.5 32 bit alpha support was added to wxImage and wxBitmap so maybe we are not doing something right somewhere.
Thanks,
Leith
I think the SetMaskColour() method is a little different now. It looks like it accepts a wx.Colour, a HTML-like code, a tuple or some kind of "word". See the following docs:
No that doesn't work since I am using wxImage's set mask color which has
the SetMaskColour(self, r, g, b) prototype.
Seems to be a lot of inconsistency between wxImage and
wxBitmap/wxIcon/wxCursor so maybe at somestage wxWidgets should try to
unify or at least make their functions have compatible prototypes.
But anyway some the images that are not loading don't use a mask.
So there is something elso going on.
I wonder what the 'official' way of loading an image into a bitmap is
currently since their seems to be large number of different functions
for converting between images, bitmaps and icons.
Leith
···
-----Original Message-----
From: wxpython-users-bounces@lists.wxwidgets.org
[mailto:wxpython-users-bounces@lists.wxwidgets.org] On Behalf Of Mike
Driscoll
Sent: Wednesday, 7 January 2009 11:31 a.m.
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] 32 bit bitmap loading
Leith Bade wrote:
We are upgrading a project from wxPython 2.4.x to the latest version
and have run into problems with out bitmap loading code which is used
for icons and toolbars.
Any bitmap that has been saved as a 32 bit image fails to load -
either missing toolbar image or black icon. 24 bit images load fine.
Since we don't actually use alpha channels (only a magenta mask)
converting them all to 24 bit will likely fix the issue but I would
prefer to fix it in code.
I note in the documentation that in 2.5 32 bit alpha support was added
to wxImage and wxBitmap so maybe we are not doing something right
somewhere.
Thanks,
Leith
I think the SetMaskColour() method is a little different now. It looks
like it accepts a wx.Colour, a HTML-like code, a tuple or some kind of
"word". See the following docs:
I gave up and just used IrfranView to convert everything to 24 bit
depth, and it works.
Still might be handy to know what is causing the problems though.
Leith
···
-----Original Message-----
From: wxpython-users-bounces@lists.wxwidgets.org
[mailto:wxpython-users-bounces@lists.wxwidgets.org] On Behalf Of Leith
Bade
Sent: Wednesday, 7 January 2009 11:43 a.m.
To: wxpython-users@lists.wxwidgets.org
Subject: RE: [wxpython-users] 32 bit bitmap loading
No that doesn't work since I am using wxImage's set mask color which has
the SetMaskColour(self, r, g, b) prototype.
Seems to be a lot of inconsistency between wxImage and
wxBitmap/wxIcon/wxCursor so maybe at somestage wxWidgets should try to
unify or at least make their functions have compatible prototypes.
But anyway some the images that are not loading don't use a mask.
So there is something elso going on.
I wonder what the 'official' way of loading an image into a bitmap is
currently since their seems to be large number of different functions
for converting between images, bitmaps and icons.
Leith
-----Original Message-----
From: wxpython-users-bounces@lists.wxwidgets.org
[mailto:wxpython-users-bounces@lists.wxwidgets.org] On Behalf Of Mike
Driscoll
Sent: Wednesday, 7 January 2009 11:31 a.m.
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] 32 bit bitmap loading
Leith Bade wrote:
We are upgrading a project from wxPython 2.4.x to the latest version
and have run into problems with out bitmap loading code which is used
for icons and toolbars.
Any bitmap that has been saved as a 32 bit image fails to load -
either missing toolbar image or black icon. 24 bit images load fine.
Since we don't actually use alpha channels (only a magenta mask)
converting them all to 24 bit will likely fix the issue but I would
prefer to fix it in code.
I note in the documentation that in 2.5 32 bit alpha support was added
to wxImage and wxBitmap so maybe we are not doing something right
somewhere.
Thanks,
Leith
I think the SetMaskColour() method is a little different now. It looks
like it accepts a wx.Colour, a HTML-like code, a tuple or some kind of
"word". See the following docs:
I gave up and just used IrfranView to convert everything to 24 bit
depth, and it works.
Still might be handy to know what is causing the problems though.
Leith
Yeah...this is another one of the areas of wxPython that I am fuzzy with. Hopefully one of the others who uses images a lot can give us an explanation or tutorial.
Mike
···
-----Original Message-----
From: wxpython-users-bounces@lists.wxwidgets.org
[mailto:wxpython-users-bounces@lists.wxwidgets.org] On Behalf Of Leith
Bade
Sent: Wednesday, 7 January 2009 11:43 a.m.
To: wxpython-users@lists.wxwidgets.org
Subject: RE: [wxpython-users] 32 bit bitmap loading
No that doesn't work since I am using wxImage's set mask color which has
the SetMaskColour(self, r, g, b) prototype.
Seems to be a lot of inconsistency between wxImage and
wxBitmap/wxIcon/wxCursor so maybe at somestage wxWidgets should try to
unify or at least make their functions have compatible prototypes.
But anyway some the images that are not loading don't use a mask.
So there is something elso going on.
I wonder what the 'official' way of loading an image into a bitmap is
currently since their seems to be large number of different functions
for converting between images, bitmaps and icons.
Leith
-----Original Message-----
From: wxpython-users-bounces@lists.wxwidgets.org
[mailto:wxpython-users-bounces@lists.wxwidgets.org] On Behalf Of Mike
Driscoll
Sent: Wednesday, 7 January 2009 11:31 a.m.
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] 32 bit bitmap loading
Leith Bade wrote:
We are upgrading a project from wxPython 2.4.x to the latest version and have run into problems with out bitmap loading code which is used for icons and toolbars.
Any bitmap that has been saved as a 32 bit image fails to load - either missing toolbar image or black icon. 24 bit images load fine.
Since we don't actually use alpha channels (only a magenta mask) converting them all to 24 bit will likely fix the issue but I would prefer to fix it in code.
Our loading code is similar to this:
img = wx.Image(filename, wx.BITMAP_TYPE_BMP) if mask:
img.SetMaskColour(255, 0, 255)
bmp = wx.BitmapFromImage(img)
I note in the documentation that in 2.5 32 bit alpha support was added
to wxImage and wxBitmap so maybe we are not doing something right somewhere.
Thanks,
Leith
I think the SetMaskColour() method is a little different now. It looks
like it accepts a wx.Colour, a HTML-like code, a tuple or some kind of
"word". See the following docs:
We are upgrading a project from wxPython 2.4.x to the latest version and have run into problems with out bitmap loading code which is used for icons and toolbars.
Any bitmap that has been saved as a 32 bit image fails to load - either missing toolbar image or black icon. 24 bit images load fine.
Since we don't actually use alpha channels (only a magenta mask) converting them all to 24 bit will likely fix the issue but I would prefer to fix it in code.
Our loading code is similar to this:
img = wx.Image(filename, wx.BITMAP_TYPE_BMP)
if mask:
img.SetMaskColour(255, 0, 255)
bmp = wx.BitmapFromImage(img)
I note in the documentation that in 2.5 32 bit alpha support was added to wxImage and wxBitmap so maybe we are not doing something right somewhere.
Please create a bug ticket for this and include an example of an image that triggers the problem.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!