I am learning wxPython. My question is how create bit map. I have R, G, B values for each pixel but I don't know how create bit map from it. I tried use wx.BitmapFromBuffer, I don't understand how should I create this buffer. I went through each pixel and in linear way put in list R, G, B components, but it did not draw what I expected. Do you understand how the buffer should be constructed?.
I don't want draw each pixel on bitmap using wx.MemoryDC because it is too slow.
Thank you!
Edit: I use approach from wxPython demo - RawBitmapAccess.
buf = numpy.empty((w,h,3), numpy.uint8)
n = 29000
for i in xrange(w):
for j in xrange(h):
r = int(n*255*field[j,i])
if r > 253:
r = 253
buf[i, j, 0] = int(r)
buf[i, j, 1] = int(r)
buf[i, j, 2] = int(b)
#dc.SetPen(wx.Pen(wx.Colour(r,r,b)))
#dc.DrawPoint(i,j)
bmp = wx.BitmapFromBuffer(w, h, buf)
gc = wx.GraphicsContext.Create(dc)
gc.DrawBitmap(bmp, 0, 0, w, h)
If I uncomment my old way of drawing (two commented lines in the loop) then I got what I want - one fuzzy ball. If I don't uncomment them that I have odd picture - it is splitted vertically for several fragments, each have it own fuzzy ball, plus it look like that there is vertical lines of missed pixels. I use buffer in the same way as in demo program. Why I get weird picture?
Edit2: I figure out it. I should swap i and j in the loop.