All,
I can't figure this out. I have a wxListBook control to display
images. I have thumbnails in the ListCtrl and the full size image on
the page.
Thumbnail images are added to the wxImageList without problem UNLESS
the image is portrait, ie, greater height than width, then I get the
message "Couldn't add an image to the image list" and a -1 returned
from the il.Add(bmp). However, if I click in the ListCtrl where the
thumbnail should be, I can view the corresponding image.
I'm sure its something to do with masks, on which I am a bit of an
ignoramus.
Here is the code:
from PIL import Image
def set_images(self):
Sz = 50
il = wx.ImageList(Sz,Sz)
path = <image path>
imOrig = Image.open(path)
imThumb = imOrig.copy()
imThumb.thumbnail((Sz,Sz))
bmp = self.PilImageToWxBitmap(imThumb)
#- Add the thumb to the list
res = il.Add(bmp)
# Now make the panels for the list book
...
self.listbook.AssignImageList(il)
def PilImageToWxBitmap(self, myPilImage ) :
return
self.WxImageToWxBitmap( self.PilImageToWxImage( myPilImage ) )
def WxImageToWxBitmap(self, myWxImage ) :
return myWxImage.ConvertToBitmap()
def PilImageToWxImage(self, myPilImage ):
myWxImage = wx.EmptyImage( myPilImage.size[0],
myPilImage.size[1] )
myWxImage.SetData( myPilImage.convert( 'RGB' ).tostring() )
return myWxImage
regards
Phil