Add support to generate_test_mask_image for mismatched sizes,

add masks for legend renderer tests
This commit is contained in:
Nyall Dawson 2015-07-10 18:09:28 +10:00
parent 405688ea49
commit 368eaa258b
6 changed files with 7 additions and 6 deletions

View File

@ -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:

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

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