From e57d5ae62b040549b85f30613998558e8168d8a6 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sun, 7 Apr 2019 16:31:55 +0900 Subject: [PATCH 1/2] CapturePix bin exact --- Source/capture.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Source/capture.cpp b/Source/capture.cpp index fdb3ce54f..2909a7a46 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -90,18 +90,16 @@ BOOL __fastcall CapturePix(HANDLE hFile, WORD width, WORD height, WORD stride, B BYTE *pBuffer, *pBufferEnd; pBuffer = (BYTE *)DiabloAllocPtr(2 * width); - do { - if (!height) { - mem_free_dbg(pBuffer); - return TRUE; - } - height--; + while (height-- != 0) { pBufferEnd = CaptureEnc(pixels, pBuffer, width); pixels += stride; writeSize = pBufferEnd - pBuffer; - } while (WriteFile(hFile, pBuffer, writeSize, &lpNumBytes, 0) && lpNumBytes == writeSize); - - return FALSE; + if (!(WriteFile(hFile, pBuffer, writeSize, &lpNumBytes, 0) && lpNumBytes == writeSize)) { + return FALSE; + } + } + mem_free_dbg(pBuffer); + return TRUE; } BYTE *__fastcall CaptureEnc(BYTE *src, BYTE *dst, int width) From a9b8ad1d88946d72cf8ff1e1f9f61968984836bf Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Mon, 8 Apr 2019 10:35:46 +0900 Subject: [PATCH 2/2] Update Source/capture.cpp Co-Authored-By: mewmew --- Source/capture.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/capture.cpp b/Source/capture.cpp index 2909a7a46..af00deeb9 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -90,7 +90,8 @@ BOOL __fastcall CapturePix(HANDLE hFile, WORD width, WORD height, WORD stride, B BYTE *pBuffer, *pBufferEnd; pBuffer = (BYTE *)DiabloAllocPtr(2 * width); - while (height-- != 0) { + while (height != 0) { + height--; pBufferEnd = CaptureEnc(pixels, pBuffer, width); pixels += stride; writeSize = pBufferEnd - pBuffer;