From 500151be4794923cee6034c26881effeb1bb056d Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 4 May 2026 17:35:30 +1200 Subject: feat: Implemented BMP row padding Rows in a bitmap are now padded to be a multiple of 4 bytes long --- src/BMPImage.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/BMPImage.cpp') diff --git a/src/BMPImage.cpp b/src/BMPImage.cpp index 762afdb..b79bc0c 100644 --- a/src/BMPImage.cpp +++ b/src/BMPImage.cpp @@ -81,7 +81,8 @@ namespace TehImage pixel.r = reader.readByte(); pixel.a = 255; } - reader.skipBytes((width * 3)%4); + + reader.skipBytes((4-((width * 3)%4))%4); } @@ -123,7 +124,7 @@ namespace TehImage fwrite(&pixel.g, sizeof(uint8_t), 1, fd); fwrite(&pixel.r, sizeof(uint8_t), 1, fd); } - fwrite(zero, sizeof(char), (width * 3)%4, fd); + fwrite(zero, sizeof(char), (4-((width * 3)%4))%4, fd); } fclose(fd); -- cgit v1.2.3