PNG screenshot writing

This commit is contained in:
dykebeard 2013-07-07 14:56:18 -04:00
parent 76c3f16b5c
commit dc0a7de62b
3 changed files with 19 additions and 8 deletions

View File

@ -61,6 +61,7 @@ void Config::Load(const char *iniFileName)
general->Get("NumWorkerThreads", &iNumWorkerThreads, cpu_info.num_cores);
general->Get("EnableCheats", &bEnableCheats, false);
general->Get("MaxRecent", &iMaxRecent, 12);
general->Get("ScreenshotsAsPNG", &bScreenshotAsPNG, true);
// Fix issue from switching from uint (hex in .ini) to int (dec)
if (iMaxRecent == 0)
@ -210,6 +211,7 @@ void Config::Save()
general->Set("NumWorkerThreads", iNumWorkerThreads);
general->Set("MaxRecent", iMaxRecent);
general->Set("EnableCheats", bEnableCheats);
general->Set("ScreenshotsAsPNG", &bScreenshotAsPNG);
IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
cpu->Set("Jit", bJit);
@ -319,5 +321,4 @@ void Config::CleanRecent() {
cleanedRecent.push_back(recentIsos[i]);
}
recentIsos = cleanedRecent;
}
}

View File

@ -49,6 +49,7 @@ public:
// General
bool bNewUI; // "Hidden" setting, does not get saved to ini file.
int iNumWorkerThreads;
bool bScreenshotAsPNG;
// Core
bool bIgnoreBadMemAccess;
@ -159,4 +160,4 @@ private:
std::string iniFilename_;
};
extern Config g_Config;
extern Config g_Config;

View File

@ -34,6 +34,7 @@
#include "base/NativeApp.h"
#include "file/vfs.h"
#include "file/zip_read.h"
#include "native/ext/stb_image_write/stb_image_writer.h"
#include "native/ext/jpge/jpge.h"
#include "gfx_es2/gl_state.h"
#include "gfx/gl_lost_manager.h"
@ -465,8 +466,11 @@ void TakeScreenshot() {
int i = 0;
char temp[256];
while (i < 10000) {
sprintf(temp, "screenshots/screen%05d.jpg", i);
while (i < 10000){
if(g_Config.bScreenshotAsPNG)
sprintf(temp, "screenshots/screen%05d.png", i);
else
sprintf(temp, "screenshots/screen%05d.jpg", i);
FileInfo info;
if (!getFileInfo(temp, &info))
break;
@ -484,9 +488,14 @@ void TakeScreenshot() {
memcpy(flipbuffer + y * pixel_xres * 4, buffer + (pixel_yres - y - 1) * pixel_xres * 4, pixel_xres * 4);
}
jpge::params params;
params.m_quality = 90;
compress_image_to_jpeg_file(temp, pixel_xres, pixel_yres, 4, flipbuffer, params);
if(g_Config.bScreenshotAsPNG)
stbi_write_png(temp, pixel_xres, pixel_yres, 4, flipbuffer, pixel_xres * 4);
else
{
jpge::params params;
params.m_quality = 90;
compress_image_to_jpeg_file(temp, pixel_xres, pixel_yres, 4, flipbuffer, params);
}
delete [] buffer;
delete [] flipbuffer;