skia-python icon indicating copy to clipboard operation
skia-python copied to clipboard

Unable to get background (255, 255, 255, 0) for Pillow image

Open woestler opened this issue 3 years ago • 1 comments

Describe the bug Sir, I need to export a Pillow image with a background (255, 255, 255, 0), I use this code to initialize the Skia to try to set the background as (255, 255, 255, 0)

with self.surface as canvas:
      color = skia.Color(255, 255, 255, 0)
      canvas.clear(color)

After I draw a line on the surface and use this code to export a Pillow image

skia_image = self.surface.makeImageSnapshot()
alphaType=skia.AlphaType.kUnpremul_AlphaType)
res = skia_image.convert(colorType=skia.ColorType.kRGBA_8888_ColorType,
       alphaType=skia.AlphaType.kUnpremul_AlphaType)
return Image.fromarray(
        res
)

But the background is (0, 0, 0, 0) when get the pillow Image

Please help! it will be greatly appreciated. Thanks.

woestler avatar May 30 '22 03:05 woestler

Can you supply a more complete example? I can't deal with fragments of code.

HinTak avatar Oct 29 '23 20:10 HinTak