* Reads a 4 bpp uncompressed bitmap * The bitmap is converted to a 8 bpp bitmap */
| 43 | * The bitmap is converted to a 8 bpp bitmap |
| 44 | */ |
| 45 | static inline bool BmpRead4(RandomAccessFile &file, BmpInfo &info, BmpData &data) |
| 46 | { |
| 47 | uint8_t pad = GB(4 - info.width / 2, 0, 2); |
| 48 | for (uint y = info.height; y > 0; y--) { |
| 49 | uint x = 0; |
| 50 | uint8_t *pixel_row = &data.bitmap[(y - 1) * static_cast<size_t>(info.width)]; |
| 51 | while (x < info.width) { |
| 52 | if (file.AtEndOfFile()) return false; // the file is shorter than expected |
| 53 | uint8_t b = file.ReadByte(); |
| 54 | *pixel_row++ = GB(b, 4, 4); |
| 55 | x++; |
| 56 | if (x < info.width) { |
| 57 | *pixel_row++ = GB(b, 0, 4); |
| 58 | x++; |
| 59 | } |
| 60 | } |
| 61 | /* Padding for 32 bit align */ |
| 62 | file.SkipBytes(pad); |
| 63 | } |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Reads a 4-bit RLE compressed bitmap |
no test coverage detected