From 92d6c2b7b0143945033b10bb99596c89a1cea5fc Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Sep 2025 10:15:20 +0200 Subject: [PATCH] make patch/pixel conversion account for padding data/no data just set everything to transparent pixel 247 (0xf7) so we neither write nor read garbage data and just can cut it out as transparent during pixel to patch conversion --- src/r_patch.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/r_patch.c b/src/r_patch.c index 3f7fdc983..d8e0b94f3 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -491,6 +491,16 @@ void *R_PixelsToPatch(UINT8 *raw, INT16 width, INT16 height, INT16 leftoffset, I for (y = 0; y < height; y++) { UINT8 pixel = raw[((y * width) + x)]; + UINT8 opaque = (pixel != 0xf7); // If not 247 (0xf7), we have a pixel + + // End span if we have a transparent pixel + if (!opaque) + { + if (startofspan) + WRITEUINT8(imgptr, 0); + startofspan = NULL; + continue; + } // Start new column if we need to if (!startofspan || spanSize == 255) @@ -728,6 +738,9 @@ void R_PatchToPixels(patch_t *patch, UINT8 *dst) { const INT16 width = patch->width; + // init out destination to cyan so we can easily check for it when we convert it back to a patch + memset(dst, 0xf7, (width * patch->height)); // should this be here or should this be taken care of before passing it? + for (INT32 x = 0; x < width; ++x) { INT32 y = 0;