Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
woestler opened this issue May 30, 2022 · 1 comment
Open

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

woestler opened this issue May 30, 2022 · 1 comment

Comments

@woestler
Copy link

woestler commented May 30, 2022

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 woestler changed the title Cannot get background (255, 255, 255, 0) for Pillow image Unable to get background (255, 255, 255, 0) for Pillow image May 30, 2022
@HinTak
Copy link
Collaborator

HinTak commented Oct 29, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants