| 269 | } |
| 270 | |
| 271 | void readColormap(std::ifstream &file, Header &header) |
| 272 | { |
| 273 | header.colormap = Colormap(header.colormapLength); |
| 274 | |
| 275 | for (int i = 0; i < header.colormapLength; ++i) |
| 276 | { |
| 277 | switch (header.colormapDepth) |
| 278 | { |
| 279 | |
| 280 | case 15: |
| 281 | case 16: |
| 282 | { |
| 283 | const uint16_t c = read16(file); |
| 284 | header.colormap[i] = rgba(scale_5bits_to_8bits((c >> 10) & 0x1F), |
| 285 | scale_5bits_to_8bits((c >> 5) & 0x1F), |
| 286 | scale_5bits_to_8bits(c & 0x1F)); |
| 287 | break; |
| 288 | } |
| 289 | |
| 290 | case 24: |
| 291 | case 32: |
| 292 | { |
| 293 | const uint8_t b = read8(file); |
| 294 | const uint8_t g = read8(file); |
| 295 | const uint8_t r = read8(file); |
| 296 | uint8_t a; |
| 297 | if (header.colormapDepth == 32) |
| 298 | a = read8(file); |
| 299 | else |
| 300 | a = 255; |
| 301 | header.colormap[i] = rgba(r, g, b, a); |
| 302 | break; |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | color_t readRunLengthColor(std::ifstream &file, const Header &header) |
| 309 | { |
no test coverage detected