aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan <boss@tehbox.org>2026-05-04 17:35:30 +1200
committerDylan <boss@tehbox.org>2026-05-04 18:16:31 +1200
commit500151be4794923cee6034c26881effeb1bb056d (patch)
treedcaf01a6b118e724eb08a6f0b5a44fca369e18ca
parentd793ddf3f31435a7dd050b6bed00cf2dd551871c (diff)
downloadtehimage-500151be4794923cee6034c26881effeb1bb056d.tar.gz
tehimage-500151be4794923cee6034c26881effeb1bb056d.zip
feat: Implemented BMP row padding
Rows in a bitmap are now padded to be a multiple of 4 bytes long
-rw-r--r--src/BMPImage.cpp5
1 files changed, 3 insertions, 2 deletions
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);