示例#1
0
def test_YUVAPixmaps_FromExternalPixmaps():
    info = skia.YUVAInfo()
    pixmaps = [
        skia.Pixmap(),
        skia.Pixmap(),
        skia.Pixmap(),
        skia.Pixmap(),
    ]
    assert isinstance(
        skia.YUVAPixmaps.FromExternalPixmaps(info, pixmaps),
        skia.YUVAPixmaps)
    def getFrameAt(self, index):
        if self.fImages.get(index, False) is not False:
            return self.fImages[index]

        rb = self.imageInfo.minRowBytes()
        bmap = skia.Bitmap()
        bmap.allocPixels(self.imageInfo)

        reqFrame = self.fInfos[index].fRequiredFrame

        opts = skia.Codec.Options()
        opts.fFrameIndex = index
        opts.fPriorFrame = reqFrame if reqFrame != index - 1 else skia.Codec.kNoFrame

        if reqFrame != skia.Codec.kNoFrame:
            pmap = skia.Pixmap()
            if self.fImages.get(reqFrame, False):
                self.fImages.get(reqFrame).readPixels(pmap, 0, 0)
            bmap.writePixels(pmap)

        result = self.decGif.getPixels(self.imageInfo, bmap.getPixels(),
                                       bmap.rowBytes(), opts)

        if result == skia.Codec.Result.kSuccess:
            self.fImages[index] = skia.Image.MakeFromBitmap(bmap)
            return self.fImages[index]
        return False
示例#3
0
def test_Pixmap_addr64(pixmap):
    info = skia.ImageInfo.Make(
        100, 100, skia.ColorType.kRGBA_F16_ColorType,
        skia.AlphaType.kPremul_AlphaType)
    data = bytearray(info.computeMinByteSize())
    pixmap = skia.Pixmap(info, data, info.minRowBytes())
    assert isinstance(pixmap.addr64(), memoryview)
示例#4
0
	def getFrameAt(self,index):
		if self.fImages.get(index,False) != False:
			return self.fImages[index]

		rb = self.imageInfo.minRowBytes()
        #Carefull with the lifetime of this
		bmap = skia.Bitmap()
		bmap.allocPixels(self.imageInfo)

		opts = skia.Codec.Options()
		opts.fFrameIndex = index
		reqFrame = self.fInfos[index].fRequiredFrame

		if reqFrame != skia.Codec.kNoFrame:
			#copy image data from required frame
			pmap = skia.Pixmap()
			self.fImages[reqFrame].readPixels(pmap,0,0)
			bmap.installPixels(pmap)
			
		
		result = self.decGif.getPixels(self.imageInfo,bmap.getPixels(),bmap.rowBytes(),opts)

		if result == skia.Codec.Result.kSuccess:
			self.fImages[index] = skia.Image.MakeFromBitmap(bmap)
			return self.fImages[index]
		return False
示例#5
0
def test_Bitmap_readPixels(bitmap, info, use_pixmap):
    dst = bytearray(info.computeMinByteSize())
    if use_pixmap:
        pixmap = skia.Pixmap(info, dst, info.minRowBytes())
        assert isinstance(bitmap.readPixels(pixmap), bool)
    else:
        assert isinstance(bitmap.readPixels(info, dst, info.minRowBytes()),
                          bool)
示例#6
0
def test_Image_readPixels2(context, use_context, image):
    info = image.imageInfo().makeWH(100, 100)
    dstRowBytes = info.minRowBytes()
    dstPixels = bytearray(info.computeByteSize(dstRowBytes))
    dst = skia.Pixmap(info, dstPixels, dstRowBytes)
    if use_context:
        assert isinstance(image.readPixels(context, dst, 0, 0), bool)
    else:
        assert isinstance(image.readPixels(dst, 0, 0), bool)
示例#7
0
def test_Pixmap_readPixels(pixmap, use_pixmap):
    info = pixmap.info().makeWH(100, 100)
    dstRowBytes = info.minRowBytes()
    dstPixels = bytearray(info.computeByteSize(dstRowBytes))
    if use_pixmap:
        dst = skia.Pixmap(info, dstPixels, dstRowBytes)
        assert isinstance(pixmap.readPixels(dst, 0, 0), bool)
    else:
        assert isinstance(
            pixmap.readPixels(info, dstPixels, dstRowBytes, 0, 0), bool)
示例#8
0
def test_Codec_getPixels(codec, use_pixmap):
    info = skia.ImageInfo.MakeN32Premul(128, 128)
    data = bytearray(info.computeMinByteSize())
    rowBytes = info.minRowBytes()
    if use_pixmap:
        pixmap = skia.Pixmap(info, data, rowBytes)
        assert isinstance(codec.getPixels(pixmap), skia.Codec.Result)
    else:
        assert isinstance(codec.getPixels(info, data, rowBytes),
                          skia.Codec.Result)
示例#9
0
def test_Surface_peekPixels(surface):
    assert isinstance(surface.peekPixels(skia.Pixmap()), bool)
示例#10
0
    (skia.IRect(100, 100),),
])
def test_Surface_makeImageSnapshot(surface, args):
    assert isinstance(surface.makeImageSnapshot(*args), skia.Image)


def test_Surface_draw(surface):
    surface.draw(surface.getCanvas(), 0, 0, None)


def test_Surface_peekPixels(surface):
    assert isinstance(surface.peekPixels(skia.Pixmap()), bool)


@pytest.mark.parametrize('args', [
    (skia.Pixmap(), 0, 0),
    (
        skia.ImageInfo.MakeN32Premul(320, 240),
        bytearray(240 * 320 * 4),
        320 * 4,
    ),
    (
        skia.ImageInfo.MakeN32Premul(320, 240),
        np.zeros((240, 320, 4), dtype=np.uint8),
    ),
    (skia.Bitmap(), 0, 0),
])
def test_Surface_readPixels(surface, args):
    assert isinstance(surface.readPixels(*args), bool)

示例#11
0
def test_Canvas_peekPixels(canvas):
    assert isinstance(canvas.peekPixels(skia.Pixmap()), bool)
示例#12
0
def pixmap():
    info = skia.ImageInfo.MakeN32Premul(100, 100)
    data = bytearray(info.computeMinByteSize())
    yield skia.Pixmap(info, data, info.minRowBytes())
示例#13
0
def test_Image_peekPixels(image):
    pixmap = skia.Pixmap()
    assert isinstance(image.peekPixels(pixmap), bool)
示例#14
0
def test_Bitmap_peekPixels(bitmap):
    assert isinstance(bitmap.peekPixels(skia.Pixmap()), bool)
示例#15
0
def test_Pixmap_addr8():
    info = skia.ImageInfo.MakeA8(100, 100)
    data = bytearray(info.computeMinByteSize())
    pixmap = skia.Pixmap(info, data, info.minRowBytes())
    assert isinstance(pixmap.addr8(), memoryview)
示例#16
0
def test_Pixmap_init(args):
    assert isinstance(skia.Pixmap(*args), skia.Pixmap)
示例#17
0
def test_Image_peekPixels(image):
    assert isinstance(image.peekPixels(skia.Pixmap()), bool)
示例#18
0
def pixmap():
    info = skia.ImageInfo().MakeN32Premul(100, 100)
    row_bytes = info.minRowBytes()
    pixels = bytearray(info.computeByteSize(row_bytes))
    return skia.Pixmap(info, pixels, row_bytes)
示例#19
0
def test_Pixmap_scalePixels(pixmap):
    info = pixmap.info().makeWH(100, 100)
    dstRowBytes = info.minRowBytes()
    dstPixels = bytearray(info.computeByteSize(dstRowBytes))
    dst = skia.Pixmap(info, dstPixels, dstRowBytes)
    assert isinstance(pixmap.scalePixels(dst), bool)
示例#20
0
def test_Image_scalePixels(image):
    info = image.imageInfo().makeWH(100, 100)
    dstRowBytes = info.minRowBytes()
    dstPixels = bytearray(info.computeByteSize(dstRowBytes))
    dst = skia.Pixmap(info, dstPixels, dstRowBytes)
    assert isinstance(image.scalePixels(dst), bool)
示例#21
0
def test_Pixmap_extractSubset(pixmap):
    assert isinstance(
        pixmap.extractSubset(skia.Pixmap(), skia.IRect.MakeWH(100, 100)), bool)