From 06f1d3fab1bc1866f745625fdcaa3a7a852d3391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo?= Date: Thu, 18 Jul 2024 20:01:16 -0300 Subject: [PATCH] Make get_row_pitch able to handle very tall textures. Fixes #4. (#5) --- ddspp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddspp.h b/ddspp.h index ef0e939..b395f6d 100644 --- a/ddspp.h +++ b/ddspp.h @@ -622,7 +622,7 @@ namespace ddspp // Shift width by mipmap index, round to next block size and round to next byte (for the rare less than 1 byte per pixel formats) // E.g. width = 119, mip = 3, BC1 compression // ((((119 >> 2) + 4 - 1) / 4) * 64) / 8 = 64 bytes - return ((((width >> mip) + blockWidth - 1) / blockWidth) * bitsPerPixelOrBlock + 7) / 8; + return ((((((width >> mip) > 1) ? (width >> mip) : 1) + blockWidth - 1) / blockWidth) * bitsPerPixelOrBlock + 7) / 8; } // Returns number of bytes for each row of a given mip. Valid range is [0, desc.numMips)