wx.AlphaPixelData question
Danny Shevitz
shevitz at lanl.gov
Thu Feb 1 10:58:39 PST 2007
Howdy,
I have used img2py to create a bitmap. I am now trying to manipulate it
using raw bitmap access. wx.AlphaPixelData is
dying, telling me I have the wrong kind of Bitmap. I'm pretty sure my
original .bmp file was a three color bitmap, with no
alpha. Is there any way to work around this. I have found wx.AlphaPixelData
to be completely undocumented at wxPython (or
wxWidgets).
I am enclosing a minimal code example that demonstrates the problem.
TIA,
Danny
-------------- next part --------------
import wx
from wx import ImageFromStream, BitmapFromImage
import cStringIO
#----------------------------------------------------------------------
DIM = 32
def getAndGateData():
return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
\x00\x00\x9cIDAT8\x8d\xed\x90\xcd\x0e\x83@\x08\x06\x07p\xf5\xea\xc9\xc4\xf8\
\xfe\x8f\xe6Cl\x16\xa5\x87Vc\xb5\xe9\x8f\xed\xb1_\xc2\x05\x98I at D\x8d}b\x9e\
\x02`\x18\x06\x00\xc6q\x04@\xd4\xe4\xb0,j\x88\x1a\xee\x1e at 4M\x13@,\xfd\xa5\
\xb63w_\xe7wp\xdf\xf7\x07\xf0\x91\x08\x88RJ\xac\x82w\xe1\xbdD\xd4\x10Q#U\x16\
\xc5\xa7\xe3}O\x12\xf3\x14\xa2&r\xb3=~\xd0\x0b\x01\x80\x9e\x81\xb7\x8cv]\xf7\
)\xbb\xa6m[4\xe7|Z\x90s\xbe\x9e\xf0M\xfe\x82\x1f\x08\xaa\x94\x12\xa9\xb28\
\x03\xd7u\xcd\x05&c:\xd6\x1e\xd7\xeaW\x00\x00\x00\x00IEND\xaeB`\x82'
def getAndGateBitmap():
return BitmapFromImage(getAndGateImage())
def getAndGateImage():
stream = cStringIO.StringIO(getAndGateData())
return ImageFromStream(stream)
class MyFrame(wx.Frame):
def __init__(self, *args):
wx.Frame.__init__(self, *args)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.myBitmap = getAndGateBitmap()
wx.AlphaPixelData(self.myBitmap)
def OnPaint(self, evt):
dc = wx.PaintDC(self)
dc.DrawBitmap(self.myBitmap, 0, 0, True)
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, 'bitmap test.py')
frame.Show(True)
return True
app = MyApp(0)
app.MainLoop()
More information about the wxpython-users
mailing list