Skip to content

Commit 7cbbd13

Browse files
author
nitrocaster
committed
Refactor and move TGA saver to xrCore.
1 parent 79cdea1 commit 7cbbd13

33 files changed

+205
-1067
lines changed

src/Layers/xrRender/r__screenshot.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#include "stdafx.h"
22
#include "xr_effgamma.h"
33
#include "dxRenderDeviceRender.h"
4-
#include "Layers/xrRender/tga.h"
4+
#include "xrCore/Media/Image.hpp"
55
#include "xrEngine/xrImage_Resampler.h"
66
#if defined(USE_DX10) || defined(USE_DX11)
77
#include "d3dx10tex.h"
88
#endif // USE_DX10
99

10+
using namespace XRay::Media;
11+
1012
#define GAMESAVE_SIZE 128
1113

1214
IC u32 convert (float c) {
@@ -395,9 +397,6 @@ void CRender::ScreenshotImpl (ScreenshotMode mode, LPCSTR name, CMemoryWriter* m
395397
VERIFY (name);
396398
strconcat (sizeof(buf), buf, name, ".tga");
397399
IWriter* fs = FS.w_open ("$screenshots$",buf); R_ASSERT(fs);
398-
TGAdesc p;
399-
p.format = IMG_24B;
400-
401400
// TODO: DX10: This is totally incorrect but mimics
402401
// original behavior. Fix later.
403402
hr = pFB->LockRect(&D,0,D3DLOCK_NOSYSLOCK);
@@ -406,16 +405,13 @@ void CRender::ScreenshotImpl (ScreenshotMode mode, LPCSTR name, CMemoryWriter* m
406405
if(hr!=D3D_OK) goto _end_;
407406

408407
// save
409-
u32* data = (u32*)xr_malloc(Device.dwHeight*Device.dwHeight*4);
410-
imf_Process (data,Device.dwHeight,Device.dwHeight,(u32*)D.pBits,Device.dwWidth,Device.dwHeight,imf_lanczos3);
411-
p.scanlenght = Device.dwHeight*4;
412-
p.width = Device.dwHeight;
413-
p.height = Device.dwHeight;
414-
p.data = data;
415-
p.maketga (*fs);
416-
xr_free (data);
417-
418-
FS.w_close (fs);
408+
u32* data = (u32*)xr_malloc(Device.dwHeight*Device.dwHeight*4);
409+
imf_Process(data,Device.dwHeight,Device.dwHeight,(u32*)D.pBits,Device.dwWidth,Device.dwHeight,imf_lanczos3);
410+
Image img;
411+
img.Create(u16(Device.dwHeight), u16(Device.dwHeight), data, ImageFormat::RGBA8);
412+
img.SaveTGA(*fs, true);
413+
xr_free(data);
414+
FS.w_close(fs);
419415
}
420416
break;
421417
}

src/Layers/xrRender/tga.cpp

Lines changed: 0 additions & 118 deletions
This file was deleted.

src/Layers/xrRender/tga.h

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/Layers/xrRenderPC_R1/xrRender_R1.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@
434434
<ClCompile Include="..\xrRender\stats_manager.cpp" />
435435
<ClCompile Include="..\xrRender\Texture.cpp" />
436436
<ClCompile Include="..\xrRender\TextureDescrManager.cpp" />
437-
<ClCompile Include="..\xrRender\tga.cpp" />
438437
<ClCompile Include="..\xrRender\tss_def.cpp" />
439438
<ClCompile Include="..\xrRender\VertexCache.cpp" />
440439
<ClCompile Include="..\xrRender\WallmarksEngine.cpp" />

src/Layers/xrRenderPC_R1/xrRender_R1.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,6 @@
641641
<ClCompile Include="..\xrRender\Texture.cpp">
642642
<Filter>Core</Filter>
643643
</ClCompile>
644-
<ClCompile Include="..\xrRender\tga.cpp">
645-
<Filter>Core</Filter>
646-
</ClCompile>
647644
<ClCompile Include="..\xrRender\ColorMapManager.cpp">
648645
<Filter>Core\ColorMap</Filter>
649646
</ClCompile>

src/Layers/xrRenderPC_R2/xrRender_R2.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@
443443
<ClCompile Include="..\xrRender\stats_manager.cpp" />
444444
<ClCompile Include="..\xrRender\Texture.cpp" />
445445
<ClCompile Include="..\xrRender\TextureDescrManager.cpp" />
446-
<ClCompile Include="..\xrRender\tga.cpp" />
447446
<ClCompile Include="..\xrRender\tss_def.cpp" />
448447
<ClCompile Include="..\xrRender\uber_deffer.cpp" />
449448
<ClCompile Include="..\xrRender\VertexCache.cpp" />

src/Layers/xrRenderPC_R2/xrRender_R2.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,6 @@
695695
<ClCompile Include="..\xrRender\Texture.cpp">
696696
<Filter>Core</Filter>
697697
</ClCompile>
698-
<ClCompile Include="..\xrRender\tga.cpp">
699-
<Filter>Core</Filter>
700-
</ClCompile>
701698
<ClCompile Include="..\xrRender\DetailManager.cpp">
702699
<Filter>Details</Filter>
703700
</ClCompile>

src/Layers/xrRenderPC_R3/xrRender_R3.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@
490490
<ClCompile Include="..\xrRender\SkeletonX.cpp" />
491491
<ClCompile Include="..\xrRender\stats_manager.cpp" />
492492
<ClCompile Include="..\xrRender\TextureDescrManager.cpp" />
493-
<ClCompile Include="..\xrRender\tga.cpp" />
494493
<ClCompile Include="..\xrRender\tss_def.cpp" />
495494
<ClCompile Include="..\xrRender\uber_deffer.cpp" />
496495
<ClCompile Include="..\xrRender\Utils\dxHashHelper.cpp" />

src/Layers/xrRenderPC_R3/xrRender_R3.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,9 +788,6 @@
788788
<ClCompile Include="..\xrRender\r__screenshot.cpp">
789789
<Filter>Core</Filter>
790790
</ClCompile>
791-
<ClCompile Include="..\xrRender\tga.cpp">
792-
<Filter>Core</Filter>
793-
</ClCompile>
794791
<ClCompile Include="..\xrRender\DetailManager.cpp">
795792
<Filter>Details</Filter>
796793
</ClCompile>

src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,6 @@
496496
<ClCompile Include="..\xrRender\SkeletonX.cpp" />
497497
<ClCompile Include="..\xrRender\stats_manager.cpp" />
498498
<ClCompile Include="..\xrRender\TextureDescrManager.cpp" />
499-
<ClCompile Include="..\xrRender\tga.cpp" />
500499
<ClCompile Include="..\xrRender\tss_def.cpp" />
501500
<ClCompile Include="..\xrRender\uber_deffer.cpp" />
502501
<ClCompile Include="..\xrRender\Utils\dxHashHelper.cpp" />

0 commit comments

Comments
 (0)