9 #include "../3rdParty/Storm/Source/storm.h"
10 #include "file_util.h"
21 static BOOL
CaptureHdr(
short width,
short height, std::ofstream *out)
26 memset(&Buffer, 0,
sizeof(Buffer));
31 Buffer.
Xmax = SDL_SwapLE16(width - 1);
32 Buffer.
Ymax = SDL_SwapLE16(height - 1);
33 Buffer.
HDpi = SDL_SwapLE16(width);
34 Buffer.
VDpi = SDL_SwapLE16(height);
38 out->write(
reinterpret_cast<const char*
>(&Buffer),
sizeof(Buffer));
42 static BOOL
CapturePal(SDL_Color *palette, std::ofstream *out)
44 BYTE pcx_palette[1 + 256 * 3];
48 for (i = 0; i < 256; i++) {
49 pcx_palette[1 + 3 * i + 0] = palette[i].r;
50 pcx_palette[1 + 3 * i + 1] = palette[i].g;
51 pcx_palette[1 + 3 * i + 2] = palette[i].b;
54 out->write(
reinterpret_cast<const char *
>(pcx_palette),
sizeof(pcx_palette));
69 while (rlePixel == *src) {
80 if (rleLength > 1 || rlePixel > 0xBF) {
81 *dst = rleLength | 0xC0;
92 static bool CapturePix(WORD width, WORD height, WORD stride, BYTE *pixels, std::ofstream *out)
96 BYTE *pBuffer, *pBufferEnd;
100 pBufferEnd =
CaptureEnc(pixels, pBuffer, width);
102 writeSize = pBufferEnd - pBuffer;
103 out->write(
reinterpret_cast<const char *
>(pBuffer), writeSize);
104 if (out->fail())
return false;
117 GetPrefPath(path, MAX_PATH);
119 for (
int i = 0; i <= 99; i++) {
120 snprintf(dst_path, MAX_PATH,
"%sscreen%02d.PCX", path, i);
121 if (!FileExists(dst_path))
122 return new std::ofstream(dst_path, std::ios::binary | std::ios::trunc);
133 for (
int i = 0; i < 255; i++) {
150 SDL_Color palette[256];
151 char FileName[MAX_PATH];
155 if (out ==
nullptr)
return;
172 SDL_Log(
"Failed to save screenshot at %s", FileName);
173 RemoveFile(FileName);
175 SDL_Log(
"Screenshot saved at %s", FileName);
178 for (
int i = 0; i < 255; i++) {