fix screenshots in C client, fix bug in deflate compressor resulting in much less efficient compression

This commit is contained in:
UnknownShadow200 2018-05-22 14:03:07 +10:00
parent 22eabb52d9
commit d25bf3c949
4 changed files with 5 additions and 4 deletions

View File

@ -592,9 +592,10 @@ void Gfx_TakeScreenshot(Stream* output, Int32 width, Int32 height) {
Bitmap bmp; Bitmap_Create(&bmp, width, height, rect.pBits);
Bitmap_EncodePng(&bmp, output);
Platform_MemFree(&bmp.Scan0);
hresult = IDirect3DSurface9_UnlockRect(temp);
ErrorHandler_CheckOrFail(hresult, "Gfx_TakeScreenshot - Unlock temp surface");
D3D9_FreeResource(&backbuffer);
D3D9_FreeResource(&temp);
}

View File

@ -801,7 +801,7 @@ static ReturnCode Deflate_FlushBlock(DeflateState* state, Int32 len) {
maxLen = min(len - 1, DEFLATE_MAX_MATCH_LEN);
while (nextPos != 0) { /* TODO: Need to limit chain length here */
Int32 matchLen = Deflate_MatchLen(&src[nextPos], cur, maxLen);
Int32 matchLen = Deflate_MatchLen(&src[nextPos], cur + 1, maxLen);
if (matchLen > bestLen) { bestPos = 0; break; }
nextPos = state->Prev[nextPos];
}

View File

@ -510,7 +510,7 @@ void Gfx_TakeScreenshot(Stream* output, Int32 width, Int32 height) {
UInt32 stride = (UInt32)(bmp.Width) * BITMAP_SIZEOF_PIXEL;
for (y = 0; y < height / 2; y++) {
UInt32* src = Bitmap_GetRow(&bmp, y);
UInt32* dst = Bitmap_GetRow(&bmp, y);
UInt32* dst = Bitmap_GetRow(&bmp, (height - 1) - y);
Platform_MemCpy(tmp, src, stride);
Platform_MemCpy(src, dst, stride);

View File

@ -57,7 +57,7 @@ typedef struct FontDesc_ { void* Handle; UInt16 Size, Style; } FontDesc;
#define Int32_MaxValue ((Int32)2147483647L)
#define UInt32_MaxValue ((UInt32)4294967295UL)
#define USE_DX false
#define USE_DX true
#if USE_DX
typedef void* GfxResourceID;