mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 09:40:07 +01:00
Small tweak and tests to allow using objects supporting only the old buffer interface to be used as buffer sources.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73872 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -174,6 +174,31 @@ class BitmapTests(wtc.WidgetTestCase):
|
||||
self.assertTrue(bmp.IsOk())
|
||||
|
||||
|
||||
def test_bitmapBufferFactory4(self):
|
||||
# The array.array object does not support the new buffer protocol,
|
||||
# (at least as of 2.7) so this test shows if we can support the old
|
||||
# one too.
|
||||
import array
|
||||
w = h = 10
|
||||
buf = array.array('B', [123] * (w*h*4))
|
||||
bmp = wx.Bitmap.FromBufferRGBA(w, h, buf)
|
||||
self.assertTrue(bmp.IsOk())
|
||||
|
||||
|
||||
def test_bitmapBufferFactory5(self):
|
||||
# The array.array object does not support the new buffer protocol,
|
||||
# (at least as of 2.7) so this test shows if we can support the old
|
||||
# one too.
|
||||
import array
|
||||
w = h = 10
|
||||
buf = array.array('B', [10, 20, 30] * (w*h))
|
||||
bmp = wx.Bitmap.FromBuffer(w, h, buf)
|
||||
self.assertTrue(bmp.IsOk())
|
||||
img = bmp.ConvertToImage()
|
||||
self.assertEqual( (img.GetRed(1,2), img.GetGreen(1,2), img.GetBlue(1,2)),
|
||||
(10,20,30) )
|
||||
|
||||
|
||||
def test_bitmapEmptyFactory1(self):
|
||||
w = h = 10
|
||||
bmp = wx.Bitmap.FromRGBA(w, h)
|
||||
|
||||
Reference in New Issue
Block a user