mirror of https://github.com/PCSX2/pcsx2.git
gsdx-ogl: allow to dump texture as png file
-- slower (but that a debug feature) ++ smaller (40x-50x) ++ native support of alpha Require libpng++ and the define ENABLE_OGL_PNG Note: depth is not supported yet.
This commit is contained in:
parent
ee19a2789c
commit
8a52fdab57
|
@ -527,6 +527,30 @@ void GSTextureOGL::Save(const string& fn, const void* image, uint32 pitch)
|
|||
fclose(fp);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_OGL_PNG
|
||||
#include "png++/png.hpp"
|
||||
|
||||
void GSTextureOGL::SavePNG(const string& fn, const void* image, uint32 pitch) {
|
||||
if (IsDss()) {
|
||||
// TODO
|
||||
//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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
std::string rename = fn;
|
||||
img.write(rename.replace(fn.length()-3, 3, "png"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void GSTextureOGL::SaveRaw(const string& fn, const void* image, uint32 pitch)
|
||||
{
|
||||
// Build a raw CSV file
|
||||
|
@ -607,7 +631,11 @@ bool GSTextureOGL::Save(const string& fn, bool dds)
|
|||
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_OGL_PNG
|
||||
if (status) SavePNG(fn, image, pitch);
|
||||
#else
|
||||
if (status) Save(fn, image, pitch);
|
||||
#endif
|
||||
free(image);
|
||||
|
||||
return status;
|
||||
|
|
|
@ -69,6 +69,9 @@ class GSTextureOGL : public GSTexture
|
|||
void Unmap();
|
||||
bool Save(const string& fn, bool dds = false);
|
||||
void Save(const string& fn, const void* image, uint32 pitch);
|
||||
#ifdef ENABLE_OGL_PNG
|
||||
void SavePNG(const string& fn, const void* image, uint32 pitch);
|
||||
#endif
|
||||
void SaveRaw(const string& fn, const void* image, uint32 pitch);
|
||||
|
||||
bool IsBackbuffer() { return (m_type == GSTexture::Backbuffer); }
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
//#define DISABLE_DATE
|
||||
|
||||
//#define ENABLE_OGL_PNG
|
||||
#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
|
||||
|
|
Loading…
Reference in New Issue