]> git.cworth.org Git - apitrace/commitdiff
image: Non-standard PNM format variant for 4-float images.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 16 Sep 2013 13:57:30 +0000 (14:57 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 16 Sep 2013 13:57:30 +0000 (14:57 +0100)
image/image_pnm.cpp
scripts/retracediff.py

index 0473ac64025150269beac1001718518ba9867d86..58e2cd359058f8ffc9f014fb3db4a697b83447f1 100644 (file)
@@ -62,9 +62,13 @@ Image::writePNM(std::ostream &os, const char *comment) const
         if (channels == 1) {
             identifier = "Pf";
             outChannels = 1;
-        } else {
+        } else if (channels <= 3) {
             identifier = "PF";
-            outChannels = 3;
+            outChannels = 4;
+        } else {
+            // Non-standard extension for 4 floats
+            identifier = "PX";
+            outChannels = 4;
         }
         break;
     default:
@@ -235,6 +239,10 @@ readPNMHeader(const char *buffer, size_t bufferSize, PNMInfo &info)
         info.channels = 3;
         info.channelType = TYPE_FLOAT;
         break;
+    case 'X':
+        info.channels = 4;
+        info.channelType = TYPE_FLOAT;
+        break;
     default:
         return NULL;
     }
index c0518df2fbcd67f786ebdd71ac3c664bbc26e346..71e9f06473d38f38dd2e9f8259ad1b1104b10bef 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 = ''