add test for alpha blending during bilinear scaling - refs #997
This commit is contained in:
parent
19631e50e2
commit
e1fa732f90
4 changed files with 48 additions and 0 deletions
19
tests/data/good_maps/raster-alpha.xml
Normal file
19
tests/data/good_maps/raster-alpha.xml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE Map[]>
|
||||||
|
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" background-color="red">
|
||||||
|
|
||||||
|
<Style name="white" filter-mode="first">
|
||||||
|
<Rule>
|
||||||
|
<RasterSymbolizer opacity="1" scaling="bilinear" />
|
||||||
|
</Rule>
|
||||||
|
</Style>
|
||||||
|
<Layer name="white"
|
||||||
|
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
|
||||||
|
<StyleName>white</StyleName>
|
||||||
|
<Datasource>
|
||||||
|
<Parameter name="file">../raster/white-alpha.tiff</Parameter>
|
||||||
|
<Parameter name="type">gdal</Parameter>
|
||||||
|
</Datasource>
|
||||||
|
</Layer>
|
||||||
|
|
||||||
|
</Map>
|
BIN
tests/data/raster/white-alpha.tiff
Normal file
BIN
tests/data/raster/white-alpha.tiff
Normal file
Binary file not shown.
BIN
tests/python_tests/images/support/raster-alpha.png
Normal file
BIN
tests/python_tests/images/support/raster-alpha.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
29
tests/python_tests/raster_alpha_test.py
Normal file
29
tests/python_tests/raster_alpha_test.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from nose.tools import *
|
||||||
|
from utilities import execution_path
|
||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
|
import os, mapnik
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
# All of the paths used are relative, if we run the tests
|
||||||
|
# from another directory we need to chdir()
|
||||||
|
os.chdir(execution_path('.'))
|
||||||
|
|
||||||
|
def test_map_alpha_compare():
|
||||||
|
m = mapnik.Map(600,400)
|
||||||
|
mapnik.load_map(m,'../data/good_maps/raster-alpha.xml')
|
||||||
|
m.zoom_all()
|
||||||
|
actual = '/tmp/mapnik-raster-alpha.png'
|
||||||
|
expected = 'images/support/raster-alpha.png'
|
||||||
|
im = mapnik.Image(m.width,m.height)
|
||||||
|
mapnik.render(m,im)
|
||||||
|
im.save(actual)
|
||||||
|
expected_im = mapnik.Image.open(expected)
|
||||||
|
eq_(im.tostring(),expected_im.tostring(), 'failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
|
[eval(run)() for run in dir() if 'test_' in run]
|
Loading…
Reference in a new issue