diff --git a/include/mapnik/octree.hpp b/include/mapnik/octree.hpp index 67eed7637..40c2dc5d6 100644 --- a/include/mapnik/octree.hpp +++ b/include/mapnik/octree.hpp @@ -122,6 +122,11 @@ namespace mapnik { ~octree() { delete root_;} + unsigned colors() + { + return colors_; + } + void setMaxColors(unsigned max_colors) { max_colors_ = max_colors; diff --git a/include/mapnik/png_io.hpp b/include/mapnik/png_io.hpp index ae25aef7d..b78e15432 100644 --- a/include/mapnik/png_io.hpp +++ b/include/mapnik/png_io.hpp @@ -131,7 +131,7 @@ namespace mapnik { byte index = 0; int idx = -1; for(int j=levels-1; j>0; j--){ - if (U2ALPHA(val)>=limits[j]) { + if (U2ALPHA(val)>=limits[j] && trees[j].colors()>0) { index = idx = trees[j].quantize(c); break; } @@ -177,7 +177,7 @@ namespace mapnik { byte index = 0; int idx=-1; for(int j=levels-1; j>0; j--){ - if (U2ALPHA(val)>=limits[j]) { + if (U2ALPHA(val)>=limits[j] && trees[j].colors()>0) { index = idx = trees[j].quantize(c); break; }