* Reads a 1 bpp uncompressed bitmap * The bitmap is converted to a 8 bpp bitmap */
| 19 | * The bitmap is converted to a 8 bpp bitmap |
| 20 | */ |
| 21 | static inline bool BmpRead1(RandomAccessFile &file, BmpInfo &info, BmpData &data) |
| 22 | { |
| 23 | uint8_t pad = GB(4 - info.width / 8, 0, 2); |
| 24 | for (uint y = info.height; y > 0; y--) { |
| 25 | uint x = 0; |
| 26 | uint8_t *pixel_row = &data.bitmap[(y - 1) * static_cast<size_t>(info.width)]; |
| 27 | while (x < info.width) { |
| 28 | if (file.AtEndOfFile()) return false; // the file is shorter than expected |
| 29 | uint8_t b = file.ReadByte(); |
| 30 | for (uint i = 8; i > 0; i--) { |
| 31 | if (x < info.width) *pixel_row++ = GB(b, i - 1, 1); |
| 32 | x++; |
| 33 | } |
| 34 | } |
| 35 | /* Padding for 32 bit align */ |
| 36 | file.SkipBytes(pad); |
| 37 | } |
| 38 | return true; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Reads a 4 bpp uncompressed bitmap |
no test coverage detected