ASF Bugzilla – Full Text Bug Listing
|Summary:||[PATCH] PNG export: indexed option doesn't work|
|Product:||Batik - Now in Jira||Reporter:||x00000000|
|Component:||SVG Viewer||Assignee:||Batik Developer's Mailing list <batik-dev>|
exported testcase (indexed PNG with patch applied)
real world example (PNG; background is a <rect/> as in the testcase)
Description x00000000 2007-11-12 11:41:42 UTC
The indexed option of the PNG export in the SVG viewer has no effect. This is because KEY_INDEXED is set to 256 while it seems to be expected to be 8 if the number of palette entries should be 256 = 2^8. A value of 256 will be ignored in sources/org/apache/batik/ext/awt/image/codec/png/PNGTranscoderInternalCodecWriteAdapter.java I'll post a simple patch, but the indexed option is still quite unusable because it dithers a white background, even if only one other color is used.
Comment 3 x00000000 2007-11-12 11:45:02 UTC
Created attachment 21119 [details] exported testcase (indexed PNG with patch applied)
Comment 4 x00000000 2007-11-12 11:48:49 UTC
Created attachment 21120 [details] real world example (PNG; background is a <rect/> as in the testcase)
Comment 5 x00000000 2007-11-12 17:39:58 UTC
The dithering of the white background seems to be a Java bug: http://bugs.sun.com/view_bug.do?bug_id=4258700 I tried to turn dithering off in sources/org/apache/batik/ext/awt/image/rendered/IndexImage.java , but that has no effect because of another Java bug: http://bugs.sun.com/view_bug.do?bug_id=6357416 ~ $ java -version java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) 64-Bit Server VM (build 1.6.0-b105, mixed mode)
Comment 6 Helder Magalhães 2009-03-27 10:28:56 UTC
Created attachment 23423 [details] Patch v2 (In reply to comment #0) > This is because KEY_INDEXED is set to 256 while it seems to be expected > to be 8 if the number of palette entries should be 256 = 2^8. > A value of 256 will be ignored in > sources/org/apache/batik/ext/awt/image/codec/png/PNGTranscoderInternalCodecWriteAdapter.java I've (also) confirmed this in the source code (org.apache.batik.transcoder.image.PNGTranscoder.WriteAdapter#writeImage). The attachment is very similar to the current one, but additionally fixes a few indenting issues and removes some weird "By Jun Inamori" statements (which apparently shouldn't be there) and also some extraneous line breaks. > I'll post a simple patch, but the indexed option is still quite unusable > because it dithers a white background, even if only one other color is used. I haven't tried to improve this behavior...
Comment 7 Helder Magalhães 2009-03-30 03:19:31 UTC
(In reply to comment #6) > Created an attachment (id=23423) [details] > Patch v2 I haven't stated it but IMO it's ready for review. The changes are tiny and it should be quite safe to apply: it just limits to fix the bug. Nevertheless, it would also be interesting to center the dialog confirming the PNG indexed enabled (although not important in order for this to work). Changing platform to "All" and Batik version to 1.8, as I was able to reproduce in Windows XP SP3 with the trunk version.
Comment 8 Helder Magalhães 2010-02-06 11:18:19 UTC
I've committed a slightly modified version of the available patch in revision 907280. As stated in comment 6, the (somehow unexpected) dithering with a white background isn't addressed, it just fixes the indexed color option not being functional. FWIW, by taking a look at the documentation  and source code , it seems like that's the expected behavior... Also, given it's a user interface visible thing, I've added a small note in the CHANGES file. :-)  http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/transcoder/image/ImageTranscoder.html#KEY_FORCE_TRANSPARENT_WHITE  http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/image/PNGTranscoder.java?view=annotate#l98