]> git.cworth.org Git - apitrace/commitdiff
image: Yet another fix for the PFM dumping.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 16 Sep 2013 13:18:05 +0000 (14:18 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 16 Sep 2013 13:18:05 +0000 (14:18 +0100)
image/image.hpp
image/image_pnm.cpp

index 857e0621c1386e5d9a72eb9dba6e9ff467a35322..8e6b51fdf6758cfa0eb7fab43d34caa52d6d2412 100644 (file)
@@ -49,6 +49,7 @@ public:
     unsigned height;
     unsigned channels;
     ChannelType channelType;
+    unsigned bytesPerChannel;
     unsigned bytesPerPixel;
 
     // Flipped vertically or not
@@ -62,7 +63,8 @@ public:
         height(h),
         channels(c),
         channelType(t),
-        bytesPerPixel(channels * (t == TYPE_FLOAT ? 4 : 1)),
+        bytesPerChannel(t == TYPE_FLOAT ? 4 : 1),
+        bytesPerPixel(channels * bytesPerChannel),
         flipped(f),
         pixels(new unsigned char[h*w*bytesPerPixel])
     {}
index 79db1c6e78249e945b9b5a6c2f45fb89b3dc7788..0473ac64025150269beac1001718518ba9867d86 100644 (file)
@@ -99,7 +99,7 @@ Image::writePNM(std::ostream &os, const char *comment) const
          * Need to add/remove channels, one pixel at a time.
          */
 
-        unsigned char *tmp = new unsigned char[width*bytesPerPixel];
+        unsigned char *tmp = new unsigned char[width*outChannels*bytesPerChannel];
 
         if (channelType == TYPE_UNORM8) {
             /*
@@ -174,7 +174,7 @@ Image::writePNM(std::ostream &os, const char *comment) const
                         *dst++ = 0;
                     }
                 }
-                os.write((const char *)tmp, width*bytesPerPixel);
+                os.write((const char *)tmp, width*outChannels*bytesPerChannel);
             }
         }