mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 00:56:40 -04:00
Fix PNG images which had some garbage data in IDAT chunk after compressed image data not loading (Thanks goodly)
This commit is contained in:
parent
60f0668b5a
commit
bae2b9931c
14
src/Bitmap.c
14
src/Bitmap.c
@ -507,13 +507,17 @@ cc_result Png_Decode(Bitmap* bmp, struct Stream* stream) {
|
||||
rowExpander(bmp->Width, palette, &scanline[1], Bitmap_GetRow(bmp, curY));
|
||||
}
|
||||
}
|
||||
|
||||
if (curY == bmp->Height) {
|
||||
if (!BitmapCol_A(trnsCol)) ComputeTransparency(bmp, trnsCol);
|
||||
return 0;
|
||||
}
|
||||
} break;
|
||||
|
||||
case PNG_FourCC('I','E','N','D'): {
|
||||
if (dataSize) return PNG_ERR_INVALID_END_SIZE;
|
||||
if (!BitmapCol_A(trnsCol)) ComputeTransparency(bmp, trnsCol);
|
||||
return bmp->Scan0 ? 0 : PNG_ERR_NO_DATA;
|
||||
} break;
|
||||
case PNG_FourCC('I','E','N','D'):
|
||||
/* Reading all image data should be handled by above if in the IDAT chunk */
|
||||
/* If we reached here, it means not all of the image data was read */
|
||||
return PNG_ERR_REACHED_IEND;
|
||||
|
||||
default:
|
||||
if ((res = stream->Skip(stream, dataSize))) return res;
|
||||
|
@ -27,7 +27,7 @@ enum ERRORS_ALL {
|
||||
/* PNG image decoding errors */
|
||||
PNG_ERR_INVALID_SIG, PNG_ERR_INVALID_HDR_SIZE, PNG_ERR_TOO_WIDE, PNG_ERR_TOO_TALL,
|
||||
PNG_ERR_INVALID_COL_BPP, PNG_ERR_COMP_METHOD, PNG_ERR_FILTER, PNG_ERR_INTERLACED,
|
||||
PNG_ERR_PAL_SIZE, PNG_ERR_TRANS_COUNT, PNG_ERR_TRANS_INVALID, PNG_ERR_INVALID_END_SIZE, PNG_ERR_NO_DATA,
|
||||
PNG_ERR_PAL_SIZE, PNG_ERR_TRANS_COUNT, PNG_ERR_TRANS_INVALID, PNG_ERR_REACHED_IEND, PNG_ERR_NO_DATA,
|
||||
PNG_ERR_INVALID_SCANLINE,
|
||||
/* ZIP archive decoding errors */
|
||||
ZIP_ERR_TOO_MANY_ENTRIES, ZIP_ERR_SEEK_END_OF_CENTRAL_DIR, ZIP_ERR_NO_END_OF_CENTRAL_DIR,
|
||||
|
@ -110,7 +110,7 @@ static const char* Logger_GetCCErrorDesc(cc_result res) {
|
||||
case PNG_ERR_PAL_SIZE: return "Invalid size of palette data";
|
||||
case PNG_ERR_TRANS_COUNT: return "Invalid number of transparency entries";
|
||||
case PNG_ERR_TRANS_INVALID: return "Transparency invalid for color type";
|
||||
case PNG_ERR_INVALID_END_SIZE: return "Non-empty IEND chunk";
|
||||
case PNG_ERR_REACHED_IEND: return "Incomplete PNG image data";
|
||||
case PNG_ERR_NO_DATA: return "No image in PNG";
|
||||
case PNG_ERR_INVALID_SCANLINE: return "Invalid PNG scanline type";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user