-
Notifications
You must be signed in to change notification settings - Fork 132
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
Treating alpha like RGB #45
Comments
It looks like that's a special case for alpha = 0? I have been able to workaround that by forcing alpha to be at least 1, but would still prefer a cleaner solution! |
This is fundamentally impossible in libimagequant. It intentionally uses premultiplied alpha color space throughout the codebase. In this colorspace RGB and A are correlated, and are not independent channels. Separating alpha would make PNG8 much lower quality and inefficient. Instead of reducing 16mln combinations, it'd have to work with 4 billion combinations, and visually invisible alpha combinations would take precious palette entries away from the visible RGB colors. I suggest that you use two separate PNG files: RGB PNG8 for color, and a separate grayscale PNG for the alpha-but-not-really-alpha channel. |
@kornelski I see. Thanks. I'll look into those options. |
Hello!
I am using libimagequant to optimize PNGs to be used as textures in a game, and it mostly works very well - thanks!
But there are some textures where the alpha channel means something else entirely, and I see that in regions that would be transparent if alpha was interpreted as transparency, the RGB values are very wrong. That makes sense if those pixels were actually transparent of course, but not in this case.
Is there a way to make the library treat alpha as just another colour channel?
Thanks!
The text was updated successfully, but these errors were encountered: