gsdx-ogl: add ENABLE_OGL_PNG_OPAQUE to dump texture without alpha

Alpha is nice but fully transparent texture suck

The best will be an image viewer that can toggle the alpha channel
This commit is contained in:
Gregory Hainaut 2015-04-30 23:06:54 +02:00
parent 39a5d4c839
commit 25997647f2
3 changed files with 32 additions and 6 deletions

View File

@ -536,17 +536,27 @@ void GSTextureOGL::SavePNG(const string& fn, const void* image, uint32 pitch) {
//png::image<png::gray_pixel_16> img(m_size.x, m_size.y);
} 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);
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 pixel(data[4*w+0], data[4*w+1], data[4*w+2], data[4*w+3]);
img.set_pixel(w, h, pixel);
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);
#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);
#endif
}
}
std::string rename = fn;
img.write(rename.replace(fn.length()-3, 3, "png"));
img.write(rename.replace(fn.length()-4, 4, "_full.png"));
#ifdef ENABLE_OGL_PNG_OPAQUE
rename = fn;
img_opaque.write(rename.replace(fn.length()-4, 4, "_opaque.png"));
#endif
}
}
#endif

View File

@ -123,17 +123,27 @@ 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);
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 pixel(data[4*w+0], data[4*w+1], data[4*w+2], data[4*w+3]);
img.set_pixel(w, h, pixel);
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);
#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);
#endif
}
}
std::string rename = fn;
img.write(rename.replace(fn.length()-3, 3, "png"));
img.write(rename.replace(fn.length()-4, 4, "_full.png"));
#ifdef ENABLE_OGL_PNG_OPAQUE
rename = fn;
img_opaque.write(rename.replace(fn.length()-4, 4, "_opaque.png"));
#endif
}
#endif

View File

@ -38,7 +38,13 @@
//#define DISABLE_DATE
// Allow to dump texture as PNG (require libpng++). It reduces the size of the dump
// and alpha is well supported
//#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)
//#define ENABLE_OGL_PNG_OPAQUE
#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.
//#define ENABLE_OGL_DEBUG_FENCE