mirror of https://github.com/PCSX2/pcsx2.git
gsdx debug: allow to dump alpha channel as a gray texture
I would love to find an image viewer that allow to mask channel of the image
This commit is contained in:
parent
c8a3db114c
commit
004fa7aea4
|
@ -520,25 +520,37 @@ void GSTextureOGL::SavePNG(const string& fn, const void* image, uint32 pitch) {
|
|||
} else {
|
||||
png::image<png::rgba_pixel> img(m_size.x, m_size.y);
|
||||
png::image<png::rgb_pixel> img_opaque(m_size.x, m_size.y);
|
||||
png::image<png::gray_pixel> 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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,25 +124,37 @@ struct BITMAPINFOHEADER
|
|||
void GSTextureSW::SavePNG(const string& fn) {
|
||||
png::image<png::rgba_pixel> img(m_size.x, m_size.y);
|
||||
png::image<png::rgb_pixel> img_opaque(m_size.x, m_size.y);
|
||||
png::image<png::gray_pixel> 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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue