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

Getting non premultiplied pixel data #850

Open
vincaslt opened this issue Jun 29, 2024 · 0 comments
Open

Getting non premultiplied pixel data #850

vincaslt opened this issue Jun 29, 2024 · 0 comments

Comments

@vincaslt
Copy link

It seems like this canvas is using Skia's premultiplied surface. I have an issue where if I try to get data from transparent canvas with globalAlpha=0.5 it actually multiplies the RGB values. if I set rgb(50, 50, 50) the pixel value would contain r=25, g=25, b=25, a=128 (in decimal). This resulted in my colors seeming darker when I got canvas data with canvas.data(). I wonder if there's a build in way to get non pre-multiplied pixel data.

My current way is this:

const imageData = ctx.getImageData(
          0,
          0,
          canvasSize.width,
          canvasSize.height
        );

        const buffer = Buffer.from(imageData.data);
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

1 participant