fixed color quantization in case of one color and transparency. #539

This commit is contained in:
Marcin Rudowski 2010-03-24 17:20:11 +00:00
parent 0f771249c6
commit a129611c20

View file

@ -283,8 +283,10 @@ namespace mapnik {
{
byte a = preprocessAlpha(c.a);
unsigned ind=0;
if (a < InsertPolicy::MIN_ALPHA || colors_ <= 1)
if (a < InsertPolicy::MIN_ALPHA || colors_ == 0)
return 0;
if (colors_ == 1)
return pal_remap_[has_holes_?1:0];
rgba_hash_table::iterator it = color_hashmap_.find(c);
if (it == color_hashmap_.end())
@ -489,7 +491,7 @@ namespace mapnik {
}
tries=0;
// ignore leaves and also nodes with small mean error and not excessive number of pixels
if (cur_node->reduce_cost / cur_node->pixel_count * std::log(double(cur_node->pixel_count)) > 20
if ((cur_node->reduce_cost / cur_node->pixel_count + 1) * std::log(double(cur_node->pixel_count)) > 15
&& cur_node->children_count > 0)
{
colors_--;