Skip to content

Commit

Permalink
-avoid potentially premultiplying colors more than once in agg_render…
Browse files Browse the repository at this point in the history
…er::setup - closes mapnik#1515
  • Loading branch information
Dane Springmeyer authored and PetrDlouhy committed Aug 21, 2013
1 parent 6d56f65 commit 6ba1c37
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/agg/agg_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand All @@ -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();
}

Expand Down

0 comments on commit 6ba1c37

Please sign in to comment.