Ejemplo n.º 1
0
    def test_sanity(self):
        PillowQtTestCase.setUp(self)
        for mode in ('RGB', 'RGBA', 'L', 'P', '1'):
            src = hopper(mode)
            data = ImageQt.toqimage(src)

            self.assertIsInstance(data, QImage)
            self.assertFalse(data.isNull())

            # reload directly from the qimage
            rt = ImageQt.fromqimage(data)
            if mode in ('L', 'P', '1'):
                self.assert_image_equal(rt, src.convert('RGB'))
            else:
                self.assert_image_equal(rt, src)

            if mode == '1':
                # BW appears to not save correctly on QT4 and QT5
                # kicks out errors on console:
                # libpng warning: Invalid color type/bit depth combination in IHDR
                # libpng error: Invalid IHDR data
                continue
            
            # Test saving the file
            tempfile = self.tempfile('temp_{}.png'.format(mode))
            data.save(tempfile)

            # Check that it actually worked. 
            reloaded = Image.open(tempfile)
            # Gray images appear to come back in palette mode.
            # They're roughly equivalent
            if QT_VERSION == 4 and mode == 'L':
                src = src.convert('P')
            self.assert_image_equal(reloaded, src)
Ejemplo n.º 2
0
    def test_segfault(self):
        PillowQtTestCase.setUp(self)

        app = QApplication([])
        ex = Example()
        assert (app)  # Silence warning
        assert (ex)  # Silence warning
Ejemplo n.º 3
0
    def test_segfault(self):
        PillowQtTestCase.setUp(self)

        app = QApplication([])
        ex = Example()
        assert(app)  # Silence warning
        assert(ex)   # Silence warning
Ejemplo n.º 4
0
    def test_sanity(self):
        PillowQtTestCase.setUp(self)
        for mode in ('RGB', 'RGBA', 'L', 'P', '1'):
            src = hopper(mode)
            data = ImageQt.toqimage(src)

            self.assertIsInstance(data, QImage)
            self.assertFalse(data.isNull())

            # reload directly from the qimage
            rt = ImageQt.fromqimage(data)
            if mode in ('L', 'P', '1'):
                self.assert_image_equal(rt, src.convert('RGB'))
            else:
                self.assert_image_equal(rt, src)

            if mode == '1':
                # BW appears to not save correctly on QT4 and QT5
                # kicks out errors on console:
                # libpng warning: Invalid color type/bit depth combination in IHDR
                # libpng error: Invalid IHDR data
                continue

            # Test saving the file
            tempfile = self.tempfile('temp_{}.png'.format(mode))
            data.save(tempfile)

            # Check that it actually worked.
            reloaded = Image.open(tempfile)
            # Gray images appear to come back in palette mode.
            # They're roughly equivalent
            if QT_VERSION == 4 and mode == 'L':
                src = src.convert('P')
            self.assert_image_equal(reloaded, src)
Ejemplo n.º 5
0
    def test_sanity(self):
        PillowQtTestCase.setUp(self)
        for mode in ('1', 'RGB', 'RGBA', 'L', 'P'):
            data = ImageQt.toqimage(hopper(mode))

            self.assertIsInstance(data, QImage)
            self.assertFalse(data.isNull())

            # Test saving the file
            tempfile = self.tempfile('temp_{0}.png'.format(mode))
            data.save(tempfile)
Ejemplo n.º 6
0
    def test_sanity(self):
        PillowQtTestCase.setUp(self)

        for mode in ("1", "RGB", "RGBA", "L", "P"):
            data = ImageQt.toqpixmap(hopper(mode))

            self.assertTrue(isinstance(data, QPixmap))
            self.assertFalse(data.isNull())

            # Test saving the file
            tempfile = self.tempfile("temp_{0}.png".format(mode))
            data.save(tempfile)
Ejemplo n.º 7
0
 def roundtrip(self, expected):
     PillowQtTestCase.setUp(self)
     result = ImageQt.fromqpixmap(ImageQt.toqpixmap(expected))
     # Qt saves all pixmaps as rgb
     self.assert_image_equal(result, expected.convert('RGB'))
Ejemplo n.º 8
0
    def test_segfault(self):
        PillowQtTestCase.setUp(self)

        app = QApplication([])
        ex = Example()
Ejemplo n.º 9
0
    def test_segfault(self):
        PillowQtTestCase.setUp(self)

        app = QtGui.QApplication([])
        ex = Example()
Ejemplo n.º 10
0
 def roundtrip(self, expected):
     PillowQtTestCase.setUp(self)
     result = ImageQt.fromqpixmap(ImageQt.toqpixmap(expected))
     # Qt saves all pixmaps as rgb
     self.assert_image_equal(result, expected.convert('RGB'))