MCPcopy Create free account
hub / github.com/IENT/YUView / readColormap

Function readColormap

YUViewLib/src/decoder/decoderTarga.cpp:271–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271void 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
308color_t readRunLengthColor(std::ifstream &file, const Header &header)
309{

Callers 1

readHeaderFunction · 0.85

Calls 5

ColormapClass · 0.85
read16Function · 0.85
rgbaFunction · 0.85
scale_5bits_to_8bitsFunction · 0.85
read8Function · 0.85

Tested by

no test coverage detected