From 3e5a593021deee4bd25b8aaf706ebbe2a8811759 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Wed, 4 Aug 2021 22:28:22 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20Fix=20reading=20PCX=20files=20wi?= =?UTF-8?q?th=20odd=20widths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PCX files always have an even number of bytes on each uncompressed source line, which means there is an unused byte of each compressed line if the width is odd. References: 1. https://kaba.hilvi.org/pastel-1.5.0/pastel/gfx/image_file/pcx/pcx_file.htm 2. https://www.moon-soft.com/program/FORMAT/graphics/pcx.htm#decoding%20.pcx%20files --- Source/DiabloUI/art.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/DiabloUI/art.cpp b/Source/DiabloUI/art.cpp index 5a5232fb8..07d78f142 100644 --- a/Source/DiabloUI/art.cpp +++ b/Source/DiabloUI/art.cpp @@ -44,6 +44,7 @@ bool LoadPcxPixelsAndPalette(HANDLE handle, int width, int height, std::uint8_t return false; } const unsigned xSkip = bufferPitch - width; + const unsigned srcSkip = width % 2; BYTE *dataPtr = fileBuffer.get(); for (int j = 0; j < height; j++) { for (int x = 0; x < width;) { @@ -60,6 +61,7 @@ bool LoadPcxPixelsAndPalette(HANDLE handle, int width, int height, std::uint8_t buffer += runLength; x += runLength; } + dataPtr += srcSkip; buffer += xSkip; }