diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index bf3ab7d8ba..4d29d5fb90 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -520,25 +520,37 @@ void GSTextureOGL::SavePNG(const string& fn, const void* image, uint32 pitch) { } else { png::image img(m_size.x, m_size.y); png::image img_opaque(m_size.x, m_size.y); + png::image img_alpha(m_size.x, m_size.y); uint8* data = (uint8*)image; for(int h = 0; h < m_size.y; h++, data += pitch) { for (int w = 0; w < m_size.x; w++) { - png::rgba_pixel pa(data[4*w+0], data[4*w+1], data[4*w+2], data[4*w+3]); - img.set_pixel(w, h, pa); +#if !defined(ENABLE_OGL_PNG_OPAQUE) && !defined(ENABLE_OGL_PNG_ALPHA) + png::rgba_pixel p(data[4*w+0], data[4*w+1], data[4*w+2], data[4*w+3]); + img.set_pixel(w, h, p); +#endif #ifdef ENABLE_OGL_PNG_OPAQUE - png::rgb_pixel p(data[4*w+0], data[4*w+1], data[4*w+2]); - img_opaque.set_pixel(w, h, p); + png::rgb_pixel po(data[4*w+0], data[4*w+1], data[4*w+2]); + img_opaque.set_pixel(w, h, po); +#endif +#ifdef ENABLE_OGL_PNG_ALPHA + png::gray_pixel pa(data[4*w+3]); + img_alpha.set_pixel(w, h, pa); #endif } } - std::string rename = fn; - img.write(rename.replace(fn.length()-4, 4, "_full.png")); + std::string root = fn; + root.replace(fn.length()-4, 4, ""); +#if !defined(ENABLE_OGL_PNG_OPAQUE) && !defined(ENABLE_OGL_PNG_ALPHA) + img.write(root + "_full.png"); +#endif #ifdef ENABLE_OGL_PNG_OPAQUE - rename = fn; - img_opaque.write(rename.replace(fn.length()-4, 4, "_opaque.png")); + img_opaque.write(root + "_opaque.png"); +#endif +#ifdef ENABLE_OGL_PNG_ALPHA + img_alpha.write(root + "_alpha.png"); #endif } } diff --git a/plugins/GSdx/GSTextureSW.cpp b/plugins/GSdx/GSTextureSW.cpp index 173fa958c5..605e814614 100644 --- a/plugins/GSdx/GSTextureSW.cpp +++ b/plugins/GSdx/GSTextureSW.cpp @@ -124,25 +124,37 @@ struct BITMAPINFOHEADER void GSTextureSW::SavePNG(const string& fn) { png::image img(m_size.x, m_size.y); png::image img_opaque(m_size.x, m_size.y); + png::image img_alpha(m_size.x, m_size.y); uint8* data = (uint8*)m_data; for(int h = 0; h < m_size.y; h++, data += m_pitch) { for (int w = 0; w < m_size.x; w++) { - png::rgba_pixel pa(data[4*w+0], data[4*w+1], data[4*w+2], data[4*w+3]); - img.set_pixel(w, h, pa); +#if !defined(ENABLE_OGL_PNG_OPAQUE) && !defined(ENABLE_OGL_PNG_ALPHA) + png::rgba_pixel p(data[4*w+0], data[4*w+1], data[4*w+2], data[4*w+3]); + img.set_pixel(w, h, p); +#endif #ifdef ENABLE_OGL_PNG_OPAQUE - png::rgb_pixel p(data[4*w+0], data[4*w+1], data[4*w+2]); - img_opaque.set_pixel(w, h, p); + png::rgb_pixel po(data[4*w+0], data[4*w+1], data[4*w+2]); + img_opaque.set_pixel(w, h, po); +#endif +#ifdef ENABLE_OGL_PNG_ALPHA + png::gray_pixel pa(data[4*w+3]); + img_alpha.set_pixel(w, h, pa); #endif } } - std::string rename = fn; - img.write(rename.replace(fn.length()-4, 4, "_full.png")); + std::string root = fn; + root.replace(fn.length()-4, 4, ""); +#if !defined(ENABLE_OGL_PNG_OPAQUE) && !defined(ENABLE_OGL_PNG_ALPHA) + img.write(root + "_full.png"); +#endif #ifdef ENABLE_OGL_PNG_OPAQUE - rename = fn; - img_opaque.write(rename.replace(fn.length()-4, 4, "_opaque.png")); + img_opaque.write(root + "_opaque.png"); +#endif +#ifdef ENABLE_OGL_PNG_ALPHA + img_alpha.write(root + "_alpha.png"); #endif } #endif diff --git a/plugins/GSdx/config.h b/plugins/GSdx/config.h index f65c192687..b24395598f 100644 --- a/plugins/GSdx/config.h +++ b/plugins/GSdx/config.h @@ -39,11 +39,11 @@ //#define DISABLE_DATE // Allow to dump texture as PNG (require libpng++). It reduces the size of the dump -// and alpha is well supported +// and alpha is well supported (on linux) //#define ENABLE_OGL_PNG -// Extension of the previous define to also dump texture without alpha (hard to see anything -// when the texture is fully transparent) +// The next two define allows to dump texture without alpha or only the alpha channel. //#define ENABLE_OGL_PNG_OPAQUE +//#define ENABLE_OGL_PNG_ALPHA #if defined(_DEBUG) || defined(_DEVEL) #define ENABLE_OGL_DEBUG // Create a debug context and check opengl command status. Allow also to dump various textures/states.