我真的不明白以下代码导致的条带化行为。我更希望看到位图的上半部分是白色的,而下半部分是黑色的。我想我可能在这里误解了一些基本的东西。感激地收到任何帮助。
import numpy
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size = (135,655))
width = 128
height = 640
color = (255,255,255)
array = numpy.zeros((width,height,3),'uint8')
array[:,:,] = color
print array[10,10,0]
array[0:128,0:320,0:3] = 0
print array[10,10,0]
image = wx.EmptyImage(width,height)
image.SetData(array.tostring())
self.bitmap = image.ConvertToBitmap()
wx.EVT_PAINT(self, self.OnPaint)
self.Centre()
def OnPaint(self, event):
dc = wx.PaintDC(self)
dc.DrawBitmap(self.bitmap,3,10)
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, '2DS')
frame.Show(True)
self.SetTopWindow(frame)
return True
app = MyApp(0)
app.MainLoop()