]> git.cworth.org Git - apitrace/blobdiff - scripts/retracediff.py
retracediff: Dump mismtached float images to stdout.
[apitrace] / scripts / retracediff.py
index c0518df2fbcd67f786ebdd71ac3c664bbc26e346..18a97f63c158ee5473ca9b329198bc7397985c85 100755 (executable)
@@ -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)