wx.Image: Couldn't add an image to the image list.

Laszlo Zsolt Nagy gandalf at geochemsource.com
Wed Jan 26 06:57:21 EST 2005


I would like to load image from a directory right into an image list.
I wrote a simple library that loads the images in the directory and
resizes them as needed before adding to the wx.ImageList.
This is not the same code but some snippets.

I resize the image this way (using Python Imaging Library):

def resizeimage(image,newsize):
   oldsize = (image.GetWidth(),image.GetHeight())
   if oldsize != newsize:
       return piltoimage(resizepil(imagetopil(image),newsize))
   else:
       return image

This is how I convert images to a bitmaps:

bmp = wx.BitmapFromImage(image,depth=depth)

I have a directory with 16x16 bmp images in it. Everything works fine 
for sizes
16x16 and below. When I try to use a bigger size (say, 32x32) I get the 
following
message:

Couldn't add an image to the image list.

It is repeated for every image. (I used wx.PySimpleApp.) There is the 
same problem
when I try to force 8bit color depth.  Where is the problem? Is this 
related to my
Windows XP platform?

Best,

  Laci  2.0

p.s.: I wonder why it is not named wx.BitmapList since one can only 
store wx.Bitmap instances in it. Late sorrow. :-)





More information about the Python-list mailing list