blob: ee9ab525399772e857d8abf7dbc3c8e0d3b13f40 [file] [log] [blame]
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06001/* pngconf.h - machine configurable file for libpng
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06002 *
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -05003 * libpng 1.2.3rc5 - May 11, 2002
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06004 * For conditions of distribution and use, see copyright notice in png.h
Glenn Randers-Pehrsonc6de22d2002-02-23 18:55:25 -06005 * Copyright (c) 1998-2002 Glenn Randers-Pehrson
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05006 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06008 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05009
10/* Any machine specific code is near the front of this file, so if you
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060011 * are configuring libpng for a machine, you may want to read the section
12 * starting here down to where it starts to typedef png_color, png_text,
13 * and png_info.
14 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050015
16#ifndef PNGCONF_H
17#define PNGCONF_H
18
Andreas Dilger02ad0ef1997-01-17 01:34:35 -060019/* This is the size of the compression buffer, and thus the size of
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060020 * an IDAT chunk. Make this whatever size you feel is best for your
21 * machine. One of these will be allocated per png_struct. When this
22 * is full, it writes the data to the disk, and does some other
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -060023 * calculations. Making this an extremely small size will slow
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060024 * the library down, but you may want to experiment to determine
25 * where it becomes significant, if you are concerned with memory
26 * usage. Note that zlib allocates at least 32Kb also. For readers,
27 * this describes the size of the buffer available to read the data in.
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060028 * Unless this gets smaller than the size of a row (compressed),
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060029 * it should not make much difference how big this is.
30 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050031
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -060032#ifndef PNG_ZBUF_SIZE
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -060033# define PNG_ZBUF_SIZE 8192
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -060034#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -050035
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -060036/* Enable if you want a write-only libpng */
37
38#ifndef PNG_NO_READ_SUPPORTED
39# define PNG_READ_SUPPORTED
40#endif
41
42/* Enable if you want a read-only libpng */
43
44#ifndef PNG_NO_WRITE_SUPPORTED
45# define PNG_WRITE_SUPPORTED
46#endif
47
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -050048/* Enabled by default in 1.2.0. You can disable this if you don't need to
49 support PNGs that are embedded in MNG datastreams */
Glenn Randers-Pehrson377657d2002-03-08 01:31:27 -060050#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES)
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -060051# ifndef PNG_MNG_FEATURES_SUPPORTED
52# define PNG_MNG_FEATURES_SUPPORTED
53# endif
54#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -060055
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -060056#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -060057# ifndef PNG_FLOATING_POINT_SUPPORTED
58# define PNG_FLOATING_POINT_SUPPORTED
59# endif
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -050060#endif
61
Andreas Dilger47a0c421997-05-16 02:46:07 -050062/* If you are running on a machine where you cannot allocate more
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060063 * than 64K of memory at once, uncomment this. While libpng will not
64 * normally need that much memory in a chunk (unless you load up a very
65 * large file), zlib needs to know how big of a chunk it can use, and
66 * libpng thus makes sure to check any memory allocation to verify it
67 * will fit into memory.
Andreas Dilger47a0c421997-05-16 02:46:07 -050068#define PNG_MAX_MALLOC_64K
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060069 */
Andreas Dilger47a0c421997-05-16 02:46:07 -050070#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -060071# define PNG_MAX_MALLOC_64K
Guy Schalnat51f0eb41995-09-26 05:22:39 -050072#endif
73
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -050074/* Special munging to support doing things the 'cygwin' way:
75 * 'Normal' png-on-win32 defines/defaults:
76 * PNG_BUILD_DLL -- building dll
77 * PNG_USE_DLL -- building an application, linking to dll
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -060078 * (no define) -- building static library, or building an
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -050079 * application and linking to the static lib
80 * 'Cygwin' defines/defaults:
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050081 * PNG_BUILD_DLL -- (ignored) building the dll
82 * (no define) -- (ignored) building an application, linking to the dll
83 * PNG_STATIC -- (ignored) building the static lib, or building an
84 * application that links to the static lib.
85 * ALL_STATIC -- (ignored) building various static libs, or building an
86 * application that links to the static libs.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -050087 * Thus,
88 * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
89 * this bit of #ifdefs will define the 'correct' config variables based on
90 * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but
91 * unnecessary.
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -050092 *
93 * Also, the precedence order is:
94 * ALL_STATIC (since we can't #undef something outside our namespace)
95 * PNG_BUILD_DLL
96 * PNG_STATIC
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050097 * (nothing) == PNG_USE_DLL
98 *
99 * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
100 * of auto-import in binutils, we no longer need to worry about
101 * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore,
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500102 * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
103 * to __declspec() stuff. However, we DO need to worry about
104 * PNG_BUILD_DLL and PNG_STATIC because those change some defaults
105 * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500106 */
107#if defined(__CYGWIN__)
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500108# if defined(ALL_STATIC)
109# if defined(PNG_BUILD_DLL)
110# undef PNG_BUILD_DLL
111# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500112# if defined(PNG_USE_DLL)
113# undef PNG_USE_DLL
114# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500115# if defined(PNG_DLL)
116# undef PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500117# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500118# if !defined(PNG_STATIC)
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -0600119# define PNG_STATIC
120# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500121# else
122# if defined (PNG_BUILD_DLL)
123# if defined(PNG_STATIC)
124# undef PNG_STATIC
125# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500126# if defined(PNG_USE_DLL)
127# undef PNG_USE_DLL
128# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500129# if !defined(PNG_DLL)
130# define PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500131# endif
132# else
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500133# if defined(PNG_STATIC)
134# if defined(PNG_USE_DLL)
135# undef PNG_USE_DLL
136# endif
137# if defined(PNG_DLL)
138# undef PNG_DLL
139# endif
140# else
141# if !defined(PNG_USE_DLL)
142# define PNG_USE_DLL
143# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500144# if !defined(PNG_DLL)
145# define PNG_DLL
146# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500147# endif
148# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500149# endif
150#endif
151
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500152/* This protects us against compilers that run on a windowing system
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600153 * and thus don't have or would rather us not use the stdio types:
154 * stdin, stdout, and stderr. The only one currently used is stderr
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600155 * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will
156 * prevent these from being compiled and used. #defining PNG_NO_STDIO
157 * will also prevent these, plus will prevent the entire set of stdio
158 * macros and functions (FILE *, printf, etc.) from being compiled and used,
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500159 * unless (PNG_DEBUG > 0) has been #defined.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600160 *
161 * #define PNG_NO_CONSOLE_IO
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600162 * #define PNG_NO_STDIO
163 */
Guy Schalnat6d764711995-12-19 03:22:19 -0600164
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500165#if defined(_WIN32_WCE)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600166# include <windows.h>
167 /* Console I/O functions are not supported on WindowsCE */
168# define PNG_NO_CONSOLE_IO
169# ifdef PNG_DEBUG
170# undef PNG_DEBUG
171# endif
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500172#endif
173
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -0500174#ifdef PNG_BUILD_DLL
175# ifndef PNG_CONSOLE_IO_SUPPORTED
176# ifndef PNG_NO_CONSOLE_IO
177# define PNG_NO_CONSOLE_IO
178# endif
179# endif
180#endif
181
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600182# ifdef PNG_NO_STDIO
183# ifndef PNG_NO_CONSOLE_IO
184# define PNG_NO_CONSOLE_IO
185# endif
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500186# ifdef PNG_DEBUG
187# if (PNG_DEBUG > 0)
188# include <stdio.h>
189# endif
190# endif
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600191# else
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500192# if !defined(_WIN32_WCE)
193/* "stdio.h" functions are not supported on WindowsCE */
194# include <stdio.h>
195# endif
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600196# endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600197
198/* This macro protects us against machines that don't have function
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600199 * prototypes (ie K&R style headers). If your compiler does not handle
200 * function prototypes, define this macro and use the included ansi2knr.
201 * I've always been able to use _NO_PROTO as the indicator, but you may
202 * need to drag the empty declaration out in front of here, or change the
203 * ifdef to suit your own needs.
204 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500205#ifndef PNGARG
206
Andreas Dilger47a0c421997-05-16 02:46:07 -0500207#ifdef OF /* zlib prototype munger */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600208# define PNGARG(arglist) OF(arglist)
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500209#else
210
211#ifdef _NO_PROTO
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600212# define PNGARG(arglist) ()
Glenn Randers-Pehrson5cded0b2001-11-07 07:10:08 -0600213# ifndef PNG_TYPECAST_NULL
214# define PNG_TYPECAST_NULL
215# endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500216#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600217# define PNGARG(arglist) arglist
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500218#endif /* _NO_PROTO */
219
220#endif /* OF */
221
222#endif /* PNGARG */
223
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600224/* Try to determine if we are compiling on a Mac. Note that testing for
225 * just __MWERKS__ is not good enough, because the Codewarrior is now used
226 * on non-Mac platforms.
227 */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600228#ifndef MACOS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600229# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
230 defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
231# define MACOS
232# endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600233#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600234
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500235/* enough people need this for various reasons to include it here */
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500236#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600237# include <sys/types.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500238#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600239
Glenn Randers-Pehrsonb1828932001-06-23 08:03:17 -0500240#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600241# define PNG_SETJMP_SUPPORTED
242#endif
243
244#ifdef PNG_SETJMP_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -0500245/* This is an attempt to force a single setjmp behaviour on Linux. If
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600246 * the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
247 */
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500248
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600249# ifdef __linux__
250# ifdef _BSD_SOURCE
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500251# define PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600252# undef _BSD_SOURCE
253# endif
254# ifdef _SETJMP_H
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500255 __png.h__ already includes setjmp.h;
256 __dont__ include it again.;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600257# endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600258# endif /* __linux__ */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500259
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600260 /* include setjmp.h for error handling */
261# include <setjmp.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500262
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600263# ifdef __linux__
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500264# ifdef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600265# define _BSD_SOURCE
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500266# undef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600267# endif
268# endif /* __linux__ */
269#endif /* PNG_SETJMP_SUPPORTED */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600270
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500271#ifdef BSD
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600272# include <strings.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500273#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600274# include <string.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500275#endif
276
Andreas Dilger47a0c421997-05-16 02:46:07 -0500277/* Other defines for things like memory and the like can go here. */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500278#ifdef PNG_INTERNAL
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600279
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500280#include <stdlib.h>
Andreas Dilger47a0c421997-05-16 02:46:07 -0500281
282/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which
283 * aren't usually used outside the library (as far as I know), so it is
284 * debatable if they should be exported at all. In the future, when it is
285 * possible to have run-time registry of chunk-handling functions, some of
286 * these will be made available again.
287#define PNG_EXTERN extern
288 */
289#define PNG_EXTERN
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500290
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600291/* Other defines specific to compilers can go here. Try to keep
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600292 * them inside an appropriate ifdef/endif pair for portability.
293 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500294
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500295#if defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600296# if defined(MACOS)
297 /* We need to check that <math.h> hasn't already been included earlier
298 * as it seems it doesn't agree with <fp.h>, yet we should really use
299 * <fp.h> if possible.
300 */
301# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
302# include <fp.h>
303# endif
304# else
305# include <math.h>
306# endif
307# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
308 /* Amiga SAS/C: We must include builtin FPU functions when compiling using
309 * MATH=68881
310 */
311# include <m68881.h>
312# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600313#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600314
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600315/* Codewarrior on NT has linking problems without this. */
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500316#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600317# define PNG_ALWAYS_EXTERN
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600318#endif
319
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600320/* For some reason, Borland C++ defines memcmp, etc. in mem.h, not
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600321 * stdlib.h like it should (I think). Or perhaps this is a C++
322 * "feature"?
323 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500324#ifdef __TURBOC__
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600325# include <mem.h>
326# include "alloc.h"
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500327#endif
328
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500329#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \
330 defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__))
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600331# include <malloc.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500332#endif
333
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600334/* This controls how fine the dithering gets. As this allocates
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600335 * a largish chunk of memory (32K), those who are not as concerned
336 * with dithering quality can decrease some or all of these.
337 */
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600338#ifndef PNG_DITHER_RED_BITS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600339# define PNG_DITHER_RED_BITS 5
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600340#endif
341#ifndef PNG_DITHER_GREEN_BITS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600342# define PNG_DITHER_GREEN_BITS 5
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600343#endif
344#ifndef PNG_DITHER_BLUE_BITS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600345# define PNG_DITHER_BLUE_BITS 5
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600346#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500347
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600348/* This controls how fine the gamma correction becomes when you
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600349 * are only interested in 8 bits anyway. Increasing this value
350 * results in more memory being used, and more pow() functions
351 * being called to fill in the gamma tables. Don't set this value
352 * less then 8, and even that may not work (I haven't tested it).
353 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500354
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600355#ifndef PNG_MAX_GAMMA_8
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600356# define PNG_MAX_GAMMA_8 11
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600357#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500358
Andreas Dilger47a0c421997-05-16 02:46:07 -0500359/* This controls how much a difference in gamma we can tolerate before
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600360 * we actually start doing gamma conversion.
361 */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600362#ifndef PNG_GAMMA_THRESHOLD
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600363# define PNG_GAMMA_THRESHOLD 0.05
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600364#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500365
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500366#endif /* PNG_INTERNAL */
367
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600368/* The following uses const char * instead of char * for error
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600369 * and warning message functions, so some compilers won't complain.
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600370 * If you do not want to use const, define PNG_NO_CONST here.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600371 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600372
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600373#ifndef PNG_NO_CONST
Guy Schalnat6d764711995-12-19 03:22:19 -0600374# define PNG_CONST const
375#else
376# define PNG_CONST
377#endif
378
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600379/* The following defines give you the ability to remove code from the
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600380 * library that you will not be using. I wish I could figure out how to
381 * automate this, but I can't do that without making it seriously hard
382 * on the users. So if you are not using an ability, change the #define
383 * to and #undef, and that part of the library will not be compiled. If
384 * your linker can't find a function, you may want to make sure the
385 * ability is defined here. Some of these depend upon some others being
386 * defined. I haven't figured out all the interactions here, so you may
387 * have to experiment awhile to get everything to compile. If you are
388 * creating or using a shared library, you probably shouldn't touch this,
389 * as it will affect the size of the structures, and this will cause bad
390 * things to happen if the library and/or application ever change.
391 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500392
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500393/* Any features you will not be using can be undef'ed here */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600394
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600395/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500396 * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS
397 * on the compile line, then pick and choose which ones to define without
398 * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED
399 * if you only want to have a png-compliant reader/writer but don't need
400 * any of the extra transformations. This saves about 80 kbytes in a
401 * typical installation of the library. (PNG_NO_* form added in version
402 * 1.0.1c, for consistency)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600403 */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600404
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500405/* The size of the png_text structure changed in libpng-1.0.6 when
406 * iTXt is supported. It is turned off by default, to support old apps
407 * that malloc the png_text structure instead of calling png_set_text()
408 * and letting libpng malloc it. It will be turned on by default in
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600409 * libpng-1.3.0.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500410 */
411
412#ifndef PNG_iTXt_SUPPORTED
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500413# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500414# define PNG_NO_READ_iTXt
415# endif
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500416# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500417# define PNG_NO_WRITE_iTXt
418# endif
419#endif
420
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500421/* The following support, added after version 1.0.0, can be turned off here en
422 * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility
423 * with old applications that require the length of png_struct and png_info
424 * to remain unchanged.
425 */
426
427#ifdef PNG_LEGACY_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600428# define PNG_NO_FREE_ME
429# define PNG_NO_READ_UNKNOWN_CHUNKS
430# define PNG_NO_WRITE_UNKNOWN_CHUNKS
431# define PNG_NO_READ_USER_CHUNKS
432# define PNG_NO_READ_iCCP
433# define PNG_NO_WRITE_iCCP
434# define PNG_NO_READ_iTXt
435# define PNG_NO_WRITE_iTXt
436# define PNG_NO_READ_sCAL
437# define PNG_NO_WRITE_sCAL
438# define PNG_NO_READ_sPLT
439# define PNG_NO_WRITE_sPLT
440# define PNG_NO_INFO_IMAGE
441# define PNG_NO_READ_RGB_TO_GRAY
442# define PNG_NO_READ_USER_TRANSFORM
443# define PNG_NO_WRITE_USER_TRANSFORM
444# define PNG_NO_USER_MEM
445# define PNG_NO_READ_EMPTY_PLTE
446# define PNG_NO_MNG_FEATURES
447# define PNG_NO_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500448#endif
449
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500450/* Ignore attempt to turn off both floating and fixed point support */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500451#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600452 !defined(PNG_NO_FIXED_POINT_SUPPORTED)
453# define PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500454#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600455
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500456#ifndef PNG_NO_FREE_ME
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600457# define PNG_FREE_ME_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500458#endif
459
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600460#if defined(PNG_READ_SUPPORTED)
461
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500462#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600463 !defined(PNG_NO_READ_TRANSFORMS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600464# define PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600465#endif
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600466
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600467#ifdef PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600468# ifndef PNG_NO_READ_EXPAND
469# define PNG_READ_EXPAND_SUPPORTED
470# endif
471# ifndef PNG_NO_READ_SHIFT
472# define PNG_READ_SHIFT_SUPPORTED
473# endif
474# ifndef PNG_NO_READ_PACK
475# define PNG_READ_PACK_SUPPORTED
476# endif
477# ifndef PNG_NO_READ_BGR
478# define PNG_READ_BGR_SUPPORTED
479# endif
480# ifndef PNG_NO_READ_SWAP
481# define PNG_READ_SWAP_SUPPORTED
482# endif
483# ifndef PNG_NO_READ_PACKSWAP
484# define PNG_READ_PACKSWAP_SUPPORTED
485# endif
486# ifndef PNG_NO_READ_INVERT
487# define PNG_READ_INVERT_SUPPORTED
488# endif
489# ifndef PNG_NO_READ_DITHER
490# define PNG_READ_DITHER_SUPPORTED
491# endif
492# ifndef PNG_NO_READ_BACKGROUND
493# define PNG_READ_BACKGROUND_SUPPORTED
494# endif
495# ifndef PNG_NO_READ_16_TO_8
496# define PNG_READ_16_TO_8_SUPPORTED
497# endif
498# ifndef PNG_NO_READ_FILLER
499# define PNG_READ_FILLER_SUPPORTED
500# endif
501# ifndef PNG_NO_READ_GAMMA
502# define PNG_READ_GAMMA_SUPPORTED
503# endif
504# ifndef PNG_NO_READ_GRAY_TO_RGB
505# define PNG_READ_GRAY_TO_RGB_SUPPORTED
506# endif
507# ifndef PNG_NO_READ_SWAP_ALPHA
508# define PNG_READ_SWAP_ALPHA_SUPPORTED
509# endif
510# ifndef PNG_NO_READ_INVERT_ALPHA
511# define PNG_READ_INVERT_ALPHA_SUPPORTED
512# endif
513# ifndef PNG_NO_READ_STRIP_ALPHA
514# define PNG_READ_STRIP_ALPHA_SUPPORTED
515# endif
516# ifndef PNG_NO_READ_USER_TRANSFORM
517# define PNG_READ_USER_TRANSFORM_SUPPORTED
518# endif
519# ifndef PNG_NO_READ_RGB_TO_GRAY
520# define PNG_READ_RGB_TO_GRAY_SUPPORTED
521# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600522#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600523
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500524#if !defined(PNG_NO_PROGRESSIVE_READ) && \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600525 !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
526# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600527#endif /* about interlacing capability! You'll */
528 /* still have interlacing unless you change the following line: */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600529
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600530#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500531
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500532#ifndef PNG_NO_READ_COMPOSITE_NODIV
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600533# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
534# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
535# endif
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500536#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500537
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600538/* Deprecated, will be removed from version 2.0.0.
539 Use PNG_MNG_FEATURES_SUPPORTED instead. */
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500540#ifndef PNG_NO_READ_EMPTY_PLTE
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600541# define PNG_READ_EMPTY_PLTE_SUPPORTED
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500542#endif
543
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600544#endif /* PNG_READ_SUPPORTED */
545
546#if defined(PNG_WRITE_SUPPORTED)
547
548# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
549 !defined(PNG_NO_WRITE_TRANSFORMS)
550# define PNG_WRITE_TRANSFORMS_SUPPORTED
551#endif
552
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600553#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600554# ifndef PNG_NO_WRITE_SHIFT
555# define PNG_WRITE_SHIFT_SUPPORTED
556# endif
557# ifndef PNG_NO_WRITE_PACK
558# define PNG_WRITE_PACK_SUPPORTED
559# endif
560# ifndef PNG_NO_WRITE_BGR
561# define PNG_WRITE_BGR_SUPPORTED
562# endif
563# ifndef PNG_NO_WRITE_SWAP
564# define PNG_WRITE_SWAP_SUPPORTED
565# endif
566# ifndef PNG_NO_WRITE_PACKSWAP
567# define PNG_WRITE_PACKSWAP_SUPPORTED
568# endif
569# ifndef PNG_NO_WRITE_INVERT
570# define PNG_WRITE_INVERT_SUPPORTED
571# endif
572# ifndef PNG_NO_WRITE_FILLER
573# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */
574# endif
575# ifndef PNG_NO_WRITE_SWAP_ALPHA
576# define PNG_WRITE_SWAP_ALPHA_SUPPORTED
577# endif
578# ifndef PNG_NO_WRITE_INVERT_ALPHA
579# define PNG_WRITE_INVERT_ALPHA_SUPPORTED
580# endif
581# ifndef PNG_NO_WRITE_USER_TRANSFORM
582# define PNG_WRITE_USER_TRANSFORM_SUPPORTED
583# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600584#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600585
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500586#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600587 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
588# ifndef PNG_NO_USER_TRANSFORM_PTR
589# define PNG_USER_TRANSFORM_PTR_SUPPORTED
590# endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500591#endif
592
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600593#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
594 encoders, but can cause trouble
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600595 if left undefined */
596
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500597#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
598 defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600599# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500600#endif
601
Glenn Randers-Pehrson73d57cb2002-03-25 18:49:08 -0600602#ifndef PNG_1_0_X
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500603#ifndef PNG_NO_ERROR_NUMBERS
604#define PNG_ERROR_NUMBERS_SUPPORTED
605#endif
Glenn Randers-Pehrson73d57cb2002-03-25 18:49:08 -0600606#endif /* PNG_1_0_X */
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500607
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500608#ifndef PNG_NO_WRITE_FLUSH
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600609# define PNG_WRITE_FLUSH_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500610#endif
611
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -0600612/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500613#ifndef PNG_NO_WRITE_EMPTY_PLTE
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600614# define PNG_WRITE_EMPTY_PLTE_SUPPORTED
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500615#endif
616
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600617#endif /* PNG_WRITE_SUPPORTED */
618
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500619#ifndef PNG_NO_STDIO
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600620# define PNG_TIME_RFC1123_SUPPORTED
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600621#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500622
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600623/* This adds extra functions in pngget.c for accessing data from the
624 * info pointer (added in version 0.99)
625 * png_get_image_width()
626 * png_get_image_height()
627 * png_get_bit_depth()
628 * png_get_color_type()
629 * png_get_compression_type()
630 * png_get_filter_type()
631 * png_get_interlace_type()
632 * png_get_pixel_aspect_ratio()
633 * png_get_pixels_per_meter()
634 * png_get_x_offset_pixels()
635 * png_get_y_offset_pixels()
636 * png_get_x_offset_microns()
637 * png_get_y_offset_microns()
638 */
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500639#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600640# define PNG_EASY_ACCESS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600641#endif
642
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500643/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
Glenn Randers-Pehrsoncdf140b2001-01-15 12:22:32 -0600644 even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500645#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
646# ifndef PNG_ASSEMBLER_CODE_SUPPORTED
647# define PNG_ASSEMBLER_CODE_SUPPORTED
648# endif
649# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
650# define PNG_MMX_CODE_SUPPORTED
651# endif
652#endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500653
Glenn Randers-Pehrson1ea0ff32001-08-07 22:25:59 -0500654/* If you are sure that you don't need thread safety and you are compiling
655 with PNG_USE_PNGCCRD for an MMX application, you can define this for
656 faster execution. See pnggccrd.c.
657#define PNG_THREAD_UNSAFE_OK
658*/
659
Glenn Randers-Pehrson377657d2002-03-08 01:31:27 -0600660#if !defined(PNG_1_0_X)
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500661#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
662# define PNG_USER_MEM_SUPPORTED
663#endif
Glenn Randers-Pehrson377657d2002-03-08 01:31:27 -0600664#endif /* PNG_1_0_X */
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500665
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600666/* These are currently experimental features, define them if you want */
667
668/* very little testing */
669/*
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600670#ifdef PNG_READ_SUPPORTED
671# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
672# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
673# endif
674#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600675*/
Andreas Dilger47a0c421997-05-16 02:46:07 -0500676
677/* This is only for PowerPC big-endian and 680x0 systems */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600678/* some testing */
679/*
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600680#ifdef PNG_READ_SUPPORTED
681# ifndef PNG_PNG_READ_BIG_ENDIAN_SUPPORTED
682# define PNG_READ_BIG_ENDIAN_SUPPORTED
683# endif
684#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600685*/
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500686
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -0500687/* Buggy compilers (e.g., gcc 2.7.2.2) need this */
688/*
689#define PNG_NO_POINTER_INDEXING
690*/
691
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600692/* These functions are turned off by default, as they will be phased out. */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600693/*
694#define PNG_USELESS_TESTS_SUPPORTED
695#define PNG_CORRECT_PALETTE_SUPPORTED
696*/
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600697
Andreas Dilger47a0c421997-05-16 02:46:07 -0500698/* Any chunks you are not interested in, you can undef here. The
699 * ones that allocate memory may be expecially important (hIST,
700 * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600701 * a bit smaller.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500702 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500703
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600704#if defined(PNG_READ_SUPPORTED) && \
705 !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500706 !defined(PNG_NO_READ_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600707# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600708#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600709
710#if defined(PNG_WRITE_SUPPORTED) && \
711 !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500712 !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600713# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600714#endif
715
716#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600717
718#ifdef PNG_NO_READ_TEXT
719# define PNG_NO_READ_iTXt
720# define PNG_NO_READ_tEXt
721# define PNG_NO_READ_zTXt
722#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500723#ifndef PNG_NO_READ_bKGD
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600724# define PNG_READ_bKGD_SUPPORTED
725# define PNG_bKGD_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500726#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500727#ifndef PNG_NO_READ_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600728# define PNG_READ_cHRM_SUPPORTED
729# define PNG_cHRM_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500730#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500731#ifndef PNG_NO_READ_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600732# define PNG_READ_gAMA_SUPPORTED
733# define PNG_gAMA_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500734#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500735#ifndef PNG_NO_READ_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600736# define PNG_READ_hIST_SUPPORTED
737# define PNG_hIST_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600738#endif
739#ifndef PNG_NO_READ_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600740# define PNG_READ_iCCP_SUPPORTED
741# define PNG_iCCP_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600742#endif
743#ifndef PNG_NO_READ_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500744# ifndef PNG_READ_iTXt_SUPPORTED
745# define PNG_READ_iTXt_SUPPORTED
746# endif
747# ifndef PNG_iTXt_SUPPORTED
748# define PNG_iTXt_SUPPORTED
749# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500750#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500751#ifndef PNG_NO_READ_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600752# define PNG_READ_oFFs_SUPPORTED
753# define PNG_oFFs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500754#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500755#ifndef PNG_NO_READ_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600756# define PNG_READ_pCAL_SUPPORTED
757# define PNG_pCAL_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600758#endif
759#ifndef PNG_NO_READ_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600760# define PNG_READ_sCAL_SUPPORTED
761# define PNG_sCAL_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500762#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500763#ifndef PNG_NO_READ_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600764# define PNG_READ_pHYs_SUPPORTED
765# define PNG_pHYs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500766#endif
767#ifndef PNG_NO_READ_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600768# define PNG_READ_sBIT_SUPPORTED
769# define PNG_sBIT_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600770#endif
771#ifndef PNG_NO_READ_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600772# define PNG_READ_sPLT_SUPPORTED
773# define PNG_sPLT_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500774#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500775#ifndef PNG_NO_READ_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600776# define PNG_READ_sRGB_SUPPORTED
777# define PNG_sRGB_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500778#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500779#ifndef PNG_NO_READ_tEXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600780# define PNG_READ_tEXt_SUPPORTED
781# define PNG_tEXt_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500782#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500783#ifndef PNG_NO_READ_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600784# define PNG_READ_tIME_SUPPORTED
785# define PNG_tIME_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500786#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500787#ifndef PNG_NO_READ_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600788# define PNG_READ_tRNS_SUPPORTED
789# define PNG_tRNS_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500790#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500791#ifndef PNG_NO_READ_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600792# define PNG_READ_zTXt_SUPPORTED
793# define PNG_zTXt_SUPPORTED
794#endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500795#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
796# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500797# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
798# define PNG_UNKNOWN_CHUNKS_SUPPORTED
799# endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500800# ifndef PNG_NO_HANDLE_AS_UNKNOWN
801# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
802# endif
803#endif
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -0500804#if !defined(PNG_NO_READ_USER_CHUNKS) && \
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500805 defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600806# define PNG_READ_USER_CHUNKS_SUPPORTED
807# define PNG_USER_CHUNKS_SUPPORTED
808# ifdef PNG_NO_READ_UNKNOWN_CHUNKS
809# undef PNG_NO_READ_UNKNOWN_CHUNKS
810# endif
811# ifdef PNG_NO_HANDLE_AS_UNKNOWN
812# undef PNG_NO_HANDLE_AS_UNKNOWN
813# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600814#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500815#ifndef PNG_NO_READ_OPT_PLTE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600816# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
817#endif /* optional PLTE chunk in RGB and RGBA images */
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600818#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600819 defined(PNG_READ_zTXt_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600820# define PNG_READ_TEXT_SUPPORTED
821# define PNG_TEXT_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600822#endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600823
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600824#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500825
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600826#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600827
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600828#ifdef PNG_NO_WRITE_TEXT
829# define PNG_NO_WRITE_iTXt
830# define PNG_NO_WRITE_tEXt
831# define PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600832#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600833#ifndef PNG_NO_WRITE_bKGD
834# define PNG_WRITE_bKGD_SUPPORTED
835# ifndef PNG_bKGD_SUPPORTED
836# define PNG_bKGD_SUPPORTED
837# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500838#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500839#ifndef PNG_NO_WRITE_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600840# define PNG_WRITE_cHRM_SUPPORTED
841# ifndef PNG_cHRM_SUPPORTED
842# define PNG_cHRM_SUPPORTED
843# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500844#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500845#ifndef PNG_NO_WRITE_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600846# define PNG_WRITE_gAMA_SUPPORTED
847# ifndef PNG_gAMA_SUPPORTED
848# define PNG_gAMA_SUPPORTED
849# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500850#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500851#ifndef PNG_NO_WRITE_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600852# define PNG_WRITE_hIST_SUPPORTED
853# ifndef PNG_hIST_SUPPORTED
854# define PNG_hIST_SUPPORTED
855# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600856#endif
857#ifndef PNG_NO_WRITE_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600858# define PNG_WRITE_iCCP_SUPPORTED
859# ifndef PNG_iCCP_SUPPORTED
860# define PNG_iCCP_SUPPORTED
861# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600862#endif
863#ifndef PNG_NO_WRITE_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500864# ifndef PNG_WRITE_iTXt_SUPPORTED
865# define PNG_WRITE_iTXt_SUPPORTED
866# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600867# ifndef PNG_iTXt_SUPPORTED
868# define PNG_iTXt_SUPPORTED
869# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500870#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500871#ifndef PNG_NO_WRITE_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600872# define PNG_WRITE_oFFs_SUPPORTED
873# ifndef PNG_oFFs_SUPPORTED
874# define PNG_oFFs_SUPPORTED
875# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500876#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500877#ifndef PNG_NO_WRITE_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600878# define PNG_WRITE_pCAL_SUPPORTED
879# ifndef PNG_pCAL_SUPPORTED
880# define PNG_pCAL_SUPPORTED
881# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600882#endif
883#ifndef PNG_NO_WRITE_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600884# define PNG_WRITE_sCAL_SUPPORTED
885# ifndef PNG_sCAL_SUPPORTED
886# define PNG_sCAL_SUPPORTED
887# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500888#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500889#ifndef PNG_NO_WRITE_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600890# define PNG_WRITE_pHYs_SUPPORTED
891# ifndef PNG_pHYs_SUPPORTED
892# define PNG_pHYs_SUPPORTED
893# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500894#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500895#ifndef PNG_NO_WRITE_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600896# define PNG_WRITE_sBIT_SUPPORTED
897# ifndef PNG_sBIT_SUPPORTED
898# define PNG_sBIT_SUPPORTED
899# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600900#endif
901#ifndef PNG_NO_WRITE_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600902# define PNG_WRITE_sPLT_SUPPORTED
903# ifndef PNG_sPLT_SUPPORTED
904# define PNG_sPLT_SUPPORTED
905# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500906#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500907#ifndef PNG_NO_WRITE_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600908# define PNG_WRITE_sRGB_SUPPORTED
909# ifndef PNG_sRGB_SUPPORTED
910# define PNG_sRGB_SUPPORTED
911# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500912#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500913#ifndef PNG_NO_WRITE_tEXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600914# define PNG_WRITE_tEXt_SUPPORTED
915# ifndef PNG_tEXt_SUPPORTED
916# define PNG_tEXt_SUPPORTED
917# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500918#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500919#ifndef PNG_NO_WRITE_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600920# define PNG_WRITE_tIME_SUPPORTED
921# ifndef PNG_tIME_SUPPORTED
922# define PNG_tIME_SUPPORTED
923# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500924#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500925#ifndef PNG_NO_WRITE_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600926# define PNG_WRITE_tRNS_SUPPORTED
927# ifndef PNG_tRNS_SUPPORTED
928# define PNG_tRNS_SUPPORTED
929# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500930#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500931#ifndef PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600932# define PNG_WRITE_zTXt_SUPPORTED
933# ifndef PNG_zTXt_SUPPORTED
934# define PNG_zTXt_SUPPORTED
935# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600936#endif
937#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600938# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
939# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
940# define PNG_UNKNOWN_CHUNKS_SUPPORTED
941# endif
942# ifndef PNG_NO_HANDLE_AS_UNKNOWN
943# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
944# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
945# endif
946# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600947#endif
948#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600949 defined(PNG_WRITE_zTXt_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600950# define PNG_WRITE_TEXT_SUPPORTED
951# ifndef PNG_TEXT_SUPPORTED
952# define PNG_TEXT_SUPPORTED
953# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500954#endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600955
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600956#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500957
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600958/* Turn this off to disable png_read_png() and
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600959 * png_write_png() and leave the row_pointers member
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600960 * out of the info structure.
961 */
962#ifndef PNG_NO_INFO_IMAGE
963# define PNG_INFO_IMAGE_SUPPORTED
964#endif
965
Andreas Dilger47a0c421997-05-16 02:46:07 -0500966/* need the time information for reading tIME chunks */
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600967#if defined(PNG_tIME_SUPPORTED)
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500968# if !defined(_WIN32_WCE)
969 /* "time.h" functions are not supported on WindowsCE */
970# include <time.h>
971# endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500972#endif
973
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600974/* Some typedefs to get us started. These should be safe on most of the
Andreas Dilger47a0c421997-05-16 02:46:07 -0500975 * common platforms. The typedefs should be at least as large as the
976 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
977 * don't have to be exactly that size. Some compilers dislike passing
978 * unsigned shorts as function parameters, so you may be better off using
979 * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may
980 * want to have unsigned int for png_uint_32 instead of unsigned long.
981 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500982
983typedef unsigned long png_uint_32;
984typedef long png_int_32;
985typedef unsigned short png_uint_16;
986typedef short png_int_16;
987typedef unsigned char png_byte;
988
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600989/* This is usually size_t. It is typedef'ed just in case you need it to
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500990 change (I'm not sure if you will or not, so I thought I'd be safe) */
991typedef size_t png_size_t;
992
Andreas Dilger47a0c421997-05-16 02:46:07 -0500993/* The following is needed for medium model support. It cannot be in the
994 * PNG_INTERNAL section. Needs modification for other compilers besides
995 * MSC. Model independent support declares all arrays and pointers to be
996 * large using the far keyword. The zlib version used must also support
997 * model independent data. As of version zlib 1.0.4, the necessary changes
998 * have been made in zlib. The USE_FAR_KEYWORD define triggers other
999 * changes that are needed. (Tim Wegner)
1000 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001001
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001002/* Separate compiler dependencies (problem here is that zlib.h always
1003 defines FAR. (SJT) */
Guy Schalnat6d764711995-12-19 03:22:19 -06001004#ifdef __BORLANDC__
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001005# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
1006# define LDATA 1
1007# else
1008# define LDATA 0
1009# endif
1010 /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
1011# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
1012# define PNG_MAX_MALLOC_64K
1013# if (LDATA != 1)
1014# ifndef FAR
1015# define FAR __far
1016# endif
1017# define USE_FAR_KEYWORD
1018# endif /* LDATA != 1 */
1019 /* Possibly useful for moving data out of default segment.
1020 * Uncomment it if you want. Could also define FARDATA as
1021 * const if your compiler supports it. (SJT)
1022# define FARDATA FAR
1023 */
1024# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
Guy Schalnatb2e01bd1996-01-26 01:38:47 -06001025#endif /* __BORLANDC__ */
Guy Schalnat6d764711995-12-19 03:22:19 -06001026
1027
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001028/* Suggest testing for specific compiler first before testing for
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001029 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
1030 * making reliance oncertain keywords suspect. (SJT)
1031 */
Guy Schalnat6d764711995-12-19 03:22:19 -06001032
1033/* MSC Medium model */
1034#if defined(FAR)
1035# if defined(M_I86MM)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001036# define USE_FAR_KEYWORD
1037# define FARDATA FAR
1038# include <dos.h>
Guy Schalnat6d764711995-12-19 03:22:19 -06001039# endif
1040#endif
1041
1042/* SJT: default case */
1043#ifndef FAR
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001044# define FAR
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001045#endif
1046
Andreas Dilger47a0c421997-05-16 02:46:07 -05001047/* At this point FAR is always defined */
Guy Schalnat6d764711995-12-19 03:22:19 -06001048#ifndef FARDATA
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001049# define FARDATA
Guy Schalnat6d764711995-12-19 03:22:19 -06001050#endif
1051
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001052/* Typedef for floating-point numbers that are converted
1053 to fixed-point with a multiple of 100,000, e.g., int_gamma */
1054typedef png_int_32 png_fixed_point;
1055
Andreas Dilger47a0c421997-05-16 02:46:07 -05001056/* Add typedefs for pointers */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001057typedef void FAR * png_voidp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001058typedef png_byte FAR * png_bytep;
1059typedef png_uint_32 FAR * png_uint_32p;
1060typedef png_int_32 FAR * png_int_32p;
1061typedef png_uint_16 FAR * png_uint_16p;
1062typedef png_int_16 FAR * png_int_16p;
1063typedef PNG_CONST char FAR * png_const_charp;
1064typedef char FAR * png_charp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001065typedef png_fixed_point FAR * png_fixed_point_p;
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001066
1067#ifndef PNG_NO_STDIO
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -05001068#if defined(_WIN32_WCE)
1069typedef HANDLE png_FILE_p;
1070#else
1071typedef FILE * png_FILE_p;
1072#endif
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001073#endif
1074
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001075#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001076typedef double FAR * png_doublep;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001077#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001078
Andreas Dilger47a0c421997-05-16 02:46:07 -05001079/* Pointers to pointers; i.e. arrays */
Guy Schalnat6d764711995-12-19 03:22:19 -06001080typedef png_byte FAR * FAR * png_bytepp;
1081typedef png_uint_32 FAR * FAR * png_uint_32pp;
1082typedef png_int_32 FAR * FAR * png_int_32pp;
1083typedef png_uint_16 FAR * FAR * png_uint_16pp;
1084typedef png_int_16 FAR * FAR * png_int_16pp;
1085typedef PNG_CONST char FAR * FAR * png_const_charpp;
1086typedef char FAR * FAR * png_charpp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001087typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001088#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001089typedef double FAR * FAR * png_doublepp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001090#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001091
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001092/* Pointers to pointers to pointers; i.e., pointer to array */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001093typedef char FAR * FAR * FAR * png_charppp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001094
Andreas Dilger47a0c421997-05-16 02:46:07 -05001095/* libpng typedefs for types in zlib. If zlib changes
1096 * or another compression library is used, then change these.
1097 * Eliminates need to change all the source files.
1098 */
Guy Schalnat6d764711995-12-19 03:22:19 -06001099typedef charf * png_zcharp;
1100typedef charf * FAR * png_zcharpp;
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001101typedef z_stream FAR * png_zstreamp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001102
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001103/*
1104 * Define PNG_BUILD_DLL if the module being built is a Windows
1105 * LIBPNG DLL.
1106 *
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001107 * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL.
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -06001108 * It is equivalent to Microsoft predefined macro _DLL that is
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001109 * automatically defined when you compile using the share
1110 * version of the CRT (C Run-Time library)
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001111 *
1112 * The cygwin mods make this behavior a little different:
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001113 * Define PNG_BUILD_DLL if you are building a dll for use with cygwin
1114 * Define PNG_STATIC if you are building a static library for use with cygwin,
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001115 * -or- if you are building an application that you want to link to the
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001116 * static library.
1117 * PNG_USE_DLL is defined by default (no user action needed) unless one of
1118 * the other flags is defined.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001119 */
1120
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001121#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001122# define PNG_DLL
1123#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001124/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib.
1125 * When building a static lib, default to no GLOBAL ARRAYS, but allow
1126 * command-line override
1127 */
1128#if defined(__CYGWIN__)
1129# if !defined(PNG_STATIC)
1130# if defined(PNG_USE_GLOBAL_ARRAYS)
1131# undef PNG_USE_GLOBAL_ARRAYS
1132# endif
1133# if !defined(PNG_USE_LOCAL_ARRAYS)
1134# define PNG_USE_LOCAL_ARRAYS
1135# endif
1136# else
1137# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS)
1138# if defined(PNG_USE_GLOBAL_ARRAYS)
1139# undef PNG_USE_GLOBAL_ARRAYS
1140# endif
1141# endif
1142# endif
1143# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
1144# define PNG_USE_LOCAL_ARRAYS
1145# endif
1146#endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001147
Glenn Randers-Pehrsonec61c232000-05-16 06:17:36 -05001148/* Do not use global arrays (helps with building DLL's)
1149 * They are no longer used in libpng itself, since version 1.0.5c,
1150 * but might be required for some pre-1.0.5c applications.
1151 */
1152#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
1153# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL))
1154# define PNG_USE_LOCAL_ARRAYS
1155# else
1156# define PNG_USE_GLOBAL_ARRAYS
1157# endif
1158#endif
1159
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001160#if defined(__CYGWIN__)
1161# undef PNGAPI
1162# define PNGAPI __cdecl
1163# undef PNG_IMPEXP
1164# define PNG_IMPEXP
1165#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001166
Glenn Randers-Pehrson25d82242002-05-01 11:51:26 -05001167/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
1168 * you may get warnings regarding the linkage of png_zalloc and png_zfree.
1169 * Don't ignore those warnings; you must also reset the default calling
1170 * convention in your compiler to match your PNGAPI, and you must build
1171 * zlib and your applications the same way you build libpng.
1172 */
1173
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001174#ifndef PNGAPI
Glenn Randers-Pehrsonf5ed0e12000-11-18 18:19:14 -06001175
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001176#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001177# ifndef PNG_NO_MODULEDEF
1178# define PNG_NO_MODULEDEF
1179# endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001180#endif
1181
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001182#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001183# define PNG_IMPEXP
1184#endif
1185
1186#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001187 (( defined(_Windows) || defined(_WINDOWS) || \
1188 defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001189 ))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001190
Glenn Randers-Pehrsonf05f8032000-12-23 14:27:39 -06001191# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001192# define PNGAPI __cdecl
1193# else
1194# define PNGAPI _cdecl
1195# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001196
1197# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \
1198 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */)
1199# define PNG_IMPEXP
1200# endif
1201
1202# if !defined(PNG_IMPEXP)
1203
1204# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol
1205# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol
1206
1207 /* Borland/Microsoft */
1208# if defined(_MSC_VER) || defined(__BORLANDC__)
1209# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
1210# define PNG_EXPORT PNG_EXPORT_TYPE1
1211# else
1212# define PNG_EXPORT PNG_EXPORT_TYPE2
1213# if defined(PNG_BUILD_DLL)
1214# define PNG_IMPEXP __export
1215# else
1216# define PNG_IMPEXP /*__import*/ /* doesn't exist AFAIK in
1217 VC++*/
1218# endif /* Exists in Borland C++ for
1219 C++ classes (== huge) */
1220# endif
1221# endif
1222
1223# if !defined(PNG_IMPEXP)
1224# if defined(PNG_BUILD_DLL)
1225# define PNG_IMPEXP __declspec(dllexport)
1226# else
1227# define PNG_IMPEXP __declspec(dllimport)
1228# endif
1229# endif
1230# endif /* PNG_IMPEXP */
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001231#else /* !(DLL || non-cygwin WINDOWS) */
Glenn Randers-Pehrsonf64a06f2001-04-11 07:38:00 -05001232# if (defined(__IBMC__) || defined(IBMCPP__)) && defined(__OS2__)
1233# define PNGAPI _System
1234# define PNG_IMPEXP
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001235# else
Glenn Randers-Pehrsonf64a06f2001-04-11 07:38:00 -05001236# if 0 /* ... other platforms, with other meanings */
1237# else
1238# define PNGAPI
1239# define PNG_IMPEXP
1240# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001241# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001242#endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001243#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001244
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -06001245#ifndef PNGAPI
1246# define PNGAPI
1247#endif
1248#ifndef PNG_IMPEXP
1249# define PNG_IMPEXP
1250#endif
1251
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -05001252#ifndef PNG_EXPORT
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001253# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001254#endif
1255
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001256#ifdef PNG_USE_GLOBAL_ARRAYS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001257# ifndef PNG_EXPORT_VAR
1258# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type
1259# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001260#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001261
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001262/* User may want to use these so they are not in PNG_INTERNAL. Any library
1263 * functions that are passed far data must be model independent.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001264 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001265
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001266#ifndef PNG_ABORT
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001267# define PNG_ABORT() abort()
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001268#endif
1269
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001270#ifdef PNG_SETJMP_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001271# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06001272#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001273# define png_jmpbuf(png_ptr) \
1274 (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED)
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001275#endif
1276
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001277#if defined(USE_FAR_KEYWORD) /* memory model independent fns */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001278/* use this to make far-to-near assignments */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001279# define CHECK 1
1280# define NOCHECK 0
1281# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
1282# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
1283# define png_strcpy _fstrcpy
1284# define png_strlen _fstrlen
1285# define png_memcmp _fmemcmp /* SJT: added */
1286# define png_memcpy _fmemcpy
1287# define png_memset _fmemset
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001288#else /* use the usual functions */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001289# define CVT_PTR(ptr) (ptr)
1290# define CVT_PTR_NOCHECK(ptr) (ptr)
1291# define png_strcpy strcpy
1292# define png_strlen strlen
1293# define png_memcmp memcmp /* SJT: added */
1294# define png_memcpy memcpy
1295# define png_memset memset
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001296#endif
1297/* End of memory model independent support */
1298
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001299/* Just a little check that someone hasn't tried to define something
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001300 * contradictory.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001301 */
1302#if (PNG_ZBUF_SIZE > 65536) && defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001303# undef PNG_ZBUF_SIZE
1304# define PNG_ZBUF_SIZE 65536
Andreas Dilger47a0c421997-05-16 02:46:07 -05001305#endif
1306
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06001307#ifdef PNG_READ_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001308/* Prior to libpng-1.0.9, this block was in pngasmrd.h */
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06001309#if defined(PNG_INTERNAL)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001310
1311/* These are the default thresholds before the MMX code kicks in; if either
1312 * rowbytes or bitdepth is below the threshold, plain C code is used. These
1313 * can be overridden at runtime via the png_set_mmx_thresholds() call in
Glenn Randers-Pehrsoncdf140b2001-01-15 12:22:32 -06001314 * libpng 1.2.0 and later. The values below were chosen by Intel.
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001315 */
1316
1317#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT
1318# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */
1319#endif
1320#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT
1321# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */
1322#endif
1323
1324/* Set this in the makefile for VC++ on Pentium, not here. */
1325/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c .
1326 * MMX will be detected at run time and used if present.
1327 */
1328#ifdef PNG_USE_PNGVCRD
1329# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
1330# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
1331# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
1332#endif
1333
1334/* Set this in the makefile for gcc/as on Pentium, not here. */
1335/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c .
1336 * MMX will be detected at run time and used if present.
1337 */
1338#ifdef PNG_USE_PNGGCCRD
1339# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
1340# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
1341# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
1342#endif
1343/* - see pnggccrd.c for info about what is currently enabled */
1344
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06001345#endif /* PNG_INTERNAL */
1346#endif /* PNG_READ_SUPPORTED */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001347
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001348#endif /* PNGCONF_H */
1349