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

Function lodepng_inspect_chunk

depends/lodepng/lodepng.cpp:4704–4754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4702#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
4703
4704unsigned lodepng_inspect_chunk(LodePNGState* state, size_t pos,
4705 const unsigned char* in, size_t insize) {
4706 const unsigned char* chunk = in + pos;
4707 unsigned chunkLength;
4708 const unsigned char* data;
4709 unsigned unhandled = 0;
4710 unsigned error = 0;
4711
4712 if(pos + 4 > insize) return 30;
4713 chunkLength = lodepng_chunk_length(chunk);
4714 if(chunkLength > 2147483647) return 63;
4715 data = lodepng_chunk_data_const(chunk);
4716 if(data + chunkLength + 4 > in + insize) return 30;
4717
4718 if(lodepng_chunk_type_equals(chunk, "PLTE")) {
4719 error = readChunk_PLTE(&state->info_png.color, data, chunkLength);
4720 } else if(lodepng_chunk_type_equals(chunk, "tRNS")) {
4721 error = readChunk_tRNS(&state->info_png.color, data, chunkLength);
4722#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
4723 } else if(lodepng_chunk_type_equals(chunk, "bKGD")) {
4724 error = readChunk_bKGD(&state->info_png, data, chunkLength);
4725 } else if(lodepng_chunk_type_equals(chunk, "tEXt")) {
4726 error = readChunk_tEXt(&state->info_png, data, chunkLength);
4727 } else if(lodepng_chunk_type_equals(chunk, "zTXt")) {
4728 error = readChunk_zTXt(&state->info_png, &state->decoder, data, chunkLength);
4729 } else if(lodepng_chunk_type_equals(chunk, "iTXt")) {
4730 error = readChunk_iTXt(&state->info_png, &state->decoder, data, chunkLength);
4731 } else if(lodepng_chunk_type_equals(chunk, "tIME")) {
4732 error = readChunk_tIME(&state->info_png, data, chunkLength);
4733 } else if(lodepng_chunk_type_equals(chunk, "pHYs")) {
4734 error = readChunk_pHYs(&state->info_png, data, chunkLength);
4735 } else if(lodepng_chunk_type_equals(chunk, "gAMA")) {
4736 error = readChunk_gAMA(&state->info_png, data, chunkLength);
4737 } else if(lodepng_chunk_type_equals(chunk, "cHRM")) {
4738 error = readChunk_cHRM(&state->info_png, data, chunkLength);
4739 } else if(lodepng_chunk_type_equals(chunk, "sRGB")) {
4740 error = readChunk_sRGB(&state->info_png, data, chunkLength);
4741 } else if(lodepng_chunk_type_equals(chunk, "iCCP")) {
4742 error = readChunk_iCCP(&state->info_png, &state->decoder, data, chunkLength);
4743#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
4744 } else {
4745 /* unhandled chunk is ok (is not an error) */
4746 unhandled = 1;
4747 }
4748
4749 if(!error && !unhandled && !state->decoder.ignore_crc) {
4750 if(lodepng_chunk_check_crc(chunk)) return 57; /*invalid CRC*/
4751 }
4752
4753 return error;
4754}
4755
4756/*read a PNG, the result will be in the same color type as the PNG (hence "generic")*/
4757static void decodeGeneric(unsigned char** out, unsigned* w, unsigned* h,

Callers

nothing calls this directly

Calls 15

lodepng_chunk_lengthFunction · 0.85
lodepng_chunk_data_constFunction · 0.85
readChunk_PLTEFunction · 0.85
readChunk_tRNSFunction · 0.85
readChunk_bKGDFunction · 0.85
readChunk_tEXtFunction · 0.85
readChunk_zTXtFunction · 0.85
readChunk_iTXtFunction · 0.85
readChunk_tIMEFunction · 0.85
readChunk_pHYsFunction · 0.85
readChunk_gAMAFunction · 0.85

Tested by

no test coverage detected