Skip to content

Commit

Permalink
backport image-filters/alpha fix to 2.3.x branch - refs #1313
Browse files Browse the repository at this point in the history
  • Loading branch information
Dane Springmeyer committed Jun 19, 2014
1 parent 4b90c96 commit 7c7da1a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions include/mapnik/image_filter.hpp
Expand Up @@ -394,8 +394,12 @@ void apply_convolution_3x3(Src const& src_view, Dst & dst_view, Filter const& fi
template <typename Src, typename Filter>
void apply_filter(Src & src, Filter const& filter)
{
double_buffer<Src> tb(src);
apply_convolution_3x3(tb.src_view, tb.dst_view, filter);
{
src.demultiply();
double_buffer<Src> tb(src);
apply_convolution_3x3(tb.src_view, tb.dst_view, filter);
} // ensure ~double_buffer() is called before premultiplying
src.premultiply();
}

template <typename Src>
Expand Down
8 changes: 4 additions & 4 deletions tests/python_tests/image_filters_test.py
Expand Up @@ -49,18 +49,18 @@ def test_style_level_image_filter():
mapnik.render(m, im)
actual = '/tmp/mapnik-style-image-filter-' + filename + '.png'
expected = 'images/style-image-filter/' + filename + '.png'
im.save(actual)
im.save(actual,"png32")
if not os.path.exists(expected):
print 'generating expected test image: %s' % expected
im.save(expected)
im.save(expected,'png32')
expected_im = mapnik.Image.open(expected)
# compare them
if im.tostring() == expected_im.tostring():
if im.tostring('png32') == expected_im.tostring('png32'):
successes.append(name)
else:
fails.append('failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected))
fail_im = side_by_side_image(expected_im, im)
fail_im.save('/tmp/mapnik-style-image-filter-' + filename + '.fail.png')
fail_im.save('/tmp/mapnik-style-image-filter-' + filename + '.fail.png','png32')
eq_(len(fails), 0, '\n'+'\n'.join(fails))

if __name__ == "__main__":
Expand Down
Binary file modified tests/python_tests/images/style-image-filter/blur.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/python_tests/images/style-image-filter/edge-detect.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/python_tests/images/style-image-filter/emboss.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/python_tests/images/style-image-filter/sharpen.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/python_tests/images/style-image-filter/sobel.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7c7da1a

Please sign in to comment.