diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-01-28 16:28:17 -0200 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:53:50 -0300 |
commit | 279fb0242963caf5a03ea30d6cde5f10d3387f7b (patch) | |
tree | 10cd1c6fc4f95e98d6c4e8a17b10606647d91c69 /tests | |
parent | 9c7d055f3d6f7f93f66ed977ca480979b445fcb8 (diff) |
Fix bug 565 - "QImage missing *data constructors"
Fix bug 566 - "'PySide.QtGui.QImage' object has no attribute 'scanLine'"
The constructors now accepts any PyObject which implements the buffer protocol, as the
C++ and PyQt4 version the buffer must be alive during the life time of QImage because QImage
*does not* copy the image data.
scanLine() and bits() now return buffer objects pointing to the memory inside QImage.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/QtGui/qimage_test.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/QtGui/qimage_test.py b/tests/QtGui/qimage_test.py index d8aa545af..e9af2d71d 100644 --- a/tests/QtGui/qimage_test.py +++ b/tests/QtGui/qimage_test.py @@ -2,18 +2,30 @@ '''Test cases for QImage''' import unittest - -from PySide.QtGui import QImage - -from helper import UsesQApplication +from PySide.QtGui import * +from helper import * class QImageTest(UsesQApplication): '''Test case for calling setPixel with float as argument''' def testQImageStringBuffer(self): '''Test if the QImage signatures receiving string buffers exist.''' - img0 = QImage('', 100, 100, QImage.Format_ARGB32) - img1 = QImage('', 100, 100, 0, QImage.Format_ARGB32) + img0 = QImage(adjust_filename('sample.png', __file__)) + + print type(img0.bits()) + + # btw let's test the bits() method + img1 = QImage(img0.bits(), img0.width(), img0.height(), img0.format()) + self.assertEqual(img0, img1) + img2 = QImage(img0.bits(), img0.width(), img0.height(), img0.bytesPerLine(), img0.format()) + self.assertEqual(img0, img2) + + ## test scanLine method + data1 = img0.scanLine(0) + data2 = img1.scanLine(0) + self.assertEqual(data1, data2) + self.assertEquals(str(data1), img0.bits()[:img0.bytesPerLine()]) + self.assertEquals(str(data2), img0.bits()[:img0.bytesPerLine()]) if __name__ == '__main__': unittest.main() |