mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Imported from libpng-1.0.6j.tar
This commit is contained in:
64
pngread.c
64
pngread.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* libpng 1.0.6j - May 4, 2000
|
||||
* 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
|
||||
@@ -86,6 +86,18 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
"Incompatible libpng version in application and library");
|
||||
}
|
||||
|
||||
/* Libpng 1.0.6 was not binary compatible, due to insertion of the
|
||||
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[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; version 1.0.6 was incompatible");
|
||||
}
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||
@@ -116,14 +128,44 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
/* Initialize PNG structure for reading, and allocate any memory needed.
|
||||
This interface is deprecated in favour of the png_create_read_struct(),
|
||||
and it will eventually disappear. */
|
||||
#undef png_read_init
|
||||
void
|
||||
png_read_init(png_structp png_ptr)
|
||||
{
|
||||
/* We only come here via pre-1.0.7-compiled applications */
|
||||
png_read_init_2(png_ptr, "1.0.0", 10000, 10000);
|
||||
}
|
||||
|
||||
void
|
||||
png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
||||
png_size_t png_struct_size, png_size_t png_info_size)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf tmp_jmp; /* to save current jump buffer */
|
||||
#endif
|
||||
|
||||
png_debug(1, "in png_read_init\n");
|
||||
#ifndef PNG_LEGACY_SUPPORTED
|
||||
int i=0;
|
||||
do
|
||||
{
|
||||
if(user_png_ver[i] != png_libpng_ver[i])
|
||||
{
|
||||
png_ptr->error_fn=(png_error_ptr)NULL;
|
||||
png_error(png_ptr,
|
||||
"Application uses deprecated png_read_init() and must be recompiled.");
|
||||
}
|
||||
} while (png_libpng_ver[i++]);
|
||||
#endif
|
||||
|
||||
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_read_init_2\n");
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* save jump buffer and error functions */
|
||||
@@ -138,15 +180,6 @@ png_read_init(png_structp png_ptr)
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
#ifndef PNG_LEGACY_SUPPORTED
|
||||
if(!(png_ptr->mode & PNG_CREATED_READ_STRUCT))
|
||||
{
|
||||
png_ptr->error_fn=NULL;
|
||||
png_error(png_ptr,
|
||||
"Read struct not properly created; use a legacy-supporting libpng.");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||
@@ -168,6 +201,11 @@ png_read_init(png_structp png_ptr)
|
||||
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||
|
||||
png_set_read_fn(png_ptr, NULL, NULL);
|
||||
|
||||
#ifdef PNG_LEGACY_SUPPORTED
|
||||
if (user_png_ver)
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Read the information before the actual image data. This has been
|
||||
@@ -652,7 +690,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
* not called png_set_interlace_handling(), the display_row buffer will
|
||||
* be ignored, so pass NULL to it.
|
||||
*
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6i.
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6j.
|
||||
*/
|
||||
|
||||
void
|
||||
@@ -701,7 +739,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||
* only call this function once. If you desire to have an image for
|
||||
* each pass of a interlaced image, use png_read_rows() instead.
|
||||
*
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6i.
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6j.
|
||||
*/
|
||||
void
|
||||
png_read_image(png_structp png_ptr, png_bytepp image)
|
||||
|
||||
Reference in New Issue
Block a user