MCPcopy Create free account
hub / github.com/DFHack/dfhack / readChunk_PLTE

Function readChunk_PLTE

depends/lodepng/lodepng.cpp:4349–4367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4347}
4348
4349static unsigned readChunk_PLTE(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength) {
4350 unsigned pos = 0, i;
4351 color->palettesize = chunkLength / 3u;
4352 if(color->palettesize == 0 || color->palettesize > 256) return 38; /*error: palette too small or big*/
4353 lodepng_color_mode_alloc_palette(color);
4354 if(!color->palette && color->palettesize) {
4355 color->palettesize = 0;
4356 return 83; /*alloc fail*/
4357 }
4358
4359 for(i = 0; i != color->palettesize; ++i) {
4360 color->palette[4 * i + 0] = data[pos++]; /*R*/
4361 color->palette[4 * i + 1] = data[pos++]; /*G*/
4362 color->palette[4 * i + 2] = data[pos++]; /*B*/
4363 color->palette[4 * i + 3] = 255; /*alpha*/
4364 }
4365
4366 return 0; /* OK */
4367}
4368
4369static unsigned readChunk_tRNS(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength) {
4370 unsigned i;

Callers 2

lodepng_inspect_chunkFunction · 0.85
decodeGenericFunction · 0.85

Calls 1

Tested by

no test coverage detected