X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1f0299c17dc878540bf190c290392db241b425ad..0e32fdb872d413f14da8ce045766f0e2f13e202d:/src/png/pngpread.c diff --git a/src/png/pngpread.c b/src/png/pngpread.c index 897140d9dc..b44651801d 100644 --- a/src/png/pngpread.c +++ b/src/png/pngpread.c @@ -1,16 +1,15 @@ /* pngpread.c - read a png file in push mode * - * libpng 1.0.1 + * libpng 1.0.3 - January 14, 1999 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger - * Copyright (c) 1998, Glenn Randers-Pehrson - * March 15, 1998 + * Copyright (c) 1998, 1999 Glenn Randers-Pehrson */ #define PNG_INTERNAL -#include "../png/png.h" +#include "png.h" #ifdef PNG_PROGRESSIVE_READ_SUPPORTED @@ -78,8 +77,9 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr) /* Read any remaining signature bytes from the stream and compare them with * the correct PNG signature. It is possible that this routine is called - * with bytes already read from the signature, whether because they have been - * checked by the calling application, or from multiple calls to this routine. + * with bytes already read from the signature, either because they have been + * checked by the calling application, or because of multiple calls to this + * routine. */ void png_push_read_sig(png_structp png_ptr, png_infop info_ptr) @@ -92,7 +92,7 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr) num_to_check = png_ptr->buffer_size; } - png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), + png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); png_ptr->sig_bytes += num_to_check; @@ -446,13 +446,13 @@ png_push_save_buffer(png_structp png_ptr) { if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) { - png_size_t i; + png_size_t i,istop; png_bytep sp; png_bytep dp; + istop = png_ptr->save_buffer_size; for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer; - i < png_ptr->save_buffer_size; - i++, sp++, dp++) + i < istop; i++, sp++, dp++) { *dp = *sp; } @@ -466,7 +466,7 @@ png_push_save_buffer(png_structp png_ptr) new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; old_buffer = png_ptr->save_buffer; - png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, + png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, (png_uint_32)new_max); png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); png_free(png_ptr, old_buffer); @@ -630,7 +630,7 @@ png_push_process_row(png_structp png_ptr) png_ptr->row_info.channels = png_ptr->channels; png_ptr->row_info.bit_depth = png_ptr->bit_depth; png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - + png_ptr->row_info.rowbytes = ((png_ptr->row_info.width * (png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3); @@ -781,6 +781,7 @@ png_read_push_finish_row(png_structp png_ptr) png_ptr->pass++; if (png_ptr->pass >= 7) break; + png_ptr->iwidth = (png_ptr->width + png_pass_inc[png_ptr->pass] - 1 - png_pass_start[png_ptr->pass]) / @@ -789,18 +790,15 @@ png_read_push_finish_row(png_structp png_ptr) png_ptr->irowbytes = ((png_ptr->iwidth * png_ptr->pixel_depth + 7) >> 3) + 1; - if (!(png_ptr->transformations & PNG_INTERLACE)) - { - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - if (!(png_ptr->num_rows)) - continue; - } if (png_ptr->transformations & PNG_INTERLACE) break; - } while (png_ptr->iwidth == 0); + + png_ptr->num_rows = (png_ptr->height + + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; + + } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); } } @@ -826,7 +824,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length } #endif - png_ptr->current_text = (png_charp)png_malloc(png_ptr, + png_ptr->current_text = (png_charp)png_malloc(png_ptr, (png_uint_32)(length+1)); png_ptr->current_text[length] = '\0'; png_ptr->current_text_ptr = png_ptr->current_text; @@ -1070,7 +1068,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) #endif /* This function is called when we haven't found a handler for this - * chunk. In the future we will have code here which can handle + * chunk. In the future we will have code here that can handle * user-defined callback functions for unknown chunks before they are * ignored or cause an error. If there isn't a problem with the * chunk itself (ie a bad chunk name or a critical chunk), the chunk @@ -1117,7 +1115,7 @@ void png_progressive_combine_row (png_structp png_ptr, png_bytep old_row, png_bytep new_row) { - if (new_row != NULL) + if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); }