[wxPython] Problems with bitmaps and icons

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Problems with bitmaps and icons

George Thom@s
Hi everyone,
I am using the pre-compiled binary of wxPython 2.1.11 for Windows. I have a
couple of queries in this regard.
1. Does the wxImageList constructor accept dimension values greater than 16
? I tried 32*32 in vain.
2. Is the support for the PNG format ? Is there any way for me to check this
out ? I can't seem to be able to use anything but BMP and ICO.
Regards,
George
--------------------------------------------------------------------------
George Thomas
Resident,Planet Earth,Third Rock from the Sun
[hidden email]


Flat No. FI-5, Fifth Floor,
Himagirinath Co-op. Hsg. Society,
486A Elphinstone Road,
Kirkee, Pune - 411003,
Maharashtra State,
India.
--------------------------------------------------------------------------


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Problems with bitmaps and icons

Markus Gritsch
"George Thom@s" wrote:

> Hi everyone,
> I am using the pre-compiled binary of wxPython 2.1.11 for Windows. I have a
> couple of queries in this regard.
> 1. Does the wxImageList constructor accept dimension values greater than 16
> ? I tried 32*32 in vain.
> 2. Is the support for the PNG format ? Is there any way for me to check this
> out ? I can't seem to be able to use anything but BMP and ICO.

By looking at the demo you should have recognized, that there is some
demo-code, which loads various graphic formats, including PGN

And if you would have searched the users-archive at searchbutton.com
(http://search.searchbutton.com/search?site=1148125724), you would have found
several postings discussing this. I searched for you and put here some text
Robin has written:

[Robin]
You need to call wxImage_AddHandler(wxPNGHandler()) sometime before you try
to use the image.  wxWindows has the concept of image handlers that can be
loaded only for programs that need them to save memory resources.  The next
version of wxPython will have wxInitAllImageHandlers() to load them all for
you.



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Problems with bitmaps and icons

Robin Dunn
In reply to this post by George Thom@s
> Hi everyone,
> I am using the pre-compiled binary of wxPython 2.1.11 for Windows. I have a
> couple of queries in this regard.
> 1. Does the wxImageList constructor accept dimension values greater than 16
> ? I tried 32*32 in vain.

I've never tried but I think it depends on what you are going to use the
image list for.  Some controls on MSW may have limits.  I've seen larger
images on a wxNotebook before, but i don't think I ever have on a wxTreeCtrl
on MSW.


> 2. Is the support for the PNG format ? Is there any way for me to check
this
> out ? I can't seem to be able to use anything but BMP and ICO.

As has been mentioned already, You simply need to activate the image handlers
for the formats you want.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Problems with bitmaps and icons

Riaan Booysen


Robin Dunn wrote:

>
> > Hi everyone,
> > I am using the pre-compiled binary of wxPython 2.1.11 for Windows. I have a
> > couple of queries in this regard.
> > 1. Does the wxImageList constructor accept dimension values greater than 16
> > ? I tried 32*32 in vain.
>
> I've never tried but I think it depends on what you are going to use the
> image list for.  Some controls on MSW may have limits.  I've seen larger
> images on a wxNotebook before, but i don't think I ever have on a wxTreeCtrl
> on MSW.

In Pygasm there are wxImageLists of size 24*24 used with wxListCtrls
and wxTreeCtrls, no problems for me on WinNT. It might be your
comctl32.dll version. The only 16*16 size limitation I have encountered
has been for wxToolBar on wxGTK. (Anyone know if/when this will be
fixed?)

A while ago, if I recall correctly, someone asked which color depths
were
supported by wxImageList. So far any color depth I've used (16 cols,
256 cols, 24 bit color) works. But it gets better, you can mix pictures
with different depths in one wxImageList and it is still handled
correctly.

Robin, do you know why a wxToolBar doesn't use an wxImageList like all
the other image list using controls? Has this been discussed in the
wxWin lists?

I'm having the most baffling problem with wxToolBar myself. I can't seem
to add a tool button with picture containing the color red.
Pure red comes out as blue, regardless of the color depth.
All other colors work fine. Blue is blue, yellow is yellow etc.
This is really weird.
Running on interim build wxPython-2.1.11-20000102

Riaan

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Problems with bitmaps and icons

Robin Dunn
>
> Robin, do you know why a wxToolBar doesn't use an wxImageList like all
> the other image list using controls? Has this been discussed in the
> wxWin lists?
>

Probably because the underlying MSW control does not use an image list.  In
fact it doesn't even use separate bitmaps but just one with all the button
images next to each other.  When you call wxToolbar.Realize wxWindows takes
all the bitmaps you used with AddTool and builds the one bitmap to be sent to
MSW.


> I'm having the most baffling problem with wxToolBar myself. I can't seem
> to add a tool button with picture containing the color red.
> Pure red comes out as blue, regardless of the color depth.
> All other colors work fine. Blue is blue, yellow is yellow etc.
> This is really weird.
> Running on interim build wxPython-2.1.11-20000102
>

Eeek!  That sounds nasty!  Given the above info, there may be some kinds of
interaction with the other images, a mask or a pallete or someting.  Try it
on a toolbar by itself and see if it still behaves that way.  If so, send me
the image and a small sample and I'll trace through in the debugger to see
what's going on.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Problems with bitmaps and icons

Riaan Booysen


Robin Dunn wrote:

>
> >
> > Robin, do you know why a wxToolBar doesn't use an wxImageList like all
> > the other image list using controls? Has this been discussed in the
> > wxWin lists?
> >
>
> Probably because the underlying MSW control does not use an image list.  In
> fact it doesn't even use separate bitmaps but just one with all the button
> images next to each other.  When you call wxToolbar.Realize wxWindows takes
> all the bitmaps you used with AddTool and builds the one bitmap to be sent to
> MSW.
>
Right you are, I just checked the Win32 API and they use just add plain
old bitmaps (sorry should have checked before posting).
Interesting thing I suspected and just read in the help is that toolbar
images default to 16*15 and not 16*16.
I guess I expected toolbars to use image lists because that's the way
it's done in Delphi. Behind the scenes they probably also just feed the
toolbar one long bitmap.

> > I'm having the most baffling problem with wxToolBar myself. I can't seem
> > to add a tool button with picture containing the color red.
> > Pure red comes out as blue, regardless of the color depth.
> > All other colors work fine. Blue is blue, yellow is yellow etc.
> > This is really weird.
> > Running on interim build wxPython-2.1.11-20000102
> >
>
> Eeek!  That sounds nasty!  Given the above info, there may be some kinds of
> interaction with the other images, a mask or a pallete or someting.  Try it
> on a toolbar by itself and see if it still behaves that way.  If so, send me
> the image and a small sample and I'll trace through in the debugger to see
> what's going on.
>
I've tested it on the wxToolBar.py file of the wxPython demo and the red
still
goes blue, even if it's the only button on the toolbar. I've attached a
little
red containing bmp which you can just copy into demo/bitmaps directory
and
look at the toolbar in demo.py to see the problem in action.

Riaan

new.bmp (336 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Problems with bitmaps and icons

Robin Dunn
> I've tested it on the wxToolBar.py file of the wxPython demo and the red
> still
> goes blue, even if it's the only button on the toolbar. I've attached a
> little
> red containing bmp which you can just copy into demo/bitmaps directory
> and
> look at the toolbar in demo.py to see the problem in action.

Okay, I've just fixed this in wxWindows.  As a workaround you can change the
red to almost red (254,0,0 instead of 255,0,0) or just wait for the next
interim release.

The wxToolbar on MSW maps certain colours in the tool bitmaps to the current
system colours.  The default system colours for the button face, highlight,
shadow, text are mapped to the current system settings.  This means you don't
have to define masks for your bitmaps if you use (192,192,192) for the
background colour and if you use black for text it will be mapped to the
current button text colour.  This is nice and conveinent.

However... For some reason pure blue (used to be red, the bug was that the
colour values were defined backwards) and pure magenta (255,0,255) are mapped
to the system selection colour and the system window colour respectivly.
These last two make no sense to me and I will lobby for their removal, but
until then be aware that this is how it works.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users