X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=scripts%2Fretracediff.py;h=18a97f63c158ee5473ca9b329198bc7397985c85;hb=a0708b02018902497da4df6c9be05cd053374afc;hp=c0518df2fbcd67f786ebdd71ac3c664bbc26e346;hpb=127a7281d3cc0c8233e128a2c3e8601276939b9a;p=apitrace diff --git a/scripts/retracediff.py b/scripts/retracediff.py index c0518df..18a97f6 100755 --- a/scripts/retracediff.py +++ b/scripts/retracediff.py @@ -148,6 +148,10 @@ def read_pnm(stream): channels = 3 bytesPerChannel = 4 mode = 'RGB' + elif magic == 'PX': + channels = 4 + bytesPerChannel = 4 + mode = 'RGB' else: raise Exception('Unsupported magic `%s`' % magic) comment = '' @@ -175,6 +179,17 @@ def read_pnm(stream): return image, comment +def dumpNumpyImage(output, pixels): + height, width, channels = pixels.shape + for y in range(height): + output.write(' ') + for x in range(width): + for c in range(channels): + output.write('%0.9g,' % pixels[y, x, c]) + output.write(' ') + output.write('\n') + + def parse_env(optparser, entries): '''Translate a list of NAME=VALUE entries into an environment dictionary.''' @@ -324,6 +339,10 @@ def main(): highligher.normal() if mismatch: + if numpyImages: + dumpNumpyImage(output, refImage) + output.write("->\n") + dumpNumpyImage(output, srcImage) if options.diff_prefix and not numpyImages: prefix = os.path.join(options.diff_prefix, '%010u' % callNo) prefix_dir = os.path.dirname(prefix)