Skip to content

Drop useless remapping of palette in gdImageNeuQuant() #918

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Dec 28, 2024

This code has been taken from pngnq.c[1] where it makes much sense, because the image is always output in PNG format. For our case, it does not make sense, since the output format may be different, and we already have respective remapping code in gd_png.c. Furthermore, this remapping may destroy the advantageous topological properties of the NeuQuant color quantization[2].

And actually, that code wouldn't work as it's supposed to, since the alpha channel cannot be 255 for libgd, and as such the remapping just inverses the order of the palette entries.

[1] https://sourceforge.net/projects/pngnq/
[2] https://web.archive.org/web/20070416070905/http://members.ozemail.com.au/~dekker/NeuQuant.pdf, section 6

This code has been taken from pngnq.c[1] where it makes much sense,
because the image is always output in PNG format.  For our case, it
does not make sense, since the output format may be different, and we
already have respective remapping code in gd_png.c.  Furthermore, this
remapping may destroy the advantageous topological properties of the
NeuQuant color quantization[2].

And actually, that code wouldn't work as it's supposed to, since the
alpha channel cannot be 255 for libgd, and as such the remapping just
inverses the order of the palette entries.

[1] <https://sourceforge.net/projects/pngnq/>
[2] <https://web.archive.org/web/20070416070905/http://members.ozemail.com.au/~dekker/NeuQuant.pdf>, section 6
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

Successfully merging this pull request may close these issues.

1 participant