Skip to content

Commit

Permalink
before caching marker premultiply only those image formats that might…
Browse files Browse the repository at this point in the history
… potentially need to be premultiplied
  • Loading branch information
Dane Springmeyer committed Oct 4, 2012
1 parent 357e711 commit a4b5549
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/jpeg_reader.cpp
Expand Up @@ -50,7 +50,7 @@ class JpegReader : public image_reader, boost::noncopyable
~JpegReader();
unsigned width() const;
unsigned height() const;
inline bool premultiplied_alpha() const { return true ;}
inline bool premultiplied_alpha() const { return true; }
void read(unsigned x,unsigned y,image_data_32& image);
private:
void init();
Expand Down
11 changes: 6 additions & 5 deletions src/marker_cache.cpp
Expand Up @@ -198,11 +198,12 @@ boost::optional<marker_ptr> marker_cache::find(std::string const& uri,
BOOST_ASSERT(width > 0 && height > 0);
mapnik::image_ptr image(boost::make_shared<mapnik::image_data_32>(width,height));
reader->read(0,0,*image);
// ensure images are premultiplied
// TODO - don't need to multiply jpegs
agg::rendering_buffer buffer(image->getBytes(),image->width(),image->height(),image->width() * 4);
agg::pixfmt_rgba32 pixf(buffer);
pixf.premultiply();
if (!reader->premultiplied_alpha())
{
agg::rendering_buffer buffer(image->getBytes(),image->width(),image->height(),image->width() * 4);
agg::pixfmt_rgba32 pixf(buffer);
pixf.premultiply();
}
marker_ptr mark(boost::make_shared<marker>(image));
result.reset(mark);
if (update_cache)
Expand Down

0 comments on commit a4b5549

Please sign in to comment.