@@ -27,19 +27,6 @@ freely, subject to the following restrictions:
2727The manual and changelog are in the header file "lodepng.h"
2828Rename this file to lodepng.cpp to use it for C++, or to lodepng.c to use it for C.
2929*/
30- /*
31- This file has been altered from the original. The decodeGeneric function has
32- been split into the public lodepng_decode_chunks and static inflateIdat.
33- decodeGeneric has been reimplemented by calling these 2 functions. A new
34- public lodepng_finish_decode has been added. With the new public functions
35- a user can separate decode of all the chunks, so as to learn all the details
36- of the file, from decompression, and possible conversion, of the image data.
37- Search for msc to see the changes.
38-
39- Additional warning disables have been added. 4267 for MS VC++ and the
40- equivalent -Wshorten-64-to-32 for clang. "32-bit shift implicitly converted
41- to 64 bits" warnings have been fixed by changing 1u constants to 1ull.
42- */
4330
4431#include " lodepng.h"
4532
@@ -5298,8 +5285,8 @@ unsigned lodepng_inspect_chunk(LodePNGState* state, size_t pos,
52985285 return error;
52995286}
53005287
5301- /* extracted from the original decodeGeneric by msc*/
53025288/* read the PNG's chunks, updating the state and accumulating the iDAT chunks*/
5289+ /* extracted from previous version of decodeGeneric*/
53035290unsigned lodepng_decode_chunks (void ** idat_out, size_t * idatsize_out, unsigned * w, unsigned * h,
53045291 LodePNGState* state,
53055292 const unsigned char * in, size_t insize) {
@@ -5480,7 +5467,7 @@ unsigned lodepng_decode_chunks(void** idat_out, size_t* idatsize_out, unsigned*
54805467 return state->error ;
54815468}
54825469
5483- /* extracted from the original decodeGeneric by msc */
5470+ /* extracted from the previous version of decodeGeneric */
54845471static unsigned inflateIdat (unsigned char ** out,
54855472 unsigned char * directOut, size_t directOutSize,
54865473 unsigned w, unsigned h,
@@ -5507,7 +5494,7 @@ static unsigned inflateIdat(unsigned char** out,
55075494 If the decompressed size does not match the prediction, the image must be corrupt.*/
55085495 if (state->info_png .interlace_method == 0 ) {
55095496 unsigned bpp = lodepng_get_bpp (&state->info_png .color );
5510- expected_size = lodepng_get_raw_size_idat (* w, * h, bpp);
5497+ expected_size = lodepng_get_raw_size_idat (w, h, bpp);
55115498 } else {
55125499 unsigned bpp = lodepng_get_bpp (&state->info_png .color );
55135500 /* Adam-7 interlaced: expected size is the sum of the 7 sub-images sizes*/
@@ -5545,7 +5532,6 @@ static unsigned inflateIdat(unsigned char** out,
55455532 return state->error ;
55465533}
55475534
5548- /* added by msc*/
55495535/* finishes decode by inflating the images captured from the idat chunks by lodepng_decode_chunks
55505536and converting them if info_raw differs from info_png.color. A buffer to receive the final
55515537image data is provided as a parameter.
@@ -5585,8 +5571,8 @@ unsigned lodepng_finish_decode(unsigned char* cbuffer, size_t cbufsize,
55855571 return state->error ;
55865572}
55875573
5588- /* reimplemented by msc.*/
55895574/* read a PNG, the result will be in the same color type as the PNG (hence "generic")*/
5575+ /* reimplemented by calling the functions extracted from previous version*/
55905576static void decodeGeneric (unsigned char ** out, unsigned * w, unsigned * h,
55915577 LodePNGState* state,
55925578 const unsigned char * in, size_t insize) {
@@ -7110,7 +7096,6 @@ const char* lodepng_error_text(unsigned code) {
71107096 case 120 : return " invalid cLLI chunk size" ;
71117097 case 121 : return " invalid chunk type name: may only contain [a-zA-Z]" ;
71127098 case 122 : return " invalid chunk type name: third character must be uppercase" ;
7113- // Added for 'msc' changes
71147099 case 123 : return " destination buffer too small" ;
71157100 }
71167101 return " unknown error code" ;
0 commit comments