GSdx: Save PNG compressed screenshots as `.png` files

This commit is contained in:
Tyler Wilding 2020-07-28 20:16:45 -04:00 committed by refractionpcsx2
parent 9da0cc6a91
commit 9f41f33e86
2 changed files with 31 additions and 23 deletions

View File

@ -676,8 +676,12 @@ EXPORT_C_(uint32) GSmakeSnapshot(char* path)
{
std::string s{path};
if(!s.empty() && s[s.length() - 1] != DIRECTORY_SEPARATOR)
if (!s.empty())
{
// Allows for providing a complete path
if (s.substr(s.size() - 4, 4) == ".png")
return s_gs->MakeSnapshot(s);
else if (s[s.length() - 1] != DIRECTORY_SEPARATOR)
s = s + DIRECTORY_SEPARATOR;
}

View File

@ -462,7 +462,7 @@ void GSRenderer::VSync(int field)
if(GSTexture* t = m_dev->GetCurrent())
{
t->Save(m_snapshot + ".bmp");
t->Save(m_snapshot + ".png");
}
m_snapshot.clear();
@ -501,6 +501,11 @@ void GSRenderer::VSync(int field)
bool GSRenderer::MakeSnapshot(const std::string& path)
{
if (m_snapshot.empty())
{
// Allows for providing a complete path
if (path.substr(path.size() - 4, 4) == ".png")
m_snapshot = path.substr(0, path.size() - 4);
else
{
time_t cur_time = time(nullptr);
static time_t prev_snap;
@ -514,9 +519,7 @@ bool GSRenderer::MakeSnapshot(const std::string& path)
if (strftime(local_time, sizeof(local_time), "%Y%m%d%H%M%S", localtime(&cur_time)))
{
if (cur_time == prev_snap)
{
m_snapshot = format("%s_%s_(%d)", path.c_str(), local_time, n++);
}
else
{
n = 2;
@ -525,6 +528,7 @@ bool GSRenderer::MakeSnapshot(const std::string& path)
prev_snap = cur_time;
}
}
}
return true;
}