diff options
| author | Dylan <boss@tehbox.org> | 2026-04-30 16:43:10 +1200 |
|---|---|---|
| committer | Dylan <boss@tehbox.org> | 2026-04-30 16:43:10 +1200 |
| commit | d793ddf3f31435a7dd050b6bed00cf2dd551871c (patch) | |
| tree | 39f7b16ffc750e3799f9968649e29d71640dd16d | |
| parent | dc12c3562d858cbe38a99cd751fee2917b8e122e (diff) | |
| download | tehimage-d793ddf3f31435a7dd050b6bed00cf2dd551871c.tar.gz tehimage-d793ddf3f31435a7dd050b6bed00cf2dd551871c.zip | |
feat: Implemented padding
Implemented padding scalines to 4 bytes if they aren't already that
| -rw-r--r-- | src/BMPImage.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/BMPImage.cpp b/src/BMPImage.cpp index 1835f4f..762afdb 100644 --- a/src/BMPImage.cpp +++ b/src/BMPImage.cpp @@ -81,6 +81,7 @@ namespace TehImage pixel.r = reader.readByte(); pixel.a = 255; } + reader.skipBytes((width * 3)%4); } @@ -92,7 +93,8 @@ namespace TehImage { FILE* fd = fopen(filename.c_str(), "w"); char magic[] = "BM"; - uint32_t fileSize = 14 + 12 + width*height*/*(bitDepth/8)*/8*3; + uint32_t rowSize = (bpp * width + 31)/32; + uint32_t fileSize = 14 + 12 + rowSize*height*/*(bitDepth/8)*/8*3; char zero[] = "\0\0\0\0"; uint32_t offset = 26; uint32_t headerSize = 12; @@ -121,6 +123,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); } fclose(fd); |
