mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-23 00:02:38 -05:00
Add support to generate_test_mask_image for mismatched sizes,
add masks for legend renderer tests
This commit is contained in:
parent
405688ea49
commit
368eaa258b
@ -72,11 +72,14 @@ def updateMask(control_image_path, rendered_image_path, mask_image_path):
|
||||
if not rendered_image:
|
||||
error('Could not read rendered image {}'.format(rendered_image_path))
|
||||
if not rendered_image.width() == control_image.width() or not rendered_image.height() == control_image.height():
|
||||
error('Size mismatch - control image is {}x{}, rendered image is {}x{}'.format(control_image.width(),
|
||||
print ('Size mismatch - control image is {}x{}, rendered image is {}x{}'.format(control_image.width(),
|
||||
control_image.height(),
|
||||
rendered_image.width(),
|
||||
rendered_image.height()))
|
||||
|
||||
max_width = min( rendered_image.width(), control_image.width() )
|
||||
max_height = min( rendered_image.height(), control_image.height() )
|
||||
|
||||
#read current mask, if it exist
|
||||
mask_image = imageFromPath( mask_image_path )
|
||||
if mask_image.isNull():
|
||||
@ -86,15 +89,13 @@ def updateMask(control_image_path, rendered_image_path, mask_image_path):
|
||||
|
||||
#loop through pixels in rendered image and compare
|
||||
mismatch_count = 0
|
||||
width = control_image.width()
|
||||
height = control_image.height()
|
||||
linebytes = width * 4
|
||||
for y in xrange( height ):
|
||||
linebytes = max_width * 4
|
||||
for y in xrange( max_height ):
|
||||
control_scanline = control_image.constScanLine( y ).asstring(linebytes)
|
||||
rendered_scanline = rendered_image.constScanLine( y ).asstring(linebytes)
|
||||
mask_scanline = mask_image.scanLine( y ).asstring(linebytes)
|
||||
|
||||
for x in xrange( width ):
|
||||
for x in xrange( max_width ):
|
||||
currentTolerance = qRed( struct.unpack('I', mask_scanline[ x*4:x*4+4 ] )[0] )
|
||||
|
||||
if currentTolerance == 255:
|
||||
|
BIN
tests/testdata/control_images/expected_legend_basic/expected_legend_basic_mask.png
vendored
Normal file
BIN
tests/testdata/control_images/expected_legend_basic/expected_legend_basic_mask.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
tests/testdata/control_images/expected_legend_big_marker/expected_legend_big_marker_mask.png
vendored
Normal file
BIN
tests/testdata/control_images/expected_legend_big_marker/expected_legend_big_marker_mask.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
BIN
tests/testdata/control_images/expected_legend_filter_by_map/expected_legend_filter_by_map_mask.png
vendored
Normal file
BIN
tests/testdata/control_images/expected_legend_filter_by_map/expected_legend_filter_by_map_mask.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 18 KiB |
Loading…
x
Reference in New Issue
Block a user