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

Quantize colors from a RGB(A) buffer. #68

Open
srijan-paul opened this issue Mar 30, 2024 · 4 comments
Open

Quantize colors from a RGB(A) buffer. #68

srijan-paul opened this issue Mar 30, 2024 · 4 comments

Comments

@srijan-paul
Copy link

(I'd be happy to contribute this feature if PRs are welcome).

Currently, we have to set the global/local color table manually.
However, when writing an RGBA buffer, it would be much easier if the library could quantize the colors into a 256-bit space.

GIFLIB, for example, has a GifQuantizeColors function that is very handy for creating frame-local color tables.

@dloebl
Copy link
Owner

dloebl commented Mar 31, 2024

Hi @srijan-paul. Great feature request! We are working on a cgif_rgb API in #37 that will support color quantization and dithering. It's still work-in-progress, but feel free to give it a try. You can find an example here: cgif_rgb_example.c. The current limitations are listed in the pull request.
We hope to be able to release this feature in the coming months.

@srijan-paul
Copy link
Author

Amazing, thank you for working on this.
Is the quantization implementation currently usable? I'm using cgif for an app I'm working on.
For now, I think I'll manually quantize the RGBA buffer if rgb API isn't ready yet.

@dloebl
Copy link
Owner

dloebl commented Apr 10, 2024

@srijan-paul The RGB API isn't released so it's still unstable. It should still work though the file size of the resulting GIFs won't be ideal: As of now, it creates one local color palette per frame. In the future we are planning to support quantizing to a single global color palette as well.

@srijan-paul
Copy link
Author

Got it.
I implemented my own quantizer for now, and am happy with the results.
Looking forward to more options :^)

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