Ok, investigated a little, I can confirm it does not work. When the image is fully transparent (nothing has been drawn) the CustomPaletteBuilder class, responsible for the 24 -> 8 bits color reduction comes up with a palette with just one item.
This is correct, there is just one color, but unfortunately the png encoders do not work properly in this case, and they generate a grayscale png instead, which is not transparent.
The following patch workaround this by adding a fake second element to the generated palette so that it always at least two items. Seems to work, not sure if I'm curing the cause or just the symptom there, but at least the generated png is valid and transparent:
Index: C:/progetti/geoserver/src/trunkClean/geoserver/wms/src/main/java/org/vfny/geoserver/wms/responses/palette/CustomPaletteBuilder.java
===================================================================
--- C:/progetti/geoserver/src/trunkClean/geoserver/wms/src/main/java/org/vfny/geoserver/wms/responses/palette/CustomPaletteBuilder.java (revision 8807)
+++ C:/progetti/geoserver/src/trunkClean/geoserver/wms/src/main/java/org/vfny/geoserver/wms/responses/palette/CustomPaletteBuilder.java (working copy)
@@ -426,6 +426,10 @@
if (transparency == Transparency.BITMASK) {
size++; }
+ + + if(size < 2)
+ size = 2;
final byte[] red = new byte[size];
final byte[] green = new byte[size];
Simone, can you review it? To reproduce the issue with a GeoServer in standard configuration you can use the following wms request (got it from the map preview and adapted):
http:&SRS=EPSG%3A26713&HEIGHT=256&FORMAT=image%2Fpng8&TILED=true&TILESORIGIN=589213.0189195721%2C4913481.836583115
&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap
&EXCEPTIONS=application%2Fvnd.ogc.se_inimage
&BBOX=599351.9645728546,4913481.836583115,601886.7009861752,4916016.572996436&transparent=true
I'm cc'ing Simone, the developer that created png8 color quantization. Simone, I'm curious about how we create the palette for png8. Is it a set of 256 colors where each one has its own transparency, or do we specify a transparent pixel?