mirror of https://github.com/PCSX2/pcsx2.git
GSdx: Save PNG compressed screenshots as `.png` files
This commit is contained in:
parent
9da0cc6a91
commit
9f41f33e86
|
@ -676,9 +676,13 @@ EXPORT_C_(uint32) GSmakeSnapshot(char* path)
|
|||
{
|
||||
std::string s{path};
|
||||
|
||||
if(!s.empty() && s[s.length() - 1] != DIRECTORY_SEPARATOR)
|
||||
if (!s.empty())
|
||||
{
|
||||
s = s + DIRECTORY_SEPARATOR;
|
||||
// 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;
|
||||
}
|
||||
|
||||
return s_gs->MakeSnapshot(s + "gsdx");
|
||||
|
|
|
@ -80,7 +80,7 @@ bool GSRenderer::CreateDevice(GSDevice* dev)
|
|||
|
||||
void GSRenderer::ResetDevice()
|
||||
{
|
||||
if(m_dev) m_dev->Reset(1, 1);
|
||||
if(m_dev) m_dev->Reset(1, 1);
|
||||
}
|
||||
|
||||
bool GSRenderer::Merge(int field)
|
||||
|
@ -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();
|
||||
|
@ -500,29 +500,33 @@ void GSRenderer::VSync(int field)
|
|||
|
||||
bool GSRenderer::MakeSnapshot(const std::string& path)
|
||||
{
|
||||
if(m_snapshot.empty())
|
||||
if (m_snapshot.empty())
|
||||
{
|
||||
time_t cur_time = time(nullptr);
|
||||
static time_t prev_snap;
|
||||
// The variable 'n' is used for labelling the screenshots when multiple screenshots are taken in
|
||||
// a single second, we'll start using this variable for naming when a second screenshot request is detected
|
||||
// at the same time as the first one. Hence, we're initially setting this counter to 2 to imply that
|
||||
// the captured image is the 2nd image captured at this specific time.
|
||||
static int n = 2;
|
||||
char local_time[16];
|
||||
|
||||
if (strftime(local_time, sizeof(local_time), "%Y%m%d%H%M%S", localtime(&cur_time)))
|
||||
// Allows for providing a complete path
|
||||
if (path.substr(path.size() - 4, 4) == ".png")
|
||||
m_snapshot = path.substr(0, path.size() - 4);
|
||||
else
|
||||
{
|
||||
if (cur_time == prev_snap)
|
||||
time_t cur_time = time(nullptr);
|
||||
static time_t prev_snap;
|
||||
// The variable 'n' is used for labelling the screenshots when multiple screenshots are taken in
|
||||
// a single second, we'll start using this variable for naming when a second screenshot request is detected
|
||||
// at the same time as the first one. Hence, we're initially setting this counter to 2 to imply that
|
||||
// the captured image is the 2nd image captured at this specific time.
|
||||
static int n = 2;
|
||||
char local_time[16];
|
||||
|
||||
if (strftime(local_time, sizeof(local_time), "%Y%m%d%H%M%S", localtime(&cur_time)))
|
||||
{
|
||||
m_snapshot = format("%s_%s_(%d)", path.c_str(), local_time, n++);
|
||||
if (cur_time == prev_snap)
|
||||
m_snapshot = format("%s_%s_(%d)", path.c_str(), local_time, n++);
|
||||
else
|
||||
{
|
||||
n = 2;
|
||||
m_snapshot = format("%s_%s", path.c_str(), local_time);
|
||||
}
|
||||
prev_snap = cur_time;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = 2;
|
||||
m_snapshot = format("%s_%s", path.c_str(), local_time);
|
||||
}
|
||||
prev_snap = cur_time;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue