diff --git a/include/mapnik/png_io.hpp b/include/mapnik/png_io.hpp index 1e8c5e595..9db04dcd9 100644 --- a/include/mapnik/png_io.hpp +++ b/include/mapnik/png_io.hpp @@ -109,18 +109,19 @@ namespace mapnik { } template - void reduce_8 (T const& in, ImageData8 & out, octree trees[], unsigned limits[], std::vector &alpha) + void reduce_8 (T const& in, ImageData8 & out, octree trees[], unsigned limits[], std::vector & alpha) { unsigned width = in.width(); unsigned height = in.height(); - unsigned alphaCount[alpha.size()]; + //unsigned alphaCount[alpha.size()]; + std::vector alphaCount(alpha.size()); for(unsigned i=0; i - void reduce_4 (T const& in, ImageData8 & out, octree trees[], unsigned limits[], std::vector &alpha) + void reduce_4 (T const& in, ImageData8 & out, octree trees[], unsigned limits[], std::vector & alpha) { unsigned width = in.width(); unsigned height = in.height(); - unsigned alphaCount[alpha.size()]; + //unsigned alphaCount[alpha.size()]; + std::vector alphaCount(alpha.size()); for(unsigned i=0; i - void reduce_1(T const&, ImageData8 & out, octree trees[], unsigned limits[], std::vector &alpha) + void reduce_1(T const&, ImageData8 & out, octree trees[], unsigned limits[], std::vector & alpha) { out.set(0); // only one color!!! } @@ -249,15 +251,16 @@ namespace mapnik { // make transparent lowest indexes, so tRNS is small if (alpha.size()>0) { - png_byte trans[alpha.size()]; - unsigned alphaSize=0;//truncate to nonopaque values - for(unsigned i=0; i0) - png_set_tRNS(png_ptr, info_ptr, (png_bytep)trans, alphaSize, NULL); + std::vector trans(alpha.size()); + unsigned alphaSize=0;//truncate to nonopaque values + for(unsigned i=0; i < alpha.size(); i++) + { + trans[i]=alpha[i]; + if (alpha[i]<255) + alphaSize = i+1; + } + if (alphaSize>0) + png_set_tRNS(png_ptr, info_ptr, (png_bytep)&trans[0], alphaSize, 0); } png_write_info(png_ptr, info_ptr); @@ -389,8 +392,8 @@ namespace mapnik { //transparency values per palette index std::vector alphaTable; //alphaTable.resize(palette.size());//allow semitransparency also in almost opaque range - alphaTable.resize(palette.size()-cols[TRANSPARENCY_LEVELS-1]); - + alphaTable.resize(palette.size() - cols[TRANSPARENCY_LEVELS-1]); + if (palette.size() > 16 ) { // >16 && <=256 colors -> write 8-bit color depth