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

Function PNG_adam7Pass

Protocols/AppleImageCodec/picopng.c:903–942  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

901}
902
903void PNG_adam7Pass(UINT8 *out, UINT8 *linen, UINT8 *lineo, const UINT8 *in, UINT32 w,
904 UINT32 passleft, UINT32 passtop, UINT32 spacex, UINT32 spacey, UINT32 passw, UINT32 passh,
905 UINT32 bpp)
906{ // filter and reposition the pixels into the output when the image is Adam7 interlaced. This
907 // function can only do it after the full image is already decoded. The out buffer must have
908 // the correct allocated memory size already.
909 UINT32 bytewidth,linelength,y;
910
911 if (passw == 0)
912 return;
913 bytewidth = (bpp + 7) / 8;
914 linelength = 1 + ((bpp * passw + 7) / 8);
915 for (y = 0; y < passh; y++)
916 {
917 UINT32 i, b;
918 UINT8 filterType = in[y * linelength], *prevline = (y == 0) ? 0 : lineo;
919 UINT8 *temp;
920 PNG_unFilterScanline(linen, &in[y * linelength + 1], prevline, bytewidth, filterType,
921 (w * bpp + 7) / 8);
922 if (PNG_error)
923 return;
924 if (bpp >= 8)
925 for (i = 0; i < passw; i++)
926 for (b = 0; b < bytewidth; b++) // b = current byte of this pixel
927 out[bytewidth * w * (passtop + spacey * y) + bytewidth *
928 (passleft + spacex * i) + b] = linen[bytewidth * i + b];
929 else
930 for (i = 0; i < passw; i++)
931 {
932 UINT32 obp, bp;
933 obp = bpp * w * (passtop + spacey * y) + bpp * (passleft + spacex * i);
934 bp = i * bpp;
935 for (b = 0; b < bpp; b++)
936 PNG_setBitOfReversedStream(&obp, out, PNG_readBitFromReversedStream(&bp, linen));
937 }
938 temp = linen;
939 linen = lineo;
940 lineo = temp; // swap the two buffer pointers "line old" and "line new"
941 }
942}
943
944INT32 PNG_convert(const PNG_INFO *info, VECTOR_8 *out, const UINT8 *in)
945{ // converts from any color type to 32-bit. return value = LodePNG error code

Callers 1

PNG_decodeFunction · 0.85

Calls 3

PNG_unFilterScanlineFunction · 0.85

Tested by

no test coverage detected