/* pngwrite.c - general routines to write a PNG file
*
- * libpng 1.2.5rc3 - September 18, 2002
+ * libpng 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/
up++)
{
int keep=png_handle_as_unknown(png_ptr, up->name);
- if (keep != HANDLE_CHUNK_NEVER &&
- up->location && (!(up->location & PNG_HAVE_PLTE)) &&
- ((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS ||
+ if (keep != PNG_HANDLE_CHUNK_NEVER &&
+ up->location && !(up->location & PNG_HAVE_PLTE) &&
+ !(up->location & PNG_HAVE_IDAT) &&
+ ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
{
png_write_chunk(png_ptr, up->name, up->data, up->size);
up++)
{
int keep=png_handle_as_unknown(png_ptr, up->name);
- if (keep != HANDLE_CHUNK_NEVER &&
+ if (keep != PNG_HANDLE_CHUNK_NEVER &&
up->location && (up->location & PNG_HAVE_PLTE) &&
!(up->location & PNG_HAVE_IDAT) &&
- ((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS ||
+ ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
{
png_write_chunk(png_ptr, up->name, up->data, up->size);
up++)
{
int keep=png_handle_as_unknown(png_ptr, up->name);
- if (keep != HANDLE_CHUNK_NEVER &&
+ if (keep != PNG_HANDLE_CHUNK_NEVER &&
up->location && (up->location & PNG_AFTER_IDAT) &&
- ((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS ||
+ ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
{
png_write_chunk(png_ptr, up->name, up->data, up->size);
#endif
#endif /* PNG_1_0_X */
+ /* added at libpng-1.2.6 */
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+ png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
+ png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
+#endif
+
#ifdef PNG_SETJMP_SUPPORTED
#ifdef USE_FAR_KEYWORD
if (setjmp(jmpbuf))
return (NULL);
}
#ifdef USE_FAR_KEYWORD
- png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
+ png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
#endif
#endif
#ifdef USE_FAR_KEYWORD
if (setjmp(jmpbuf))
PNG_ABORT();
- png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
+ png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
#else
if (setjmp(png_ptr->jmpbuf))
PNG_ABORT();
{
/* We only come here via pre-1.0.12-compiled applications */
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
- if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size)
+ if(png_sizeof(png_struct) > png_struct_size ||
+ png_sizeof(png_info) > png_info_size)
{
char msg[80];
png_ptr->warning_fn=NULL;
png_warning(png_ptr, msg);
}
#endif
- if(sizeof(png_struct) > png_struct_size)
+ if(png_sizeof(png_struct) > png_struct_size)
{
png_ptr->error_fn=NULL;
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_error(png_ptr,
"The png struct allocated by the application for writing is too small.");
}
- if(sizeof(png_info) > png_info_size)
+ if(png_sizeof(png_info) > png_info_size)
{
png_ptr->error_fn=NULL;
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
#ifdef PNG_SETJMP_SUPPORTED
/* save jump buffer and error functions */
- png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
+ png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
#endif
- if (sizeof(png_struct) > png_struct_size)
+ if (png_sizeof(png_struct) > png_struct_size)
{
png_destroy_struct(png_ptr);
png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
}
/* reset all variables to 0 */
- png_memset(png_ptr, 0, sizeof (png_struct));
+ png_memset(png_ptr, 0, png_sizeof (png_struct));
+
+ /* added at libpng-1.2.6 */
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+ png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
+ png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
+#endif
#if !defined(PNG_1_0_X)
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
#ifdef PNG_SETJMP_SUPPORTED
/* restore jump buffer */
- png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
+ png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
#endif
png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL,
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
png_ptr->row_info.channels);
- png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
- (png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
+ png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
+ png_ptr->row_info.width);
png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type);
png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width);
#ifdef PNG_SETJMP_SUPPORTED
/* reset structure */
- png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
+ png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
#endif
error_fn = png_ptr->error_fn;
free_fn = png_ptr->free_fn;
#endif
- png_memset(png_ptr, 0, sizeof (png_struct));
+ png_memset(png_ptr, 0, png_sizeof (png_struct));
png_ptr->error_fn = error_fn;
png_ptr->warning_fn = warning_fn;
#endif
#ifdef PNG_SETJMP_SUPPORTED
- png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
+ png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
#endif
}
if (png_ptr->prev_filters == NULL)
{
png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
- (png_uint_32)(sizeof(png_byte) * num_weights));
+ (png_uint_32)(png_sizeof(png_byte) * num_weights));
/* To make sure that the weighting starts out fairly */
for (i = 0; i < num_weights; i++)
if (png_ptr->filter_weights == NULL)
{
png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,
- (png_uint_32)(sizeof(png_uint_16) * num_weights));
+ (png_uint_32)(png_sizeof(png_uint_16) * num_weights));
png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,
- (png_uint_32)(sizeof(png_uint_16) * num_weights));
+ (png_uint_32)(png_sizeof(png_uint_16) * num_weights));
for (i = 0; i < num_weights; i++)
{
png_ptr->inv_filter_weights[i] =
if (png_ptr->filter_costs == NULL)
{
png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,
- (png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
+ (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,
- (png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
+ (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
{