projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Removed obsolete code
[wxWidgets.git]
/
wxPython
/
demo
/
BitmapFromBuffer.py
diff --git
a/wxPython/demo/BitmapFromBuffer.py
b/wxPython/demo/BitmapFromBuffer.py
index 2f72f6a02e1cd1b52547715a4305e3274daa2c41..69f2c0664307141b2699e4dfbc780f9808dce71c 100644
(file)
--- a/
wxPython/demo/BitmapFromBuffer.py
+++ b/
wxPython/demo/BitmapFromBuffer.py
@@
-34,18
+34,13
@@
class TestPanel(wx.Panel):
bpp = 3 # bytes per pixel
bytes = array.array('B', [0] * width*height*bpp)
bpp = 3 # bytes per pixel
bytes = array.array('B', [0] * width*height*bpp)
- def offset(x, y):
- # return the offset into the bytes array for the start of
- # the x,y pixel
- return y*width*bpp + x*bpp
-
for y in xrange(height):
for x in xrange(width):
for y in xrange(height):
for x in xrange(width):
+ offset = y*width*bpp + x*bpp
r,g,b = self.GetRGB(x, y, bpp)
r,g,b = self.GetRGB(x, y, bpp)
- bytes[offset(x, y) + 0] = r
- bytes[offset(x, y) + 1] = g
- bytes[offset(x, y) + 2] = b
- ##print (x, y), offset(x, y), (r, g, b)
+ bytes[offset + 0] = r
+ bytes[offset + 1] = g
+ bytes[offset + 2] = b
self.rgbBmp = wx.BitmapFromBuffer(width, height, bytes)
self.rgbBmp = wx.BitmapFromBuffer(width, height, bytes)
@@
-56,19
+51,14
@@
class TestPanel(wx.Panel):
bpp = 4 # bytes per pixel
bytes = array.array('B', [0] * width*height*bpp)
bpp = 4 # bytes per pixel
bytes = array.array('B', [0] * width*height*bpp)
- def offset(x, y):
- # return the offset into the bytes array for the start of
- # the x,y pixel
- return y*width*bpp + x*bpp
-
for y in xrange(height):
for x in xrange(width):
for y in xrange(height):
for x in xrange(width):
+ offset = y*width*bpp + x*bpp
r,g,b,a = self.GetRGB(x, y, bpp)
r,g,b,a = self.GetRGB(x, y, bpp)
- bytes[offset(x, y) + 0] = r
- bytes[offset(x, y) + 1] = g
- bytes[offset(x, y) + 2] = b
- bytes[offset(x, y) + 3] = a
- ##print (x, y), offset(x, y), (r, g, b, a)
+ bytes[offset + 0] = r
+ bytes[offset + 1] = g
+ bytes[offset + 2] = b
+ bytes[offset + 3] = a
self.rgbaBmp = wx.BitmapFromBufferRGBA(width, height, bytes)
self.rgbaBmp = wx.BitmapFromBufferRGBA(width, height, bytes)
@@
-77,20
+67,15
@@
class TestPanel(wx.Panel):
# Make a bitmap using an array of RGB bytes plus a separate
# buffer for the alpha channel
bpp = 3 # bytes per pixel
# Make a bitmap using an array of RGB bytes plus a separate
# buffer for the alpha channel
bpp = 3 # bytes per pixel
- bytes = array.array('B', [1,2,3] * width*height)#*bpp)
-
- def offset(x, y):
- # return the offset into the bytes array for the start of
- # the x,y pixel
- return y*width*bpp + x*bpp
+ bytes = array.array('B', [0] * width*height*bpp)
for y in xrange(height):
for x in xrange(width):
for y in xrange(height):
for x in xrange(width):
+ offset = y*width*bpp + x*bpp
r,g,b = self.GetRGB(x, y, bpp)
r,g,b = self.GetRGB(x, y, bpp)
- bytes[offset(x, y) + 0] = r
- bytes[offset(x, y) + 1] = g
- bytes[offset(x, y) + 2] = b
- ##print (x, y), offset(x, y), (r, g, b)
+ bytes[offset + 0] = r
+ bytes[offset + 1] = g
+ bytes[offset + 2] = b
# just use an alpha buffer with a constant alpha value for all
# pixels for this example, it could just as easily have
# just use an alpha buffer with a constant alpha value for all
# pixels for this example, it could just as easily have