diff -urN apitrace-6.1-orig/image/image_png.cpp apitrace-6.1/image/image_png.cpp
--- apitrace-6.1-orig/image/image_png.cpp	2015-01-09 08:46:25 +0900
+++ apitrace-6.1/image/image_png.cpp	2015-03-26 16:38:21 +0900
@@ -151,6 +151,8 @@
 Image *
 readPNG(std::istream &is)
 {
+    assert(channelType == TYPE_UNORM8);
+
     png_structp png_ptr;
     png_infop info_ptr;
     png_infop end_info;
diff -urN apitrace-6.1-orig/image/image_pnm.cpp apitrace-6.1/image/image_pnm.cpp
--- apitrace-6.1-orig/image/image_pnm.cpp	2015-01-09 08:46:25 +0900
+++ apitrace-6.1/image/image_pnm.cpp	2015-03-26 16:39:12 +0900
@@ -46,6 +46,8 @@
 void
 Image::writePNM(std::ostream &os, const char *comment) const
 {
+    assert(channelType == TYPE_UNORM8);
+
     const char *identifier;
     unsigned outChannels;
 
diff -urN apitrace-6.1-orig/retrace/d3dretrace.hpp apitrace-6.1/retrace/d3dretrace.hpp
--- apitrace-6.1-orig/retrace/d3dretrace.hpp	2015-01-09 08:46:25 +0900
+++ apitrace-6.1/retrace/d3dretrace.hpp	2015-03-26 16:22:12 +0900
@@ -51,7 +51,7 @@
     {}
 
     image::Image *
-    getSnapshot(void) {
+    getSnapshot(bool raw) {
         if (!pLastDevice) {
             return NULL;
         }
diff -urN apitrace-6.1-orig/retrace/glretrace_main.cpp apitrace-6.1/retrace/glretrace_main.cpp
--- apitrace-6.1-orig/retrace/glretrace_main.cpp	2015-01-09 08:46:25 +0900
+++ apitrace-6.1/retrace/glretrace_main.cpp	2015-03-26 16:22:12 +0900
@@ -601,11 +601,11 @@
 class GLDumper : public retrace::Dumper {
 public:
     image::Image *
-    getSnapshot(void) {
+    getSnapshot(bool raw) {
         if (!glretrace::getCurrentContext()) {
             return NULL;
         }
-        return glstate::getDrawBufferImage();
+        return glstate::getDrawBufferImage(raw);
     }
 
     bool
diff -urN apitrace-6.1-orig/retrace/glstate.hpp apitrace-6.1/retrace/glstate.hpp
--- apitrace-6.1-orig/retrace/glstate.hpp	2015-01-09 08:46:25 +0900
+++ apitrace-6.1/retrace/glstate.hpp	2015-03-26 16:22:12 +0900
@@ -63,7 +63,7 @@
 getDrawableBounds(GLint *width, GLint *height);
 
 image::Image *
-getDrawBufferImage(void);
+getDrawBufferImage(bool raw);
 
 
 } /* namespace glstate */
diff -urN apitrace-6.1-orig/retrace/glstate_images.cpp apitrace-6.1/retrace/glstate_images.cpp
--- apitrace-6.1-orig/retrace/glstate_images.cpp	2015-01-09 08:46:25 +0900
+++ apitrace-6.1/retrace/glstate_images.cpp	2015-03-26 16:50:08 +0900
@@ -70,6 +70,7 @@
     GLint depth;
     GLint samples;
     GLint internalFormat;
+    GLint type;  // of the red or depth component
 
     inline
     ImageDesc() :
@@ -96,6 +97,168 @@
 };
 
 
+static const InternalFormatDesc
+internalFormatDescs[] = {
+
+    {1,	GL_RED,	GL_NONE},
+    {2,	GL_RG,	GL_NONE},
+    {3,	GL_RGB,	GL_NONE},
+    {4,	GL_RGBA,	GL_NONE},
+
+    {GL_RED,	GL_RED,	GL_NONE},
+    {GL_GREEN,	GL_GREEN,	GL_NONE},
+    {GL_BLUE,	GL_BLUE,	GL_NONE},
+    {GL_ALPHA,	GL_ALPHA,	GL_NONE},
+    {GL_RG,	GL_RG,	GL_NONE},
+    {GL_RGB,	GL_RGB,	GL_NONE},
+    {GL_BGR,	GL_RGB,	GL_NONE},
+    {GL_RGBA,	GL_RGBA,	GL_NONE},
+    {GL_BGRA,	GL_RGBA,	GL_NONE},
+    {GL_LUMINANCE,	GL_LUMINANCE,	GL_NONE},
+    {GL_LUMINANCE_ALPHA,	GL_LUMINANCE_ALPHA,	GL_NONE},
+    {GL_INTENSITY,	GL_INTENSITY,	GL_NONE},
+ 
+    {GL_R8,	GL_RED,	GL_UNSIGNED_BYTE},
+    {GL_R16,	GL_RED,	GL_UNSIGNED_SHORT},
+    {GL_RG8,	GL_RG,	GL_UNSIGNED_BYTE},
+    {GL_RG16,	GL_RG,	GL_UNSIGNED_SHORT},
+    {GL_R3_G3_B2,	GL_RGB,	GL_UNSIGNED_BYTE_3_3_2},
+    {GL_RGB4,	GL_RGB,	GL_UNSIGNED_SHORT_4_4_4_4},
+    {GL_RGB5,	GL_RGB,	GL_UNSIGNED_SHORT_5_5_5_1},
+    {GL_RGB8,	GL_RGB,	GL_UNSIGNED_BYTE},
+    {GL_RGB10,	GL_RGBA,	GL_UNSIGNED_INT_10_10_10_2},
+    {GL_RGB16,	GL_RGB,	GL_UNSIGNED_SHORT},
+    {GL_RGBA4,	GL_RGBA,	GL_UNSIGNED_SHORT_4_4_4_4},
+    {GL_RGBA8,	GL_RGBA,	GL_UNSIGNED_BYTE},
+    {GL_RGBA16,	GL_RGBA,	GL_UNSIGNED_SHORT},
+    {GL_RGB10_A2,	GL_RGBA,	GL_UNSIGNED_INT_10_10_10_2},
+    {GL_LUMINANCE8,	GL_LUMINANCE,	GL_UNSIGNED_BYTE},
+    {GL_LUMINANCE16,	GL_LUMINANCE,	GL_UNSIGNED_SHORT},
+    {GL_ALPHA8,	GL_ALPHA,	GL_UNSIGNED_BYTE},
+    {GL_ALPHA16,	GL_ALPHA,	GL_UNSIGNED_SHORT},
+    {GL_LUMINANCE8_ALPHA8,	GL_LUMINANCE_ALPHA,	GL_UNSIGNED_BYTE},
+    {GL_LUMINANCE16_ALPHA16,	GL_LUMINANCE_ALPHA,	GL_UNSIGNED_SHORT},
+    {GL_INTENSITY8,	GL_INTENSITY,	GL_UNSIGNED_BYTE},
+    {GL_INTENSITY16,	GL_INTENSITY,	GL_UNSIGNED_SHORT},
+    
+    {GL_RED_INTEGER,	GL_RED_INTEGER,	GL_NONE},
+    {GL_GREEN_INTEGER,	GL_GREEN_INTEGER,	GL_NONE},
+    {GL_BLUE_INTEGER,	GL_BLUE_INTEGER,	GL_NONE},
+    {GL_ALPHA_INTEGER,	GL_ALPHA_INTEGER,	GL_NONE},
+    {GL_RG_INTEGER,	GL_RG_INTEGER,	GL_NONE},
+    {GL_RGB_INTEGER,	GL_RGB_INTEGER,	GL_NONE},
+    {GL_BGR_INTEGER,	GL_RGB_INTEGER,	GL_NONE},
+    {GL_RGBA_INTEGER,	GL_RGBA_INTEGER,	GL_NONE},
+    {GL_BGRA_INTEGER,	GL_RGBA_INTEGER,	GL_NONE},
+    {GL_LUMINANCE_INTEGER_EXT,	GL_LUMINANCE_INTEGER_EXT,	GL_NONE},
+    {GL_LUMINANCE_ALPHA_INTEGER_EXT,	GL_LUMINANCE_ALPHA_INTEGER_EXT,	GL_NONE},
+ 
+    {GL_R8I,	GL_RED_INTEGER,	GL_BYTE},
+    {GL_R8UI,	GL_RED_INTEGER,	GL_UNSIGNED_BYTE},
+    {GL_R16I,	GL_RED_INTEGER,	GL_SHORT},
+    {GL_R16UI,	GL_RED_INTEGER,	GL_UNSIGNED_SHORT},
+    {GL_R32I,	GL_RED_INTEGER,	GL_INT},
+    {GL_R32UI,	GL_RED_INTEGER,	GL_UNSIGNED_INT},
+    {GL_RG8I,	GL_RG_INTEGER,	GL_BYTE},
+    {GL_RG8UI,	GL_RG_INTEGER,	GL_UNSIGNED_BYTE},
+    {GL_RG16I,	GL_RG_INTEGER,	GL_SHORT},
+    {GL_RG16UI,	GL_RG_INTEGER,	GL_UNSIGNED_SHORT},
+    {GL_RG32I,	GL_RG_INTEGER,	GL_INT},
+    {GL_RG32UI,	GL_RG_INTEGER,	GL_UNSIGNED_INT},
+    {GL_RGB8I,	GL_RGB_INTEGER,	GL_BYTE},
+    {GL_RGB8UI,	GL_RGB_INTEGER,	GL_UNSIGNED_BYTE},
+    {GL_RGB16I,	GL_RGB_INTEGER,	GL_SHORT},
+    {GL_RGB16UI,	GL_RGB_INTEGER,	GL_UNSIGNED_SHORT},
+    {GL_RGB32I,	GL_RGB_INTEGER,	GL_INT},
+    {GL_RGB32UI,	GL_RGB_INTEGER,	GL_UNSIGNED_INT},
+    {GL_RGBA8I,	GL_RGBA_INTEGER,	GL_BYTE},
+    {GL_RGBA8UI,	GL_RGBA_INTEGER,	GL_UNSIGNED_BYTE},
+    {GL_RGBA16I,	GL_RGBA_INTEGER,	GL_SHORT},
+    {GL_RGBA16UI,	GL_RGBA_INTEGER,	GL_UNSIGNED_SHORT},
+    {GL_RGBA32I,	GL_RGBA_INTEGER,	GL_INT},
+    {GL_RGBA32UI,	GL_RGBA_INTEGER,	GL_UNSIGNED_INT},
+    {GL_RGB10_A2UI,	GL_RGBA_INTEGER,	GL_UNSIGNED_INT_10_10_10_2},
+    {GL_LUMINANCE8I_EXT,	GL_LUMINANCE_INTEGER_EXT,	GL_BYTE},
+    {GL_LUMINANCE8UI_EXT,	GL_LUMINANCE_INTEGER_EXT,	GL_UNSIGNED_BYTE},
+    {GL_LUMINANCE16I_EXT,	GL_LUMINANCE_INTEGER_EXT,	GL_SHORT},
+    {GL_LUMINANCE16UI_EXT,	GL_LUMINANCE_INTEGER_EXT,	GL_UNSIGNED_SHORT},
+    {GL_LUMINANCE32I_EXT,	GL_LUMINANCE_INTEGER_EXT,	GL_INT},
+    {GL_LUMINANCE32UI_EXT,	GL_LUMINANCE_INTEGER_EXT,	GL_UNSIGNED_INT},
+    {GL_ALPHA8I_EXT,	GL_ALPHA_INTEGER_EXT,	GL_BYTE},
+    {GL_ALPHA8UI_EXT,	GL_ALPHA_INTEGER_EXT,	GL_UNSIGNED_BYTE},
+    {GL_ALPHA16I_EXT,	GL_ALPHA_INTEGER_EXT,	GL_SHORT},
+    {GL_ALPHA16UI_EXT,	GL_ALPHA_INTEGER_EXT,	GL_UNSIGNED_SHORT},
+    {GL_ALPHA32I_EXT,	GL_ALPHA_INTEGER_EXT,	GL_INT},
+    {GL_ALPHA32UI_EXT,	GL_ALPHA_INTEGER_EXT,	GL_UNSIGNED_INT},
+    {GL_LUMINANCE_ALPHA8I_EXT,	GL_LUMINANCE_ALPHA_INTEGER_EXT,	GL_BYTE},
+    {GL_LUMINANCE_ALPHA8UI_EXT,	GL_LUMINANCE_ALPHA_INTEGER_EXT,	GL_UNSIGNED_BYTE},
+    {GL_LUMINANCE_ALPHA16I_EXT,	GL_LUMINANCE_ALPHA_INTEGER_EXT,	GL_SHORT},
+    {GL_LUMINANCE_ALPHA16UI_EXT,	GL_LUMINANCE_ALPHA_INTEGER_EXT,	GL_UNSIGNED_SHORT},
+    {GL_LUMINANCE_ALPHA32I_EXT,	GL_LUMINANCE_ALPHA_INTEGER_EXT,	GL_INT},
+    {GL_LUMINANCE_ALPHA32UI_EXT,	GL_LUMINANCE_ALPHA_INTEGER_EXT,	GL_UNSIGNED_INT},
+    {GL_INTENSITY8I_EXT,	GL_RED_INTEGER,	GL_BYTE},
+    {GL_INTENSITY8UI_EXT,	GL_RED_INTEGER,	GL_UNSIGNED_BYTE},
+    {GL_INTENSITY16I_EXT,	GL_RED_INTEGER,	GL_SHORT},
+    {GL_INTENSITY16UI_EXT,	GL_RED_INTEGER,	GL_UNSIGNED_SHORT},
+    {GL_INTENSITY32I_EXT,	GL_RED_INTEGER,	GL_INT},
+    {GL_INTENSITY32UI_EXT,	GL_RED_INTEGER,	GL_UNSIGNED_INT},
+
+    {GL_R16F,	GL_RED,	GL_HALF_FLOAT},
+    {GL_R32F,	GL_RED,	GL_FLOAT},
+    {GL_RG16F,	GL_RG,	GL_HALF_FLOAT},
+    {GL_RG32F,	GL_RG,	GL_FLOAT},
+    {GL_RGB16F,	GL_RGB,	GL_HALF_FLOAT},
+    {GL_RGB32F,	GL_RGB,	GL_FLOAT},
+    {GL_RGBA16F,	GL_RGBA,	GL_HALF_FLOAT},
+    {GL_RGBA32F,	GL_RGBA,	GL_FLOAT},
+    {GL_R11F_G11F_B10F,	GL_RGB,	GL_UNSIGNED_INT_10F_11F_11F_REV},
+    {GL_RGB9_E5,	GL_RGB,	GL_UNSIGNED_INT_5_9_9_9_REV},
+    {GL_LUMINANCE16F_ARB,	GL_LUMINANCE,	GL_HALF_FLOAT},
+    {GL_LUMINANCE32F_ARB,	GL_LUMINANCE,	GL_FLOAT},
+    {GL_ALPHA16F_ARB,	GL_ALPHA,	GL_HALF_FLOAT},
+    {GL_ALPHA32F_ARB,	GL_ALPHA,	GL_FLOAT},
+    {GL_LUMINANCE_ALPHA16F_ARB,	GL_LUMINANCE_ALPHA,	GL_HALF_FLOAT},
+    {GL_LUMINANCE_ALPHA16F_ARB,	GL_LUMINANCE_ALPHA,	GL_FLOAT},
+    {GL_INTENSITY16F_ARB,	GL_INTENSITY,	GL_HALF_FLOAT},
+    {GL_INTENSITY32F_ARB,	GL_INTENSITY,	GL_FLOAT},
+    
+    {GL_DEPTH_COMPONENT,	GL_DEPTH_COMPONENT,	GL_NONE},
+    {GL_DEPTH_COMPONENT16,	GL_DEPTH_COMPONENT,	GL_UNSIGNED_SHORT},
+    {GL_DEPTH_COMPONENT24,	GL_DEPTH_COMPONENT,	GL_UNSIGNED_INT},
+    {GL_DEPTH_COMPONENT32,	GL_DEPTH_COMPONENT,	GL_UNSIGNED_INT},
+    {GL_DEPTH_COMPONENT32F,	GL_DEPTH_COMPONENT,	GL_FLOAT},
+    {GL_DEPTH_COMPONENT32F_NV,	GL_DEPTH_COMPONENT,	GL_FLOAT},
+    {GL_DEPTH_STENCIL,	        GL_DEPTH_COMPONENT,	GL_NONE},
+    {GL_DEPTH24_STENCIL8,	GL_DEPTH_COMPONENT,	GL_UNSIGNED_INT_24_8},
+    {GL_DEPTH32F_STENCIL8,	GL_DEPTH_COMPONENT,	GL_FLOAT_32_UNSIGNED_INT_24_8_REV},
+    {GL_DEPTH32F_STENCIL8_NV,	GL_DEPTH_COMPONENT,	GL_FLOAT_32_UNSIGNED_INT_24_8_REV},
+};
+
+
+static GLenum
+getFormat(GLenum internalFormat)
+{
+    for (unsigned i = 0; i < sizeof internalFormatDescs / sizeof internalFormatDescs[0]; ++i) {
+        if (internalFormatDescs[i].internalFormat == internalFormat) {
+            return internalFormatDescs[i].format;
+        }
+    }
+    return GL_RGBA;
+}
+
+
+static GLenum
+getType(GLenum internalFormat)
+{
+    for (unsigned i = 0; i < sizeof internalFormatDescs / sizeof internalFormatDescs[0]; ++i) {
+        if (internalFormatDescs[i].internalFormat == internalFormat) {
+            return internalFormatDescs[i].type;
+        }
+    }
+    return GL_NONE;
+}
+
+
 /**
  * OpenGL ES does not support glGetTexLevelParameteriv, but it is possible to
  * probe whether a texture has a given size by crafting a dummy glTexSubImage()
@@ -192,6 +355,7 @@
 
     // XXX: mere guess
     desc.internalFormat = GL_RGBA;
+    desc.type = GL_UNSIGNED_BYTE;
 
     GLint maxSize = 0;
     switch (target) {
@@ -285,6 +449,12 @@
 
     glGetTexLevelParameteriv(target, level, GL_TEXTURE_INTERNAL_FORMAT, &desc.internalFormat);
 
+    if (getFormat(desc.internalFormat) == GL_DEPTH_COMPONENT) {
+        glGetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH_TYPE, &desc.type);
+    } else {
+        glGetTexLevelParameteriv(target, level, GL_TEXTURE_RED_TYPE, &desc.type);
+    }
+
     desc.width = 0;
     glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &desc.width);
 
@@ -844,7 +1014,7 @@
 
 
 image::Image *
-getDrawBufferImage() {
+getDrawBufferImage(bool raw) {
     Context context;
 
     GLenum framebuffer_binding;
@@ -897,11 +1067,8 @@
         desc.depth = 1;
     }
 
-    GLenum format = GL_RGB;
+    GLenum format = raw ? getFormat(desc.internalFormat) : context.ES ? GL_RGBA : GL_RGB;
     GLenum type = GL_UNSIGNED_BYTE;
-    if (context.ES) {
-        format = GL_RGBA;
-    }
 
     GLint channels = _gl_format_channels(format);
     if (channels > 4) {
@@ -910,6 +1077,57 @@
 
     image::ChannelType channelType = image::TYPE_UNORM8;
 
+    if (raw) {
+        type = getType(desc.internalFormat);
+        if (type == GL_NONE) {
+            type = desc.type;
+        }
+        switch (type) {
+        case GL_UNSIGNED_BYTE:
+        case GL_BYTE:
+            break;
+        case GL_UNSIGNED_BYTE_3_3_2:
+        case GL_UNSIGNED_BYTE_2_3_3_REV:
+            channels = 1;
+            break;
+        case GL_UNSIGNED_SHORT:
+        case GL_SHORT:
+        case GL_HALF_FLOAT:
+            channels *= 2;
+            break;
+        case GL_UNSIGNED_SHORT_5_6_5:
+        case GL_UNSIGNED_SHORT_5_6_5_REV:
+        case GL_UNSIGNED_SHORT_4_4_4_4:
+        case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+        case GL_UNSIGNED_SHORT_5_5_5_1:
+        case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+            channels = 2;
+            break;
+        case GL_UNSIGNED_INT:
+        case GL_INT:
+        case GL_FLOAT:
+            channelType = image::TYPE_FLOAT;
+            break;
+        case GL_UNSIGNED_INT_8_8_8_8:
+        case GL_UNSIGNED_INT_8_8_8_8_REV:
+        case GL_UNSIGNED_INT_10_10_10_2:
+        case GL_UNSIGNED_INT_2_10_10_10_REV:
+        case GL_UNSIGNED_INT_24_8:
+        case GL_UNSIGNED_INT_10F_11F_11F_REV:
+        case GL_UNSIGNED_INT_5_9_9_9_REV:
+            channels = 4;
+            break;
+        case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+            channelType = image::TYPE_FLOAT;
+            channels = 2;
+            break;
+        default:
+            std::cerr << "warning: unknown type " << enumToString(type) << ", using UNSIGNED_BYTE\n";
+            type = GL_UNSIGNED_BYTE;
+            break;
+        }
+    }
+
     if (format == GL_DEPTH_COMPONENT) {
         type = GL_FLOAT;
         channels = 1;
diff -urN apitrace-6.1-orig/retrace/retrace.hpp apitrace-6.1/retrace/retrace.hpp
--- apitrace-6.1-orig/retrace/retrace.hpp	2015-01-09 08:46:25 +0900
+++ apitrace-6.1/retrace/retrace.hpp	2015-03-26 16:22:12 +0900
@@ -202,7 +202,7 @@
 {
 public:
     virtual image::Image *
-    getSnapshot(void) {
+    getSnapshot(bool raw) {
         return NULL;
     }
 
diff -urN apitrace-6.1-orig/retrace/retrace_main.cpp apitrace-6.1/retrace/retrace_main.cpp
--- apitrace-6.1-orig/retrace/retrace_main.cpp	2015-01-09 08:46:25 +0900
+++ apitrace-6.1/retrace/retrace_main.cpp	2015-03-26 16:23:49 +0900
@@ -51,6 +51,7 @@
 static enum {
     PNM_FMT,
     RAW_RGB,
+    RAW_DATA,
     RAW_MD5
 } snapshotFormat = PNM_FMT;
 
@@ -112,7 +113,7 @@
 
     assert(snapshotPrefix);
 
-    image::Image *src = dumper->getSnapshot();
+    image::Image *src = dumper->getSnapshot(snapshotFormat == RAW_DATA);
     if (!src) {
         std::cerr << call_no << ": warning: failed to get snapshot\n";
         return;
@@ -131,6 +132,7 @@
                 src->writePNM(std::cout, comment);
                 break;
             case RAW_RGB:
+            case RAW_DATA:
                 src->writeRAW(std::cout);
                 break;
             case RAW_MD5:
@@ -589,7 +591,7 @@
         "      --driver=DRIVER     force driver type (`hw`, `sw`, `ref`, `null`, or driver module name)\n"
         "      --sb                use a single buffer visual\n"
         "  -s, --snapshot-prefix=PREFIX    take snapshots; `-` for PNM stdout output\n"
-        "      --snapshot-format=FMT       use (PNM, RGB, or MD5; default is PNM) when writing to stdout output\n"
+        "      --snapshot-format=FMT       use (PNM, RGB, RAW, or MD5; default is PNM) when writing to stdout output\n"
         "  -S, --snapshot=CALLSET  calls to snapshot (default is every frame)\n"
         "      --snapshot-interval=N    specify a frame interval when generating snaphots (default is 0)\n"
         "  -v, --verbose           increase output verbosity\n"
@@ -741,6 +743,8 @@
         case SNAPSHOT_FORMAT_OPT:
             if (strcmp(optarg, "RGB") == 0)
                 snapshotFormat = RAW_RGB;
+            else if (strcmp(optarg, "RAW") == 0)
+                snapshotFormat = RAW_DATA;
             else if (strcmp(optarg, "MD5") == 0)
                 snapshotFormat = RAW_MD5;
             else
