This repository has been archived on 2023-11-11. You can view files and clone it, but cannot push or open issues or pull requests.
libpng/png.h

3556 lines
143 KiB
C
Raw Permalink Normal View History

1997-05-16 07:46:07 +00:00
/* png.h - header file for PNG reference library
1998-01-01 13:13:13 +00:00
*
* libpng version 1.2.59, September 28, 2017
*
* Copyright (c) 1998-2017 Glenn Randers-Pehrson
2000-06-04 19:29:29 +00:00
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
1998-01-17 04:06:18 +00:00
*
* This code is released under the libpng license (See LICENSE, below)
*
1999-09-17 17:27:26 +00:00
* Authors and maintainers:
2000-04-02 03:10:05 +00:00
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
2015-11-03 14:28:03 +00:00
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.2.59, September 28, 2017: Glenn
1999-09-17 17:27:26 +00:00
* See also "Contributing Authors", below.
1999-10-14 12:43:10 +00:00
*/
/*
2000-04-02 03:10:05 +00:00
* COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
*
2000-06-04 19:29:29 +00:00
* If you modify libpng you may insert additional notices immediately following
* this sentence.
1999-10-01 19:22:25 +00:00
*
* This code is released under the libpng license.
*
* libpng versions 1.0.7, July 1, 2000, through 1.2.59, September 28, 2017, are
* Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
* derived from libpng-1.0.6, and are distributed according to the same
* disclaimer and license as libpng-1.0.6 with the following individuals
* added to the list of Contributing Authors:
1999-10-01 19:22:25 +00:00
*
2000-06-04 19:29:29 +00:00
* Simon-Pierre Cadieux
* Eric S. Raymond
* Cosmin Truta
2000-06-04 19:29:29 +00:00
* Gilles Vollant
*
2000-07-01 20:37:28 +00:00
* and with the following additions to the disclaimer:
*
* There is no warranty against interference with your enjoyment of the
* library or against infringement. There is no warranty that our
* efforts or the library will fulfill any of your particular purposes
* or needs. This library is provided with all faults, and the entire
* risk of satisfactory quality, performance, accuracy, and effort is with
* the user.
*
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
* libpng-0.96, and are distributed according to the same disclaimer and
* license as libpng-0.96, with the following individuals added to the list
* of Contributing Authors:
2000-06-04 19:29:29 +00:00
*
* Tom Lane
* Glenn Randers-Pehrson
* Willem van Schaik
*
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
* Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
* and are distributed according to the same disclaimer and license as
* libpng-0.88, with the following individuals added to the list of
* Contributing Authors:
1999-10-01 19:22:25 +00:00
*
1998-01-01 13:13:13 +00:00
* John Bowler
* Kevin Bracey
1998-02-07 16:20:57 +00:00
* Sam Bushell
1998-01-01 13:13:13 +00:00
* Magnus Holmgren
* Greg Roelofs
2000-06-04 19:29:29 +00:00
* Tom Tanner
*
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
2000-06-04 19:29:29 +00:00
*
* For the purposes of this copyright and license, "Contributing Authors"
* is defined as the following set of individuals:
*
* Andreas Dilger
* Dave Martindale
1998-01-01 13:13:13 +00:00
* Guy Eric Schalnat
* Paul Schmidt
* Tim Wegner
*
* The PNG Reference Library is supplied "AS IS". The Contributing Authors
* and Group 42, Inc. disclaim all warranties, expressed or implied,
* including, without limitation, the warranties of merchantability and of
* fitness for any purpose. The Contributing Authors and Group 42, Inc.
* assume no liability for direct, indirect, incidental, special, exemplary,
* or consequential damages, which may result from the use of the PNG
* Reference Library, even if advised of the possibility of such damage.
*
* Permission is hereby granted to use, copy, modify, and distribute this
* source code, or portions hereof, for any purpose, without fee, subject
* to the following restrictions:
1999-09-19 11:04:18 +00:00
*
* 1. The origin of this source code must not be misrepresented.
1999-09-19 11:04:18 +00:00
*
* 2. Altered versions must be plainly marked as such and must not
* be misrepresented as being the original source.
1999-09-19 11:04:18 +00:00
*
* 3. This Copyright notice may not be removed or altered from any
* source or altered source distribution.
1998-01-01 13:13:13 +00:00
*
* The Contributing Authors and Group 42, Inc. specifically permit, without
* fee, and encourage the use of this source code as a component to
* supporting the PNG file format in commercial products. If you use this
* source code in a product, acknowledgment is not required but would be
* appreciated.
*
* END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
1998-01-01 13:13:13 +00:00
*/
1995-07-20 07:43:20 +00:00
1999-10-01 19:22:25 +00:00
/*
1999-10-14 12:43:10 +00:00
* A "png_get_copyright" function is available, for convenient use in "about"
* boxes and the like:
1999-12-10 15:43:02 +00:00
*
* printf("%s", png_get_copyright(NULL));
1999-12-10 15:43:02 +00:00
*
1999-10-14 12:43:10 +00:00
* Also, the PNG logo (in PNG format, of course) is supplied in the
2000-07-14 13:15:12 +00:00
* files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
1999-10-14 12:43:10 +00:00
*/
/*
* Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
* a certification mark of the Open Source Initiative. OSI has not addressed
* the additional disclaimers inserted at version 1.0.7.
1999-10-01 19:22:25 +00:00
*/
/*
* The contributing authors would like to thank all those who helped
* with testing, bug fixes, and patience. This wouldn't have been
* possible without all of you.
*
* Thanks to Frank J. T. Wojcik for helping with the documentation.
*/
2015-11-03 14:28:03 +00:00
/* Note about libpng version numbers:
*
* Due to various miscommunications, unforeseen code incompatibilities
* and occasional factors outside the authors' control, version numbering
* on the library has not always been consistent and straightforward.
* The following table summarizes matters since version 0.89c, which was
* the first widely used release:
*
* source png.h png.h shared-lib
* version string int version
* ------- ------ ----- ----------
* 0.89c "1.0 beta 3" 0.89 89 1.0.89
* 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90]
* 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95]
* 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96]
* 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97]
* 0.97c 0.97 97 2.0.97
* 0.98 0.98 98 2.0.98
* 0.99 0.99 98 2.0.99
* 0.99a-m 0.99 99 2.0.99
* 1.00 1.00 100 2.1.0 [100 should be 10000]
* 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000]
* 1.0.1 png.h string is 10001 2.1.0
* 1.0.1a-e identical to the 10002 from here on, the shared library
* 1.0.2 source version) 10002 is 2.V where V is the source code
* 1.0.2a-b 10003 version, except as noted.
* 1.0.3 10003
* 1.0.3a-d 10004
* 1.0.4 10004
* 1.0.4a-f 10005
* 1.0.5 (+ 2 patches) 10005
* 1.0.5a-d 10006
* 1.0.5e-r 10100 (not source compatible)
* 1.0.5s-v 10006 (not binary compatible)
* 1.0.6 (+ 3 patches) 10006 (still binary incompatible)
* 1.0.6d-f 10007 (still binary incompatible)
* 1.0.6g 10007
* 1.0.6h 10007 10.6h (testing xy.z so-numbering)
* 1.0.6i 10007 10.6i
* 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0)
* 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible)
* 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible)
* 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible)
* 1.0.7 1 10007 (still compatible)
* ...
* 1.0.19 10 10019 10.so.0.19[.0]
* ...
* 1.0.68 10 10068 10.so.0.68[.0]
* 1.2.58 13 10258 12.so.0.58[.0]
2015-11-03 14:28:03 +00:00
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
* used for changes in backward compatibility, as it is intended. The
* PNG_LIBPNG_VER macro, which is not used within libpng but is available
* for applications, is an unsigned integer of the form xyyzz corresponding
* to the source version x.y.z (leading zeros in y and z). Beta versions
* were given the previous public release number plus a letter, until
* version 1.0.6j; from then on they were given the upcoming public
* release number plus "betaNN" or "rcNN".
*
* Binary incompatibility exists only when applications make direct access
* to the info_ptr or png_ptr members through png.h, and the compiled
* application is loaded with a different version of the library.
*
* DLLNUM will change each time there are forward or backward changes
* in binary compatibility (e.g., when a new feature is added).
*
* See libpng.txt or libpng.3 for more information. The PNG specification
* is available as a W3C Recommendation and as an ISO Specification,
* <http://www.w3.org/TR/2003/REC-PNG-20031110/
*/
2000-03-21 11:13:06 +00:00
/*
* Y2K compliance in libpng:
* =========================
*
* September 28, 2017
2000-03-21 11:13:06 +00:00
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.2.59 are Y2K compliant. It is my belief that earlier
2000-03-21 11:13:06 +00:00
* versions were also Y2K compliant.
*
* Libpng only has three year fields. One is a 2-byte unsigned integer
* that will hold years up to 65535. The other two hold the date in text
* format, and will hold years up to 9999.
*
* The integer is
* "png_uint_16 year" in png_time_struct.
*
* The strings are
* "png_charp time_buffer" in png_struct and
* "near_time_buffer", which is a local character string in png.c.
*
* There are seven time-related functions:
* png.c: png_convert_to_rfc_1123() in png.c
* (formerly png_convert_to_rfc_1152() in error)
* png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
* png_convert_from_time_t() in pngwrite.c
* png_get_tIME() in pngget.c
* png_handle_tIME() in pngrutil.c, called in pngread.c
* png_set_tIME() in pngset.c
* png_write_tIME() in pngwutil.c, called in pngwrite.c
*
* All handle dates properly in a Y2K environment. The
* png_convert_from_time_t() function calls gmtime() to convert from system
* clock time, which returns (year - 1900), which we properly convert to
* the full 4-digit year. There is a possibility that applications using
* libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
* function, or that they are incorrectly passing only a 2-digit year
* instead of "year - 1900" into the png_convert_from_struct_tm() function,
* but this is not under our control. The libpng documentation has always
* stated that it works with 4-digit years, and the APIs have been
* documented as such.
*
* The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
* integer to hold the year, and can hold years as large as 65535.
*
* zlib, upon which libpng depends, is also Y2K compliant. It contains
* no date-related code.
*
* Glenn Randers-Pehrson
* libpng maintainer
* PNG Development Group
*/
2000-06-24 12:42:42 +00:00
#ifndef PNG_H
#define PNG_H
1995-07-20 07:43:20 +00:00
/* This is not the place to learn how to use libpng. The file libpng.txt
1997-05-16 07:46:07 +00:00
* describes how to use libpng, and the file example.c summarizes it
* with some code on which to build. This file is useful for looking
* at the actual function definitions and structure components.
*/
1995-07-20 07:43:20 +00:00
2000-05-12 11:19:53 +00:00
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.2.59"
2004-07-18 03:45:44 +00:00
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.2.59 - September 28, 2017\n"
2000-05-12 11:19:53 +00:00
2002-02-22 05:14:23 +00:00
#define PNG_LIBPNG_VER_SONUM 0
2004-11-13 04:04:56 +00:00
#define PNG_LIBPNG_VER_DLLNUM 13
2000-05-12 11:19:53 +00:00
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
2001-05-06 10:34:26 +00:00
#define PNG_LIBPNG_VER_MINOR 2
#define PNG_LIBPNG_VER_RELEASE 59
2000-05-12 11:19:53 +00:00
/* This should match the numeric part of the final component of
2009-06-16 03:01:01 +00:00
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
*/
2000-11-23 17:51:42 +00:00
#define PNG_LIBPNG_VER_BUILD 0
2000-11-23 17:51:42 +00:00
2004-11-20 17:18:40 +00:00
/* Release Status */
2000-11-23 17:51:42 +00:00
#define PNG_LIBPNG_BUILD_ALPHA 1
#define PNG_LIBPNG_BUILD_BETA 2
#define PNG_LIBPNG_BUILD_RC 3
#define PNG_LIBPNG_BUILD_STABLE 4
2004-11-20 17:18:40 +00:00
#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
2004-11-20 17:18:40 +00:00
/* Release-Specific Flags */
#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with
PNG_LIBPNG_BUILD_STABLE only */
#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
PNG_LIBPNG_BUILD_SPECIAL */
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
PNG_LIBPNG_BUILD_PRIVATE */
2000-05-12 11:19:53 +00:00
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
2004-11-24 13:50:16 +00:00
2000-05-12 11:19:53 +00:00
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros.
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
* version 1.0.0 was mis-numbered 100 instead of 10000). From
2009-06-16 03:01:01 +00:00
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
*/
#define PNG_LIBPNG_VER 10259 /* 1.2.59 */
2000-05-12 11:19:53 +00:00
#ifndef PNG_VERSION_INFO_ONLY
/* Include the compression library's header */
1995-07-20 07:43:20 +00:00
#include "zlib.h"
2004-11-24 13:50:16 +00:00
#endif
1995-07-20 07:43:20 +00:00
/* Include all user configurable info, including optional assembler routines */
1995-09-26 10:22:39 +00:00
#include "pngconf.h"
1995-07-20 07:43:20 +00:00
2004-11-24 13:50:16 +00:00
/*
* Added at libpng-1.2.8 */
/* Ref MSDN: Private as priority over Special
* VS_FF_PRIVATEBUILD File *was not* built using standard release
* procedures. If this value is given, the StringFileInfo block must
* contain a PrivateBuild string.
2004-11-24 13:50:16 +00:00
*
* VS_FF_SPECIALBUILD File *was* built by the original company using
* standard release procedures but is a variation of the standard
* file of the same version number. If this value is given, the
* StringFileInfo block must contain a SpecialBuild string.
2004-11-24 13:50:16 +00:00
*/
#ifdef PNG_USER_PRIVATEBUILD
2006-02-21 04:09:05 +00:00
# define PNG_LIBPNG_BUILD_TYPE \
(PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)
2004-11-24 13:50:16 +00:00
#else
# ifdef PNG_LIBPNG_SPECIALBUILD
2006-02-21 04:09:05 +00:00
# define PNG_LIBPNG_BUILD_TYPE \
(PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)
2004-11-24 13:50:16 +00:00
# else
2006-02-21 04:09:05 +00:00
# define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)
2004-11-24 13:50:16 +00:00
# endif
#endif
#ifndef PNG_VERSION_INFO_ONLY
1999-09-17 17:27:26 +00:00
/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
1997-05-16 07:46:07 +00:00
/* This file is arranged in several sections. The first section contains
* structure and type definitions. The second section contains the external
* library functions, while the third has the internal library functions,
* which applications aren't expected to use directly.
*/
2001-11-24 20:53:31 +00:00
#ifndef PNG_NO_TYPECAST_NULL
2001-11-07 13:10:08 +00:00
#define int_p_NULL (int *)NULL
#define png_bytep_NULL (png_bytep)NULL
#define png_bytepp_NULL (png_bytepp)NULL
#define png_doublep_NULL (png_doublep)NULL
#define png_error_ptr_NULL (png_error_ptr)NULL
#define png_flush_ptr_NULL (png_flush_ptr)NULL
#define png_free_ptr_NULL (png_free_ptr)NULL
#define png_infopp_NULL (png_infopp)NULL
#define png_malloc_ptr_NULL (png_malloc_ptr)NULL
#define png_read_status_ptr_NULL (png_read_status_ptr)NULL
#define png_rw_ptr_NULL (png_rw_ptr)NULL
#define png_structp_NULL (png_structp)NULL
#define png_uint_16p_NULL (png_uint_16p)NULL
#define png_voidp_NULL (png_voidp)NULL
#define png_write_status_ptr_NULL (png_write_status_ptr)NULL
#else
#define int_p_NULL NULL
#define png_bytep_NULL NULL
#define png_bytepp_NULL NULL
#define png_doublep_NULL NULL
#define png_error_ptr_NULL NULL
#define png_flush_ptr_NULL NULL
#define png_free_ptr_NULL NULL
#define png_infopp_NULL NULL
#define png_malloc_ptr_NULL NULL
#define png_read_status_ptr_NULL NULL
#define png_rw_ptr_NULL NULL
#define png_structp_NULL NULL
#define png_uint_16p_NULL NULL
#define png_voidp_NULL NULL
#define png_write_status_ptr_NULL NULL
#endif
2001-10-27 12:35:13 +00:00
2009-06-16 03:01:01 +00:00
/* Variables declared in png.c - only it needs to define PNG_NO_EXTERN */
1998-01-31 03:45:12 +00:00
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
1997-05-16 07:46:07 +00:00
/* Version information for C files, stored in png.c. This had better match
* the version above.
*/
1999-11-29 05:32:18 +00:00
#ifdef PNG_USE_GLOBAL_ARRAYS
2007-05-18 18:40:59 +00:00
PNG_EXPORT_VAR (PNG_CONST char) png_libpng_ver[18];
/* Need room for 99.99.99beta99z */
1999-11-27 16:22:33 +00:00
#else
#define png_libpng_ver png_get_header_ver(NULL)
#endif
1995-07-20 07:43:20 +00:00
1999-11-29 05:32:18 +00:00
#ifdef PNG_USE_GLOBAL_ARRAYS
1999-11-27 16:22:33 +00:00
/* This was removed in version 1.0.5c */
1997-05-16 07:46:07 +00:00
/* Structures to facilitate easy interlacing. See png.c for more details */
2007-05-18 18:40:59 +00:00
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_start[7];
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_inc[7];
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_ystart[7];
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_yinc[7];
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_mask[7];
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_dsp_mask[7];
2000-02-18 19:48:52 +00:00
/* This isn't currently used. If you need it, see png.c for more details.
2007-05-18 18:40:59 +00:00
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_height[7];
1997-05-16 07:46:07 +00:00
*/
1999-11-27 16:22:33 +00:00
#endif
1998-12-29 17:47:59 +00:00
1997-05-16 07:46:07 +00:00
#endif /* PNG_NO_EXTERN */
/* Three color definitions. The order of the red, green, and blue, (and the
* exact size) is not important, although the size of the fields need to
* be png_byte or png_uint_16 (as defined below).
*/
1995-07-20 07:43:20 +00:00
typedef struct png_color_struct
{
1996-01-16 07:51:56 +00:00
png_byte red;
1995-07-20 07:43:20 +00:00
png_byte green;
png_byte blue;
} png_color;
1997-05-16 07:46:07 +00:00
typedef png_color FAR * png_colorp;
typedef png_color FAR * FAR * png_colorpp;
1995-07-20 07:43:20 +00:00
typedef struct png_color_16_struct
{
1997-05-16 07:46:07 +00:00
png_byte index; /* used for palette files */
png_uint_16 red; /* for use in red green blue files */
1995-07-20 07:43:20 +00:00
png_uint_16 green;
png_uint_16 blue;
1997-05-16 07:46:07 +00:00
png_uint_16 gray; /* for use in grayscale files */
1995-07-20 07:43:20 +00:00
} png_color_16;
1997-05-16 07:46:07 +00:00
typedef png_color_16 FAR * png_color_16p;
typedef png_color_16 FAR * FAR * png_color_16pp;
1995-07-20 07:43:20 +00:00
typedef struct png_color_8_struct
{
1997-05-16 07:46:07 +00:00
png_byte red; /* for use in red green blue files */
1995-07-20 07:43:20 +00:00
png_byte green;
png_byte blue;
1997-05-16 07:46:07 +00:00
png_byte gray; /* for use in grayscale files */
1995-07-20 07:43:20 +00:00
png_byte alpha; /* for alpha channel files */
} png_color_8;
1997-05-16 07:46:07 +00:00
typedef png_color_8 FAR * png_color_8p;
typedef png_color_8 FAR * FAR * png_color_8pp;
1995-07-20 07:43:20 +00:00
1999-12-10 15:43:02 +00:00
/*
* The following two structures are used for the in-core representation
* of sPLT chunks.
*/
2000-03-21 11:13:06 +00:00
typedef struct png_sPLT_entry_struct
1999-12-10 15:43:02 +00:00
{
png_uint_16 red;
png_uint_16 green;
png_uint_16 blue;
png_uint_16 alpha;
png_uint_16 frequency;
2000-03-21 11:13:06 +00:00
} png_sPLT_entry;
typedef png_sPLT_entry FAR * png_sPLT_entryp;
typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;
1999-12-10 15:43:02 +00:00
2000-04-14 19:20:47 +00:00
/* When the depth of the sPLT palette is 8 bits, the color and alpha samples
* occupy the LSB of their respective members, and the MSB of each member
* is zero-filled. The frequency member always occupies the full 16 bits.
*/
2000-03-21 11:13:06 +00:00
typedef struct png_sPLT_struct
1999-12-10 15:43:02 +00:00
{
2000-04-14 19:20:47 +00:00
png_charp name; /* palette name */
png_byte depth; /* depth of palette samples */
png_sPLT_entryp entries; /* palette entries */
png_int_32 nentries; /* number of palette entries */
2000-03-21 11:13:06 +00:00
} png_sPLT_t;
typedef png_sPLT_t FAR * png_sPLT_tp;
typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
1999-12-10 15:43:02 +00:00
#ifdef PNG_TEXT_SUPPORTED
2000-02-05 05:40:16 +00:00
/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
* and whether that contents is compressed or not. The "key" field
2000-04-14 19:20:47 +00:00
* points to a regular zero-terminated C string. The "text", "lang", and
* "lang_key" fields can be regular C strings, empty strings, or NULL pointers.
* However, the * structure returned by png_get_text() will always contain
* regular zero-terminated C strings (possibly empty), never NULL pointers,
* so they can be safely used in printf() and other string-handling functions.
*/
1995-07-20 07:43:20 +00:00
typedef struct png_text_struct
{
2000-04-14 19:20:47 +00:00
int compression; /* compression value:
-1: tEXt, none
0: zTXt, deflate
1: iTXt, none
2: iTXt, deflate */
1997-05-16 07:46:07 +00:00
png_charp key; /* keyword, 1-79 character description of "text" */
2000-04-14 19:20:47 +00:00
png_charp text; /* comment, may be an empty string (ie "")
or a NULL pointer */
2000-02-05 05:40:16 +00:00
png_size_t text_length; /* length of the text string */
2000-05-06 19:09:57 +00:00
#ifdef PNG_iTXt_SUPPORTED
2000-02-05 05:40:16 +00:00
png_size_t itxt_length; /* length of the itxt string */
2000-04-14 19:20:47 +00:00
png_charp lang; /* language code, 0-79 characters
or a NULL pointer */
2000-02-05 05:40:16 +00:00
png_charp lang_key; /* keyword translated UTF-8 string, 0 or more
2000-04-14 19:20:47 +00:00
chars or a NULL pointer */
2000-05-06 19:09:57 +00:00
#endif
1995-07-20 07:43:20 +00:00
} png_text;
1997-05-16 07:46:07 +00:00
typedef png_text FAR * png_textp;
typedef png_text FAR * FAR * png_textpp;
1999-12-10 15:43:02 +00:00
#endif
1997-05-16 07:46:07 +00:00
/* Supported compression types for text in PNG files (tEXt, and zTXt).
2009-06-16 03:01:01 +00:00
* The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed.
*/
1997-05-16 07:46:07 +00:00
#define PNG_TEXT_COMPRESSION_NONE_WR -3
#define PNG_TEXT_COMPRESSION_zTXt_WR -2
#define PNG_TEXT_COMPRESSION_NONE -1
#define PNG_TEXT_COMPRESSION_zTXt 0
2000-02-05 05:40:16 +00:00
#define PNG_ITXT_COMPRESSION_NONE 1
#define PNG_ITXT_COMPRESSION_zTXt 2
#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */
1995-07-20 07:43:20 +00:00
/* png_time is a way to hold the time in an machine independent way.
1998-01-01 13:13:13 +00:00
* Two conversions are provided, both from time_t and struct tm. There
* is no portable way to convert to either of these structures, as far
* as I know. If you know of a portable way, send it to me. As a side
2001-01-12 21:13:06 +00:00
* note - PNG has always been Year 2000 compliant!
1998-01-01 13:13:13 +00:00
*/
1995-07-20 07:43:20 +00:00
typedef struct png_time_struct
{
png_uint_16 year; /* full year, as in, 1995 */
1997-05-16 07:46:07 +00:00
png_byte month; /* month of year, 1 - 12 */
png_byte day; /* day of month, 1 - 31 */
png_byte hour; /* hour of day, 0 - 23 */
png_byte minute; /* minute of hour, 0 - 59 */
png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
1995-07-20 07:43:20 +00:00
} png_time;
1997-05-16 07:46:07 +00:00
typedef png_time FAR * png_timep;
typedef png_time FAR * FAR * png_timepp;
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
1999-12-10 15:43:02 +00:00
/* png_unknown_chunk is a structure to hold queued chunks for which there is
* no specific support. The idea is that we can use this to queue
* up private chunks for output even though the library doesn't actually
* know about their semantics.
*/
2007-10-16 19:27:46 +00:00
#define PNG_CHUNK_NAME_LENGTH 5
1999-12-10 15:43:02 +00:00
typedef struct png_unknown_chunk_t
{
2007-10-16 19:27:46 +00:00
png_byte name[PNG_CHUNK_NAME_LENGTH];
1999-12-10 15:43:02 +00:00
png_byte *data;
png_size_t size;
2000-02-05 05:40:16 +00:00
/* libpng-using applications should NOT directly modify this byte. */
1999-12-10 15:43:02 +00:00
png_byte location; /* mode of operation at read time */
}
png_unknown_chunk;
typedef png_unknown_chunk FAR * png_unknown_chunkp;
typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
#endif
1997-05-16 07:46:07 +00:00
/* png_info is a structure that holds the information in a PNG file so
* that the application can find out the characteristics of the image.
* If you are reading the file, this structure will tell you what is
* in the PNG file. If you are writing the file, fill in the information
* you want to put into the PNG file, then call png_write_info().
* The names chosen should be very close to the PNG specification, so
* consult that document for information about the meaning of each field.
*
* With libpng < 0.95, it was only possible to directly set and read the
* the values in the png_info_struct, which meant that the contents and
* order of the values had to remain fixed. With libpng 0.95 and later,
1998-05-21 14:27:50 +00:00
* however, there are now functions that abstract the contents of
1997-05-16 07:46:07 +00:00
* png_info_struct from the application, so this makes it easier to use
* libpng with dynamic libraries, and even makes it possible to use
* libraries that don't have all of the libpng ancillary chunk-handing
* functionality.
*
* In any case, the order of the parameters in png_info_struct should NOT
* be changed for as long as possible to keep compatibility with applications
* that use the old direct-access method with png_info_struct.
1999-12-10 15:43:02 +00:00
*
* The following members may have allocated storage attached that should be
2000-02-05 05:40:16 +00:00
* cleaned up before the structure is discarded: palette, trans, text,
* pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
2000-12-28 13:50:05 +00:00
* splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
* are automatically freed when the info structure is deallocated, if they were
2000-04-10 00:06:13 +00:00
* allocated internally by libpng. This behavior can be changed by means
* of the png_data_freer() function.
1999-12-10 15:43:02 +00:00
*
2000-12-28 13:50:05 +00:00
* More allocation details: all the chunk-reading functions that
* change these members go through the corresponding png_set_*
* functions. A function to clear these members is available: see
* png_free_data(). The png_set_* functions do not depend on being
* able to point info structure members to any of the storage they are
* passed (they make their own copies), EXCEPT that the png_set_text
* functions use the same storage passed to them in the text_ptr or
* itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
* functions do not make their own copies.
1997-05-16 07:46:07 +00:00
*/
1995-07-20 07:43:20 +00:00
typedef struct png_info_struct
{
/* The following are necessary for every PNG file */
png_uint_32 width PNG_DEPSTRUCT; /* width of image in pixels (from IHDR) */
png_uint_32 height PNG_DEPSTRUCT; /* height of image in pixels (from IHDR) */
png_uint_32 valid PNG_DEPSTRUCT; /* valid chunk data (see PNG_INFO_ below) */
png_uint_32 rowbytes PNG_DEPSTRUCT; /* bytes needed to hold an untransformed row */
png_colorp palette PNG_DEPSTRUCT; /* array of color values (valid & PNG_INFO_PLTE) */
png_uint_16 num_palette PNG_DEPSTRUCT; /* number of color entries in "palette" (PLTE) */
png_uint_16 num_trans PNG_DEPSTRUCT; /* number of transparent palette color (tRNS) */
png_byte bit_depth PNG_DEPSTRUCT; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
png_byte color_type PNG_DEPSTRUCT; /* see PNG_COLOR_TYPE_ below (from IHDR) */
2000-11-10 18:26:19 +00:00
/* The following three should have been named *_method not *_type */
png_byte compression_type PNG_DEPSTRUCT; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
png_byte filter_type PNG_DEPSTRUCT; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
png_byte interlace_type PNG_DEPSTRUCT; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
1997-05-16 07:46:07 +00:00
/* The following is informational only on read, and not used on writes. */
png_byte channels PNG_DEPSTRUCT; /* number of data channels per pixel (1, 2, 3, 4) */
png_byte pixel_depth PNG_DEPSTRUCT; /* number of bits per pixel */
png_byte spare_byte PNG_DEPSTRUCT; /* to align the data, and for future use */
png_byte signature[8] PNG_DEPSTRUCT; /* magic bytes read by libpng from start of file */
1997-05-16 07:46:07 +00:00
/* The rest of the data is optional. If you are reading, check the
* valid field to see if the information in these are valid. If you
* are writing, set the valid field to those chunks you want written,
* and initialize the appropriate fields below.
*/
2000-05-01 14:31:54 +00:00
#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
1997-05-16 07:46:07 +00:00
/* The gAMA chunk describes the gamma characteristics of the system
* on which the image was created, normally in the range [1.0, 2.5].
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
*/
float gamma PNG_DEPSTRUCT; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
1999-12-10 15:43:02 +00:00
#endif
1998-01-01 13:13:13 +00:00
#ifdef PNG_sRGB_SUPPORTED
1998-01-01 13:13:13 +00:00
/* GR-P, 0.96a */
/* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
png_byte srgb_intent PNG_DEPSTRUCT; /* sRGB rendering intent [0, 1, 2, or 3] */
1999-12-10 15:43:02 +00:00
#endif
#ifdef PNG_TEXT_SUPPORTED
1999-12-10 15:43:02 +00:00
/* The tEXt, and zTXt chunks contain human-readable textual data in
* uncompressed, compressed, and optionally compressed forms, respectively.
* The data in "text" is an array of pointers to uncompressed,
* null-terminated C strings. Each chunk has a keyword that describes the
* textual data contained in that chunk. Keywords are not required to be
* unique, and the text string may be empty. Any number of text chunks may
* be in an image.
1997-05-16 07:46:07 +00:00
*/
int num_text PNG_DEPSTRUCT; /* number of comments read/to write */
int max_text PNG_DEPSTRUCT; /* current size of text array */
png_textp text PNG_DEPSTRUCT; /* array of comments read/to write */
1999-12-10 15:43:02 +00:00
#endif /* PNG_TEXT_SUPPORTED */
#ifdef PNG_tIME_SUPPORTED
1997-05-16 07:46:07 +00:00
/* The tIME chunk holds the last time the displayed image data was
* modified. See the png_time struct for the contents of this struct.
*/
png_time mod_time PNG_DEPSTRUCT;
1999-12-10 15:43:02 +00:00
#endif
#ifdef PNG_sBIT_SUPPORTED
1997-05-16 07:46:07 +00:00
/* The sBIT chunk specifies the number of significant high-order bits
* in the pixel data. Values are in the range [1, bit_depth], and are
* only specified for the channels in the pixel data. The contents of
* the low-order bits is not specified. Data is valid if
* (valid & PNG_INFO_sBIT) is non-zero.
*/
png_color_8 sig_bit PNG_DEPSTRUCT; /* significant bits in color channels */
1999-12-10 15:43:02 +00:00
#endif
#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
defined(PNG_READ_BACKGROUND_SUPPORTED)
1997-05-16 07:46:07 +00:00
/* The tRNS chunk supplies transparency data for paletted images and
* other image types that don't need a full alpha channel. There are
* "num_trans" transparency values for a paletted image, stored in the
* same order as the palette colors, starting from index 0. Values
* for the data are in the range [0, 255], ranging from fully transparent
* to fully opaque, respectively. For non-paletted images, there is a
1998-05-21 14:27:50 +00:00
* single color specified that should be treated as fully transparent.
1997-05-16 07:46:07 +00:00
* Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
*/
png_bytep trans PNG_DEPSTRUCT; /* transparent values for paletted image */
png_color_16 trans_values PNG_DEPSTRUCT; /* transparent color for non-palette image */
1999-12-10 15:43:02 +00:00
#endif
#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
1997-05-16 07:46:07 +00:00
/* The bKGD chunk gives the suggested image background color if the
* display program does not have its own background color and the image
* is needs to composited onto a background before display. The colors
* in "background" are normally in the same color space/depth as the
* pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
*/
png_color_16 background PNG_DEPSTRUCT;
1999-12-10 15:43:02 +00:00
#endif
#ifdef PNG_oFFs_SUPPORTED
1997-05-16 07:46:07 +00:00
/* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
* and downwards from the top-left corner of the display, page, or other
* application-specific co-ordinate space. See the PNG_OFFSET_ defines
* below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
*/
png_int_32 x_offset PNG_DEPSTRUCT; /* x offset on page */
png_int_32 y_offset PNG_DEPSTRUCT; /* y offset on page */
png_byte offset_unit_type PNG_DEPSTRUCT; /* offset units type */
1999-12-10 15:43:02 +00:00
#endif