GNOME Bugzilla – Bug 170825
Incorrect indexing of mainly white B&W image using optimal palette.
Last modified: 2005-03-20 19:09:25 UTC
Convert the grayscale (actually B&W) png attached below to indexed using "optimal palette", and it comes out all black. Problem first described in bug #170801, which is about a different issue that has been resolved.
Created attachment 38913 [details] png file illustrating problem. image generated by Xuân Baldauf, copied from attachment in bug #170801
Yeah, that's not good. Note that if you convert the image to RGB first, things are fine. The grey->indexed code is really quite different from the RGB->indexed code, and it's the latter that gets the most love. I'm wondering how evil it would be to do an implicit grey->RGB conversion before quantizing and throw away the crusty grey->indexed code paths.
Looks like an int overflow in counting the white pixels.
Created attachment 38939 [details] [review] The fix v1 I don't know (or more accurately don't remember) where the greyscale histogram values get boosted enough to cause an int overflow, but this makes it a non-issue.
Oh yeah, patch is against my tree (somewhere around gimp 2.0) but it hopefully still applies to everything.
n.b. I will no longer respond to bug reports originating from California National Primate Research Center, as I do not believe in supporting their work in any way. Someone else can field such reports.
This is the sort of comment that generates flamewars. Although it would be easy for me to answer, I am not going to, and I hope that nobody else will feel compelled to either, or that if you must, you can do it by sending private email to Adam and/or me.
Patch applies cleanly and seems to fix the problem, committed to both branches. 2005-03-20 Bill Skaggs <weskaggs@primate.ucdavis.edu> * app/core/gimpimage-convert.c: applied patch from Adam Moss converning gray->indexed conversion, fixes bug #170825. Resolving as FIXED although comment #4 is a bit worrying. Thanks for the patch.