Пример #1
0
def test_pixbuf_from_array():
    im = cv2.imread(TEST_IMAGE_PATH)

    pixbuf = pixbuf_from_array(im)

    assert isinstance(pixbuf, GdkPixbuf.Pixbuf)

    assert im.tobytes() == pixbuf.get_pixels()
Пример #2
0
    def set_background_image(self, image: Optional[np.ndarray]) -> None:
        if image is None:
            self._background_ro.props.pixbuf = None
            return

        self._background_ro.props.pixbuf = pixbuf_from_array(image)

        self._render.props.canvas_size = image.shape[1::-1]
        self._render.viewport_extents = Rect2(position=(0, 0), size=image.shape[1::-1])