integrated test case from #759

This commit is contained in:
Alberto Valverde 2011-05-12 18:09:03 +00:00
parent aeb1b7f963
commit 0e0c4aa82c
3 changed files with 40 additions and 0 deletions

View file

@ -63,6 +63,8 @@ void agg_renderer<T>::process(raster_symbolizer const& sym,
if (sym.get_scaling() == "bilinear8"){
scale_image_bilinear8<image_data_32>(target,raster->data_, err_offs_x, err_offs_y);
} else if (sym.get_scaling() == "bilinear_old") {
scale_image_bilinear_old<image_data_32>(target,raster->data_, err_offs_x, err_offs_y);
} else {
scaling_method_e scaling_method = get_scaling_method_by_name(sym.get_scaling());
scale_image_agg<image_data_32>(target,raster->data_, (scaling_method_e)scaling_method, scale_factor, err_offs_x, err_offs_y, sym.calculate_filter_factor());

BIN
tests/data/raster/white-alpha.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

View file

@ -94,3 +94,41 @@ def test_load_save_map():
assert 'RasterSymbolizer' in out_map
assert 'RasterColorizer' in out_map
assert 'stop' in out_map
def test_raster_with_alpha_blends_correctly_with_background():
WIDTH = 500
HEIGHT = 500
map = mapnik2.Map(WIDTH, HEIGHT)
WHITE = mapnik2.Color(255, 255, 255)
map.background = WHITE
style = mapnik2.Style()
rule = mapnik2.Rule()
symbolizer = mapnik2.RasterSymbolizer()
#XXX: This fixes it, see http://trac.mapnik.org/ticket/759#comment:3
# (and remove comment when this test passes)
#symbolizer.scaling="bilinear_old"
rule.symbols.append(symbolizer)
style.rules.append(rule)
map.append_style('raster_style', style)
map_layer = mapnik2.Layer('test_layer')
filepath = '../data/raster/white-alpha.png'
map_layer.datasource = mapnik2.Gdal(file=filepath)
map_layer.styles.append('raster_style')
map.layers.append(map_layer)
map.zoom_all()
mim = mapnik2.Image(WIDTH, HEIGHT)
mapnik2.render(map, mim)
save_data('test_raster_with_alpha_blends_correctly_with_background.png',
mim.tostring('png'))
imdata = mim.tostring()
# All white is expected
assert contains_word('\xff\xff\xff\xff', imdata)