/* 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
/* 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)
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;
{
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;
}
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);
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);
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]) /
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);
}
}
}
#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;
#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
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]);
}