Skip to content

Commit

Permalink
No double screenshots anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
St4lker0k765 committed Nov 29, 2024
1 parent 19f3ddb commit 8a07334
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
16 changes: 9 additions & 7 deletions src/Layers/xrRenderDX10/dx11RenderScreenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,22 @@ void CRender::ScreenshotImpl(ScreenshotMode mode, LPCSTR name, CMemoryWriter* me
auto scratchImage = std::make_unique<ScratchImage>();
auto saved = std::make_unique<Blob>();
CaptureTexture(RDevice, RContext, pSrcTexture, *scratchImage);
SaveToWICMemory(*scratchImage->GetImage(0, 0, 0), WIC_FLAGS::WIC_FLAGS_NONE, GUID_ContainerFormatJpeg, *saved);
if (ps_screenshot_format == 0)
{
SaveToWICMemory(*scratchImage->GetImage(0, 0, 0), WIC_FLAGS::WIC_FLAGS_NONE, GUID_ContainerFormatJpeg, *saved);

auto fs = FS.w_open("$screenshots$", buf); R_ASSERT(fs);
fs->w(saved->GetBufferPointer(), (u32)saved->GetBufferSize());
FS.w_close(fs);
auto fs = FS.w_open("$screenshots$", buf); R_ASSERT(fs);
fs->w(saved->GetBufferPointer(), (u32)saved->GetBufferSize());
FS.w_close(fs);

// hq
if (ps_screenshot_format == 1)
}
else if (ps_screenshot_format == 1)
{
xr_sprintf(buf, sizeof(buf), "ssq_%s_%s_(%s).tga", Core.UserName, timestamp(t_stemp), (g_pGameLevel) ? g_pGameLevel->name().c_str() : "mainmenu");

SaveToTGAMemory(*scratchImage->GetImage(0, 0, 0), TGA_FLAGS::TGA_FLAGS_NONE, *saved);

fs = FS.w_open("$screenshots$", buf); R_ASSERT(fs);
auto fs = FS.w_open("$screenshots$", buf); R_ASSERT(fs);
fs->w(saved->GetBufferPointer(), (u32)saved->GetBufferSize());
FS.w_close(fs);
}
Expand Down
20 changes: 11 additions & 9 deletions src/Layers/xrRenderDX9/dx9RenderScreenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,21 @@ void CRender::ScreenshotImpl(ScreenshotMode mode, LPCSTR name, CMemoryWriter* me
{
string64 t_stemp;
string_path buf;
xr_sprintf(buf, sizeof(buf), "ss_%s_%s_(%s).jpg", Core.UserName, timestamp(t_stemp), (g_pGameLevel) ? g_pGameLevel->name().c_str() : "mainmenu");
Blob saved;

R_CHK(SaveToWICMemory(*scratchImage.GetImage(0, 0, 0), WIC_FLAGS::WIC_FLAGS_NONE, GUID_ContainerFormatJpeg, saved));
IWriter* fs;
if (ps_screenshot_format == 0)
{
xr_sprintf(buf, sizeof(buf), "ss_%s_%s_(%s).jpg", Core.UserName, timestamp(t_stemp), (g_pGameLevel) ? g_pGameLevel->name().c_str() : "mainmenu");
R_CHK(SaveToWICMemory(*scratchImage.GetImage(0, 0, 0), WIC_FLAGS::WIC_FLAGS_NONE, GUID_ContainerFormatJpeg, saved));

IWriter* fs = FS.w_open("$screenshots$", buf); R_ASSERT(fs);
fs->w(saved.GetBufferPointer(), (u32)saved.GetBufferSize());
FS.w_close(fs);
fs = FS.w_open("$screenshots$", buf); R_ASSERT(fs);
fs->w(saved.GetBufferPointer(), (u32)saved.GetBufferSize());
FS.w_close(fs);

// hq
if (ps_screenshot_format == 1)
}
else if (ps_screenshot_format == 1)
{
xr_sprintf(buf, sizeof(buf), "ssq_%s_%s_(%s).tga", Core.UserName, timestamp(t_stemp), (g_pGameLevel) ? g_pGameLevel->name().c_str() : "mainmenu");
xr_sprintf(buf, sizeof(buf), "ss_%s_%s_(%s).tga", Core.UserName, timestamp(t_stemp), (g_pGameLevel) ? g_pGameLevel->name().c_str() : "mainmenu");

SaveToTGAMemory(*scratchImage.GetImage(0, 0, 0), TGA_FLAGS::TGA_FLAGS_NONE, saved);

Expand Down

0 comments on commit 8a07334

Please sign in to comment.