Skip to content
Browse files

-avoid potentially premultiplying colors more than once in agg_render…

…er::setup - closes #1515
  • Loading branch information...
1 parent 9b053f4 commit 357e7113123fa164c2d095cee05c89d90bc03574 @springmeyer springmeyer committed Oct 4, 2012
Showing with 15 additions and 7 deletions.
  1. +15 −7 src/agg/agg_renderer.cpp
View
22 src/agg/agg_renderer.cpp
@@ -106,11 +106,24 @@ template <typename T>
void agg_renderer<T>::setup(Map const &m)
{
boost::optional<color> const& bg = m.background();
- if (bg) pixmap_.set_background(*bg);
+ if (bg)
+ {
+ if (bg->alpha() < 255)
+ {
+ mapnik::color bg_color = *bg;
+ bg_color.premultiply();
+ pixmap_.set_background(bg_color);
+ }
+ else
+ {
+ pixmap_.set_background(*bg);
+ }
+ }
boost::optional<std::string> const& image_filename = m.background_image();
if (image_filename)
{
+ // NOTE: marker_cache returns premultiplied image, if needed
boost::optional<mapnik::marker_ptr> bg_marker = mapnik::marker_cache::instance().find(*image_filename,true);
if (bg_marker && (*bg_marker)->is_bitmap())
{
@@ -126,17 +139,12 @@ void agg_renderer<T>::setup(Map const &m)
{
for (unsigned y=0;y<y_steps;++y)
{
- composite(pixmap_.data(),*bg_image, src_over, 1.0f, x*w, y*h, true);
+ composite(pixmap_.data(),*bg_image, src_over, 1.0f, x*w, y*h, false);
}
}
}
}
}
-
- agg::rendering_buffer buf(pixmap_.raw_data(),width_,height_, width_ * 4);
- agg::pixfmt_rgba32 pixf(buf);
- pixf.premultiply();
-
MAPNIK_LOG_DEBUG(agg_renderer) << "agg_renderer: Scale=" << m.scale();
}

0 comments on commit 357e711

Please sign in to comment.
Something went wrong with that request. Please try again.