Beispiel #1
0
 def test_restride(self):
     #restride of planar is not supported:
     img = ImageWrapper(0,
                        0,
                        1,
                        1, ["0" * 10, "0" * 10, "0" * 10, "0" * 10],
                        "YUV420P",
                        24,
                        10,
                        3,
                        planes=ImageWrapper.PLANAR_4)
     img.set_planes(ImageWrapper.PLANAR_3)
     img.clone_pixel_data()
     assert img.may_restride() is False
     img = ImageWrapper(0,
                        0,
                        1,
                        1,
                        "0" * 4,
                        "BGRA",
                        24,
                        4,
                        4,
                        planes=ImageWrapper.PACKED)
     assert img.may_restride() is False
     img = ImageWrapper(0,
                        0,
                        1,
                        1,
                        "0" * 10,
                        "BGRA",
                        24,
                        10,
                        4,
                        planes=ImageWrapper.PACKED)
     assert img.may_restride() is True
     #restride bigger:
     img.restride(20)
     #change more attributes:
     img.set_timestamp(img.get_timestamp() + 1)
     img.set_pixel_format("RGBA")
     img.set_palette(())
     img.set_pixels("1" * 10)
     assert img.allocate_buffer(0, 1) == 0
     assert img.get_palette() == ()
     assert img.is_thread_safe()
     assert img.get_gpu_buffer() is None
     img.set_rowstride(20)