Imported from libpng-1.2.0beta1.tar

This commit is contained in:
Glenn Randers-Pehrson
2001-05-06 05:34:26 -05:00
parent e68f5a361b
commit 1fd5fb33c2
56 changed files with 1093 additions and 826 deletions

View File

@@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file
*
* libpng 1.0.12beta1 - May 14, 2001
* libpng 1.2.0beta1 - May 6, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -444,7 +444,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_debug(1, "in png_create_write_struct\n");
#ifdef PNG_USER_MEM_SUPPORTED
if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
(png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr)) == NULL)
(png_malloc_ptr)malloc_fn)) == NULL)
#else
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
#endif /* PNG_USER_MEM_SUPPORTED */
@@ -452,6 +452,10 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
return ((png_structp)NULL);
}
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
png_init_mmx_flags(png_ptr); /* 1.2.0 addition */
#endif
#ifdef PNG_SETJMP_SUPPORTED
#ifdef USE_FAR_KEYWORD
if (setjmp(jmpbuf))
@@ -489,7 +493,6 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
* only check the first digit.
*/
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
(user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
(user_png_ver[0] == '0' && user_png_ver[2] < '9'))
{
png_error(png_ptr,
@@ -497,17 +500,15 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
}
/* Libpng 1.0.6 was not binary compatible, due to insertion of the
info_ptr->free_me member. Libpng-1.0.1 and earlier were not
compatible due to insertion of the user transform function. Note
to maintainer: this test can be removed from version 1.2.0 and
beyond because the previous test would have already rejected it. */
info_ptr->free_me member. Note to maintainer: this test can be
removed from version 2.0.0 and beyond because the previous test
would have already rejected it. */
if (user_png_ver[0] == '1' && user_png_ver[2] == '0' &&
(user_png_ver[4] < '2' || user_png_ver[4] == '6') &&
user_png_ver[5] == '\0')
if (user_png_ver[4] == '6' && user_png_ver[2] == '0' &&
user_png_ver[0] == '1' && user_png_ver[5] == '\0')
{
png_error(png_ptr,
"Application must be recompiled; versions <= 1.0.6 were incompatible");
"Application must be recompiled; version 1.0.6 was incompatible");
}
}
@@ -532,36 +533,13 @@ void PNGAPI
png_write_init(png_structp png_ptr)
{
/* We only come here via pre-1.0.7-compiled applications */
png_write_init_2(png_ptr, "1.0.0", 0, 0);
png_write_init_2(png_ptr, "1.0.0", 10000, 10000);
}
#undef png_write_init_2
void PNGAPI
png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
png_size_t png_struct_size, png_size_t png_info_size)
{
/* We only come here via pre-1.0.12-compiled applications */
if(sizeof(png_struct) > png_struct_size)
{
png_ptr->error_fn=(png_error_ptr)NULL;
png_error(png_ptr,
"The png struct allocated by the application is too small.");
}
if(sizeof(png_info) > png_info_size)
{
png_ptr->error_fn=(png_error_ptr)NULL;
png_error(png_ptr,
"The info struct allocated by the application is too small.");
}
png_write_init_3(&png_ptr, user_png_ver, png_struct_size);
}
void PNGAPI
png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
png_size_t png_struct_size)
{
png_structp png_ptr=*ptr_ptr;
#ifdef PNG_SETJMP_SUPPORTED
jmp_buf tmp_jmp; /* to save current jump buffer */
#endif
@@ -573,42 +551,45 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
#ifdef PNG_LEGACY_SUPPORTED
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
#else
png_ptr->warning_fn=(png_error_ptr)NULL;
png_warning(png_ptr,
"Application uses deprecated png_write_init() and should be recompiled.");
break;
png_ptr->error_fn=(png_error_ptr)NULL;
png_error(png_ptr,
"Application uses deprecated png_write_init() and must be recompiled.");
#endif
}
} while (png_libpng_ver[i++]);
png_debug(1, "in png_write_init_3\n");
if (sizeof(png_struct) > png_struct_size ||
sizeof(png_info) > png_info_size)
{
png_ptr->error_fn=(png_error_ptr)NULL;
png_error(png_ptr,
"Application and library have different sized structs. Please recompile.");
}
png_debug(1, "in png_write_init_2\n");
#ifdef PNG_SETJMP_SUPPORTED
/* save jump buffer and error functions */
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
#endif
if (sizeof(png_struct) > png_struct_size)
{
png_destroy_struct(png_ptr);
png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
*ptr_ptr = png_ptr;
}
/* reset all variables to 0 */
png_memset(png_ptr, 0, sizeof (png_struct));
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
png_init_mmx_flags(png_ptr); /* 1.2.0 addition */
#endif
#ifdef PNG_SETJMP_SUPPORTED
/* restore jump buffer */
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
#endif
png_set_write_fn(png_ptr, NULL, NULL, NULL);
/* initialize zbuf - compression buffer */
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size);
png_set_write_fn(png_ptr, NULL, NULL, NULL);
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT,
@@ -903,7 +884,6 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
png_infop info_ptr = NULL;
#ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn = NULL;
png_voidp mem_ptr = NULL;
#endif
png_debug(1, "in png_destroy_write_struct\n");
@@ -932,8 +912,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
#endif
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
png_destroy_struct_2((png_voidp)info_ptr, free_fn);
#else
png_destroy_struct((png_voidp)info_ptr);
#endif
@@ -944,8 +923,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
{
png_write_destroy(png_ptr);
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
png_destroy_struct_2((png_voidp)png_ptr, free_fn);
#else
png_destroy_struct((png_voidp)png_ptr);
#endif