MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / PNG_readPngHeader

Function PNG_readPngHeader

Protocols/AppleImageCodec/picopng.c:794–834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

792}
793
794void PNG_readPngHeader(PNG_INFO *info, const UINT8 *in, UINT32 inlength)
795{ // read the information from the header and store it in the Info
796 if (inlength < 29) {
797 PNG_error = 27; // error: the data length is smaller than the length of the header
798 return;
799 }
800 if (*(UINT64 *) in != PNG_SIGNATURE) {
801 PNG_error = 28; // no PNG signature
802 return;
803 }
804 if (*(UINT32 *) &in[12] != CHUNK_IHDR) {
805 PNG_error = 29; // error: it doesn't start with a IHDR chunk!
806 return;
807 }
808 info->width = PNG_read32bitInt(&in[16]);
809 info->height = PNG_read32bitInt(&in[20]);
810 info->bitDepth = in[24];
811 info->colorType = in[25];
812 info->compressionMethod = in[26];
813 if (in[26] != 0) {
814 PNG_error = 32; // error: only compression method 0 is allowed in the specification
815 DBG("error: only compression method 0 is allowed in the specification\n");
816 return;
817 }
818 info->filterMethod = in[27];
819 if (in[27] != 0) {
820 PNG_error = 33; // error: only filter method 0 is allowed in the specification
821 DBG("error: only filter method 0 is allowed in the specification\n");
822 return;
823 }
824 info->interlaceMethod = in[28];
825 if (in[28] > 1) {
826 PNG_error = 34; // error: only interlace methods 0 and 1 exist in the specification
827 DBG("error: only interlace method 0 and 1 exist in the specification\n");
828 return;
829 }
830 PNG_error = PNG_checkColorValidity(info->colorType, info->bitDepth);
831 if (PNG_error) {
832 DBG("error: checkColorValidity =%d\n", PNG_error);
833 }
834}
835
836INT32 PNG_paethPredictor(INT32 a, INT32 b, INT32 c) // Paeth predicter, used by PNG filter type 4
837{

Callers 1

PNG_decodeFunction · 0.85

Calls 2

PNG_read32bitIntFunction · 0.85
PNG_checkColorValidityFunction · 0.85

Tested by

no test coverage detected