mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Imported from pngcrush-1.3.1.tar
This commit is contained in:
63
png.c
63
png.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* libpng version 1.0.5j - December 21, 1999
|
||||
* libpng version 1.0.5k - December 27, 1999
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#ifdef PNG_USE_GLOBAL_ARRAYS
|
||||
/* png_libpng_ver was changed to a function in version 1.0.5c */
|
||||
char png_libpng_ver[12] = "1.0.5j";
|
||||
char png_libpng_ver[12] = "1.0.5k";
|
||||
|
||||
/* png_sig was changed to a function in version 1.0.5c */
|
||||
/* Place to hold the signature string for a PNG file. */
|
||||
@@ -289,6 +289,21 @@ png_free_text(png_structp png_ptr, png_infop info_ptr, int num)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_tRNS_SUPPORTED)
|
||||
/* free any tRNS entry */
|
||||
void
|
||||
png_free_tRNS(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
if (info_ptr->valid & PNG_INFO_tRNS)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->trans);
|
||||
info_ptr->valid &= ~PNG_INFO_tRNS;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sCAL_SUPPORTED)
|
||||
/* free any sCAL entry */
|
||||
void
|
||||
@@ -298,7 +313,7 @@ png_free_sCAL(png_structp png_ptr, png_infop info_ptr)
|
||||
return;
|
||||
if (info_ptr->valid & PNG_INFO_sCAL)
|
||||
{
|
||||
#if defined(PNG_FIXED_POINT_SUPPORTED)&& !defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_free(png_ptr, info_ptr->scal_s_width);
|
||||
png_free(png_ptr, info_ptr->scal_s_height);
|
||||
#else
|
||||
@@ -405,6 +420,17 @@ png_free_unknown_chunks(png_structp png_ptr, png_infop info_ptr, int num)
|
||||
info_ptr->unknown_chunks_num = 0;
|
||||
}
|
||||
}
|
||||
void
|
||||
png_free_chunk_list(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
if (png_ptr->num_chunk_list)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->num_chunk_list=0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_hIST_SUPPORTED)
|
||||
@@ -433,6 +459,9 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_READ_TEXT_SUPPORTED)
|
||||
png_free_text(png_ptr, info_ptr, -1);
|
||||
#endif
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||
png_free_tRNS(png_ptr, info_ptr);
|
||||
#endif
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
png_free_sCAL(png_ptr, info_ptr);
|
||||
#endif
|
||||
@@ -447,6 +476,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
||||
#endif
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_free_unknown_chunks(png_ptr, info_ptr, -1);
|
||||
png_free_chunk_list(png_ptr);
|
||||
#endif
|
||||
#if defined(PNG_hIST_SUPPORTED)
|
||||
png_free_hIST(png_ptr, info_ptr);
|
||||
@@ -528,7 +558,7 @@ png_charp
|
||||
png_get_copyright(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
|
||||
return ("\n libpng version 1.0.5j - December 21, 1999\n\
|
||||
return ("\n libpng version 1.0.5k - December 27, 1999\n\
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
|
||||
Copyright (c) 1996, 1997 Andreas Dilger\n\
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson\n");
|
||||
@@ -546,8 +576,8 @@ png_get_libpng_ver(png_structp png_ptr)
|
||||
{
|
||||
/* Version of *.c files used when building libpng */
|
||||
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
||||
return("1.0.5j");
|
||||
return("1.0.5j");
|
||||
return("1.0.5k");
|
||||
return("1.0.5k");
|
||||
}
|
||||
|
||||
png_charp
|
||||
@@ -571,8 +601,25 @@ png_get_header_version(png_structp png_ptr)
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
void
|
||||
png_check_version
|
||||
(version_1_0_5j png_h_is_not_version_1_0_5j)
|
||||
(version_1_0_5k png_h_is_not_version_1_0_5k)
|
||||
{
|
||||
if(png_h_is_not_version_1_0_5j == NULL)
|
||||
if(png_h_is_not_version_1_0_5k == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
int
|
||||
png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
|
||||
{
|
||||
/* check chunk_name and return "keep" value if it's on the list, else 0 */
|
||||
int i;
|
||||
png_bytep p;
|
||||
if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0)
|
||||
return 0;
|
||||
p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5;
|
||||
for (i = png_ptr->num_chunk_list; i; i--, p-=5)
|
||||
if (!png_memcmp(chunk_name, p, 4))
|
||||
return ((int)*(p+4));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user