Bonjour,
Je souhaite convertir une Image de PIL vers une bitmap de wx.
Je manipule exclussivement des images 24bits (RGB pleine résolution donc.)
Avec la version de pyhton 2.5 pas de pb.
Seulement je suis contraint à utiliser python 2.2 et wx.BitmapFromBuffer n'y est pas disponible.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 imPil = Image.open("C:/images/image1.bmp") imData = imPil.tostring("raw", "RGB") bmp = wx.BitmapFromBuffer(width, height, imData) staticBmp = wx.StaticBitmap(self,wx.ID_ANY,bmp) ca ok en 2.5
Je pensais donc utiliser wx.BitmapFromBits :
"doc"=
"BitmapFromBits(bits, width, height, depth=1)
Creates a bitmap from an array of bits. You should only use this function for monochrome bitmaps (depth 1) in portable programs: in this case the bits parameter should contain an XBM image. For other bit depths, the behaviour is platform dependent."
mais je ne vois pas comment obtenir "array of bits" depuis une Image PIL
je pensais aussi passer par wx.Image:
une solution ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 imPil = Image.open("C:/images/image1.bmp") imData = imPil.tostring("raw", "RGB") imwx = wx.Image("") imwx.SetData(imData) bmp = wx.BitmapFromImage(im) staticBmp= wx.StaticBitmap(self,wx.ID_ANY,bmp) marche pas, PyAssertionError lors du setData
Partager