diff --git a/Core/Config.cpp b/Core/Config.cpp index aebb7523cd..da09164edb 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -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; - -} +} \ No newline at end of file diff --git a/Core/Config.h b/Core/Config.h index 68ec133ed2..d18618d74d 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -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; \ No newline at end of file diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index e3c9a2f4c2..3b35a043ce 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -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;