* Reads a 24 bpp uncompressed bitmap */
| 221 | * Reads a 24 bpp uncompressed bitmap |
| 222 | */ |
| 223 | static inline bool BmpRead24(RandomAccessFile &file, BmpInfo &info, BmpData &data) |
| 224 | { |
| 225 | uint8_t pad = GB(4 - info.width * 3, 0, 2); |
| 226 | for (uint y = info.height; y > 0; --y) { |
| 227 | uint8_t *pixel_row = &data.bitmap[(y - 1) * static_cast<size_t>(info.width) * 3]; |
| 228 | for (uint x = 0; x < info.width; ++x) { |
| 229 | if (file.AtEndOfFile()) return false; // the file is shorter than expected |
| 230 | *(pixel_row + 2) = file.ReadByte(); // green |
| 231 | *(pixel_row + 1) = file.ReadByte(); // blue |
| 232 | *pixel_row = file.ReadByte(); // red |
| 233 | pixel_row += 3; |
| 234 | } |
| 235 | /* Padding for 32 bit align */ |
| 236 | file.SkipBytes(pad); |
| 237 | } |
| 238 | return true; |
| 239 | } |
| 240 | |
| 241 | /* |
| 242 | * Reads bitmap headers, and palette (if any) |
no test coverage detected