blob: 3a65015ceca5cc1fc638be6e62c825e8123b865e [file] [log] [blame]
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002/* pngconf.h - machine configurable file for libpng
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06003 *
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05004 * libpng version 1.4.0beta7 - June 16, 2006
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06005 * For conditions of distribution and use, see copyright notice in png.h
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -05006 * Copyright (c) 1998-2006 Glenn Randers-Pehrson
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05007 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06009 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050010
11/* Any machine specific code is near the front of this file, so if you
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060012 * are configuring libpng for a machine, you may want to read the section
13 * starting here down to where it starts to typedef png_color, png_text,
14 * and png_info.
15 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050016
17#ifndef PNGCONF_H
18#define PNGCONF_H
19
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -050020/* Added at libpng-1.4.0 */
21/* Makefile-supplied defines go here: */
22/* End of Makefile-supplied defines. */
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060023
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -050024#ifndef PNG_NO_LIMITS_H
25#include <limits.h>
26#endif
27
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -050028/* Added at libpng-1.2.9 */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -050029
Glenn Randers-Pehrsond5d63602006-04-15 06:37:45 -050030/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */
31#ifdef PNG_CONFIGURE_LIBPNG
Glenn Randers-Pehrson170b70c2006-03-10 10:19:04 -060032#ifdef HAVE_CONFIG_H
Glenn Randers-Pehrsonb0270f72006-04-15 18:23:04 -050033#include "config.h"
Glenn Randers-Pehrsond5d63602006-04-15 06:37:45 -050034#endif
Glenn Randers-Pehrson170b70c2006-03-10 10:19:04 -060035#endif
36
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060037/*
38 * Added at libpng-1.2.8
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -050039 *
40 * PNG_USER_CONFIG has to be defined on the compiler command line. This
41 * includes the resource compiler for Windows DLL configurations.
42 */
43#ifdef PNG_USER_CONFIG
44# ifndef PNG_USER_PRIVATEBUILD
45# define PNG_USER_PRIVATEBUILD
46# endif
47#include "pngusr.h"
48#endif
49
50/*
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060051 * If you create a private DLL you need to define in "pngusr.h" the followings:
52 * #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
53 * the DLL was built>
54 * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
55 * #define PNG_USER_DLLFNAME_POSTFIX <two-letter postfix that serve to
56 * distinguish your DLL from those of the official release. These
57 * correspond to the trailing letters that come after the version
58 * number and must match your private DLL name>
59 * e.g. // private DLL "libpng13gx.dll"
60 * #define PNG_USER_DLLFNAME_POSTFIX "gx"
61 *
62 * The following macros are also at your disposal if you want to complete the
63 * DLL VERSIONINFO structure.
64 * - PNG_USER_VERSIONINFO_COMMENTS
65 * - PNG_USER_VERSIONINFO_COMPANYNAME
66 * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS
67 */
68
69#ifdef __STDC__
70#ifdef SPECIALBUILD
71# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\
72 are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.")
73#endif
74
75#ifdef PRIVATEBUILD
Glenn Randers-Pehrson3a512032006-03-31 05:29:33 -060076# pragma message("PRIVATEBUILD is deprecated.\
77 Use PNG_USER_PRIVATEBUILD instead.")
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060078# define PNG_USER_PRIVATEBUILD PRIVATEBUILD
79#endif
80#endif /* __STDC__ */
81
82#ifndef PNG_VERSION_INFO_ONLY
83
84/* End of material added to libpng-1.2.8 */
Glenn Randers-Pehrson878b31e2004-11-12 22:04:56 -060085
Andreas Dilger02ad0ef1997-01-17 01:34:35 -060086/* This is the size of the compression buffer, and thus the size of
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060087 * an IDAT chunk. Make this whatever size you feel is best for your
88 * machine. One of these will be allocated per png_struct. When this
89 * is full, it writes the data to the disk, and does some other
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -060090 * calculations. Making this an extremely small size will slow
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060091 * the library down, but you may want to experiment to determine
92 * where it becomes significant, if you are concerned with memory
93 * usage. Note that zlib allocates at least 32Kb also. For readers,
94 * this describes the size of the buffer available to read the data in.
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060095 * Unless this gets smaller than the size of a row (compressed),
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060096 * it should not make much difference how big this is.
97 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050098
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -060099#ifndef PNG_ZBUF_SIZE
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600100# define PNG_ZBUF_SIZE 8192
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600101#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500102
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600103/* Enable if you want a write-only libpng */
104
105#ifndef PNG_NO_READ_SUPPORTED
106# define PNG_READ_SUPPORTED
107#endif
108
109/* Enable if you want a read-only libpng */
110
111#ifndef PNG_NO_WRITE_SUPPORTED
112# define PNG_WRITE_SUPPORTED
113#endif
114
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500115/* Enabled in 1.4.0. */
116#ifdef PNG_ALLOW_BENIGN_ERRORS
117# define png_benign_error png_warning
118# define png_chunk_benign_error png_chunk_warning
119#else
120# ifndef PNG_BENIGN_ERRORS_SUPPORTED
121# define png_benign_error png_error
122# define png_chunk_benign_error png_chunk_error
123# endif
124#endif
125
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500126/* Enabled by default in 1.2.0. You can disable this if you don't need to
127 support PNGs that are embedded in MNG datastreams */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500128#if !defined(PNG_NO_MNG_FEATURES)
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600129# ifndef PNG_MNG_FEATURES_SUPPORTED
130# define PNG_MNG_FEATURES_SUPPORTED
131# endif
132#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600133
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -0600134#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600135# ifndef PNG_FLOATING_POINT_SUPPORTED
136# define PNG_FLOATING_POINT_SUPPORTED
137# endif
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500138#endif
139
Andreas Dilger47a0c421997-05-16 02:46:07 -0500140/* If you are running on a machine where you cannot allocate more
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600141 * than 64K of memory at once, uncomment this. While libpng will not
142 * normally need that much memory in a chunk (unless you load up a very
143 * large file), zlib needs to know how big of a chunk it can use, and
144 * libpng thus makes sure to check any memory allocation to verify it
145 * will fit into memory.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500146#define PNG_MAX_MALLOC_64K
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600147 */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500148#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600149# define PNG_MAX_MALLOC_64K
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500150#endif
151
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500152/* Special munging to support doing things the 'cygwin' way:
153 * 'Normal' png-on-win32 defines/defaults:
154 * PNG_BUILD_DLL -- building dll
155 * PNG_USE_DLL -- building an application, linking to dll
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -0600156 * (no define) -- building static library, or building an
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500157 * application and linking to the static lib
158 * 'Cygwin' defines/defaults:
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500159 * PNG_BUILD_DLL -- (ignored) building the dll
160 * (no define) -- (ignored) building an application, linking to the dll
161 * PNG_STATIC -- (ignored) building the static lib, or building an
162 * application that links to the static lib.
163 * ALL_STATIC -- (ignored) building various static libs, or building an
164 * application that links to the static libs.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500165 * Thus,
166 * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
167 * this bit of #ifdefs will define the 'correct' config variables based on
168 * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but
169 * unnecessary.
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500170 *
171 * Also, the precedence order is:
172 * ALL_STATIC (since we can't #undef something outside our namespace)
173 * PNG_BUILD_DLL
174 * PNG_STATIC
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500175 * (nothing) == PNG_USE_DLL
176 *
177 * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
178 * of auto-import in binutils, we no longer need to worry about
179 * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore,
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500180 * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
181 * to __declspec() stuff. However, we DO need to worry about
182 * PNG_BUILD_DLL and PNG_STATIC because those change some defaults
183 * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500184 */
185#if defined(__CYGWIN__)
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500186# if defined(ALL_STATIC)
187# if defined(PNG_BUILD_DLL)
188# undef PNG_BUILD_DLL
189# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500190# if defined(PNG_USE_DLL)
191# undef PNG_USE_DLL
192# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500193# if defined(PNG_DLL)
194# undef PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500195# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500196# if !defined(PNG_STATIC)
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -0600197# define PNG_STATIC
198# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500199# else
200# if defined (PNG_BUILD_DLL)
201# if defined(PNG_STATIC)
202# undef PNG_STATIC
203# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500204# if defined(PNG_USE_DLL)
205# undef PNG_USE_DLL
206# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500207# if !defined(PNG_DLL)
208# define PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500209# endif
210# else
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500211# if defined(PNG_STATIC)
212# if defined(PNG_USE_DLL)
213# undef PNG_USE_DLL
214# endif
215# if defined(PNG_DLL)
216# undef PNG_DLL
217# endif
218# else
219# if !defined(PNG_USE_DLL)
220# define PNG_USE_DLL
221# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500222# if !defined(PNG_DLL)
223# define PNG_DLL
224# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500225# endif
226# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500227# endif
228#endif
229
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500230/* This protects us against compilers that run on a windowing system
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600231 * and thus don't have or would rather us not use the stdio types:
232 * stdin, stdout, and stderr. The only one currently used is stderr
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600233 * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will
234 * prevent these from being compiled and used. #defining PNG_NO_STDIO
235 * will also prevent these, plus will prevent the entire set of stdio
236 * macros and functions (FILE *, printf, etc.) from being compiled and used,
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500237 * unless (PNG_DEBUG > 0) has been #defined.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600238 *
239 * #define PNG_NO_CONSOLE_IO
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600240 * #define PNG_NO_STDIO
241 */
Guy Schalnat6d764711995-12-19 03:22:19 -0600242
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500243#if defined(_WIN32_WCE)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600244# include <windows.h>
245 /* Console I/O functions are not supported on WindowsCE */
246# define PNG_NO_CONSOLE_IO
247# ifdef PNG_DEBUG
248# undef PNG_DEBUG
249# endif
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500250#endif
251
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -0500252#ifdef PNG_BUILD_DLL
253# ifndef PNG_CONSOLE_IO_SUPPORTED
254# ifndef PNG_NO_CONSOLE_IO
255# define PNG_NO_CONSOLE_IO
256# endif
257# endif
258#endif
259
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600260# ifdef PNG_NO_STDIO
261# ifndef PNG_NO_CONSOLE_IO
262# define PNG_NO_CONSOLE_IO
263# endif
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500264# ifdef PNG_DEBUG
265# if (PNG_DEBUG > 0)
266# include <stdio.h>
267# endif
268# endif
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600269# else
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500270# include <stdio.h>
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600271# endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600272
273/* This macro protects us against machines that don't have function
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600274 * prototypes (ie K&R style headers). If your compiler does not handle
275 * function prototypes, define this macro and use the included ansi2knr.
276 * I've always been able to use _NO_PROTO as the indicator, but you may
277 * need to drag the empty declaration out in front of here, or change the
278 * ifdef to suit your own needs.
279 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500280#ifndef PNGARG
281
Andreas Dilger47a0c421997-05-16 02:46:07 -0500282#ifdef OF /* zlib prototype munger */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600283# define PNGARG(arglist) OF(arglist)
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500284#else
285
286#ifdef _NO_PROTO
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600287# define PNGARG(arglist) ()
Glenn Randers-Pehrson5cded0b2001-11-07 07:10:08 -0600288# ifndef PNG_TYPECAST_NULL
289# define PNG_TYPECAST_NULL
290# endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500291#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600292# define PNGARG(arglist) arglist
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500293#endif /* _NO_PROTO */
294
295#endif /* OF */
296
297#endif /* PNGARG */
298
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600299/* Try to determine if we are compiling on a Mac. Note that testing for
300 * just __MWERKS__ is not good enough, because the Codewarrior is now used
301 * on non-Mac platforms.
302 */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600303#ifndef MACOS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600304# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
305 defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
306# define MACOS
307# endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600308#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600309
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500310/* enough people need this for various reasons to include it here */
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500311#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600312# include <sys/types.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500313#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600314
Glenn Randers-Pehrsonb1828932001-06-23 08:03:17 -0500315#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600316# define PNG_SETJMP_SUPPORTED
317#endif
318
319#ifdef PNG_SETJMP_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -0500320/* This is an attempt to force a single setjmp behaviour on Linux. If
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600321 * the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
322 */
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500323
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600324# ifdef __linux__
325# ifdef _BSD_SOURCE
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500326# define PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600327# undef _BSD_SOURCE
328# endif
329# ifdef _SETJMP_H
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -0500330 /* If you encounter a compiler error here, see the explanation
331 * near the end of INSTALL.
332 */
333 __png.h__ already includes setjmp.h;
334 __dont__ include it again.;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600335# endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600336# endif /* __linux__ */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500337
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600338 /* include setjmp.h for error handling */
339# include <setjmp.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500340
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600341# ifdef __linux__
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500342# ifdef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600343# define _BSD_SOURCE
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500344# undef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600345# endif
346# endif /* __linux__ */
347#endif /* PNG_SETJMP_SUPPORTED */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600348
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500349#ifdef BSD
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600350# include <strings.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500351#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600352# include <string.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500353#endif
354
Andreas Dilger47a0c421997-05-16 02:46:07 -0500355/* Other defines for things like memory and the like can go here. */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500356
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600357/* The following uses const char * instead of char * for error
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600358 * and warning message functions, so some compilers won't complain.
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600359 * If you do not want to use const, define PNG_NO_CONST here.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600360 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600361
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600362#ifndef PNG_NO_CONST
Guy Schalnat6d764711995-12-19 03:22:19 -0600363# define PNG_CONST const
364#else
365# define PNG_CONST
366#endif
367
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600368/* The following defines give you the ability to remove code from the
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600369 * library that you will not be using. I wish I could figure out how to
370 * automate this, but I can't do that without making it seriously hard
371 * on the users. So if you are not using an ability, change the #define
372 * to and #undef, and that part of the library will not be compiled. If
373 * your linker can't find a function, you may want to make sure the
374 * ability is defined here. Some of these depend upon some others being
375 * defined. I haven't figured out all the interactions here, so you may
376 * have to experiment awhile to get everything to compile. If you are
377 * creating or using a shared library, you probably shouldn't touch this,
378 * as it will affect the size of the structures, and this will cause bad
379 * things to happen if the library and/or application ever change.
380 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500381
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500382/* Any features you will not be using can be undef'ed here */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600383
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600384/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500385 * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS
386 * on the compile line, then pick and choose which ones to define without
387 * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED
388 * if you only want to have a png-compliant reader/writer but don't need
389 * any of the extra transformations. This saves about 80 kbytes in a
390 * typical installation of the library. (PNG_NO_* form added in version
391 * 1.0.1c, for consistency)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600392 */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600393
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500394/* The size of the png_text structure changed in libpng-1.0.6 when
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600395 * iTXt support was added. iTXt support was turned off by default through
396 * libpng-1.2.x, to support old apps that malloc the png_text structure
397 * instead of calling png_set_text() and letting libpng malloc it. It
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500398 * was turned on by default in libpng-1.4.0.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500399 */
400
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600401#if !defined(PNG_NO_iTXt_SUPPORTED)
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500402# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt)
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600403# define PNG_READ_iTXt
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500404# endif
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500405# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt)
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600406# define PNG_WRITE_iTXt
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500407# endif
408#endif
409
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500410/* The following support, added after version 1.0.0, can be turned off here en
411 * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility
412 * with old applications that require the length of png_struct and png_info
413 * to remain unchanged.
414 */
415
416#ifdef PNG_LEGACY_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600417# define PNG_NO_FREE_ME
418# define PNG_NO_READ_UNKNOWN_CHUNKS
419# define PNG_NO_WRITE_UNKNOWN_CHUNKS
420# define PNG_NO_READ_USER_CHUNKS
421# define PNG_NO_READ_iCCP
422# define PNG_NO_WRITE_iCCP
423# define PNG_NO_READ_iTXt
424# define PNG_NO_WRITE_iTXt
425# define PNG_NO_READ_sCAL
426# define PNG_NO_WRITE_sCAL
427# define PNG_NO_READ_sPLT
428# define PNG_NO_WRITE_sPLT
429# define PNG_NO_INFO_IMAGE
430# define PNG_NO_READ_RGB_TO_GRAY
431# define PNG_NO_READ_USER_TRANSFORM
432# define PNG_NO_WRITE_USER_TRANSFORM
433# define PNG_NO_USER_MEM
434# define PNG_NO_READ_EMPTY_PLTE
435# define PNG_NO_MNG_FEATURES
436# define PNG_NO_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500437#endif
438
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500439/* Ignore attempt to turn off both floating and fixed point support */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500440#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600441 !defined(PNG_NO_FIXED_POINT_SUPPORTED)
442# define PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500443#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600444
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500445#ifndef PNG_NO_FREE_ME
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600446# define PNG_FREE_ME_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500447#endif
448
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600449#if defined(PNG_READ_SUPPORTED)
450
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500451#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600452 !defined(PNG_NO_READ_TRANSFORMS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600453# define PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600454#endif
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600455
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600456#ifdef PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600457# ifndef PNG_NO_READ_EXPAND
458# define PNG_READ_EXPAND_SUPPORTED
459# endif
460# ifndef PNG_NO_READ_SHIFT
461# define PNG_READ_SHIFT_SUPPORTED
462# endif
463# ifndef PNG_NO_READ_PACK
464# define PNG_READ_PACK_SUPPORTED
465# endif
466# ifndef PNG_NO_READ_BGR
467# define PNG_READ_BGR_SUPPORTED
468# endif
469# ifndef PNG_NO_READ_SWAP
470# define PNG_READ_SWAP_SUPPORTED
471# endif
472# ifndef PNG_NO_READ_PACKSWAP
473# define PNG_READ_PACKSWAP_SUPPORTED
474# endif
475# ifndef PNG_NO_READ_INVERT
476# define PNG_READ_INVERT_SUPPORTED
477# endif
478# ifndef PNG_NO_READ_DITHER
479# define PNG_READ_DITHER_SUPPORTED
480# endif
481# ifndef PNG_NO_READ_BACKGROUND
482# define PNG_READ_BACKGROUND_SUPPORTED
483# endif
484# ifndef PNG_NO_READ_16_TO_8
485# define PNG_READ_16_TO_8_SUPPORTED
486# endif
487# ifndef PNG_NO_READ_FILLER
488# define PNG_READ_FILLER_SUPPORTED
489# endif
490# ifndef PNG_NO_READ_GAMMA
491# define PNG_READ_GAMMA_SUPPORTED
492# endif
493# ifndef PNG_NO_READ_GRAY_TO_RGB
494# define PNG_READ_GRAY_TO_RGB_SUPPORTED
495# endif
496# ifndef PNG_NO_READ_SWAP_ALPHA
497# define PNG_READ_SWAP_ALPHA_SUPPORTED
498# endif
499# ifndef PNG_NO_READ_INVERT_ALPHA
500# define PNG_READ_INVERT_ALPHA_SUPPORTED
501# endif
502# ifndef PNG_NO_READ_STRIP_ALPHA
503# define PNG_READ_STRIP_ALPHA_SUPPORTED
504# endif
505# ifndef PNG_NO_READ_USER_TRANSFORM
506# define PNG_READ_USER_TRANSFORM_SUPPORTED
507# endif
508# ifndef PNG_NO_READ_RGB_TO_GRAY
509# define PNG_READ_RGB_TO_GRAY_SUPPORTED
510# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600511#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600512
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500513#if !defined(PNG_NO_PROGRESSIVE_READ) && \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600514 !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
515# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600516#endif /* about interlacing capability! You'll */
517 /* still have interlacing unless you change the following line: */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600518
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600519#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500520
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500521#ifndef PNG_NO_READ_COMPOSITE_NODIV
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600522# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
523# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
524# endif
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500525#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500526
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500527#if !defined(PNG_NO_GET_INT_32) || defined(PNG_READ_oFFS_SUPPORTED) || \
528 defined(PNG_READ_pCAL_SUPPORTED)
529# ifndef PNG_GET_INT_32_SUPPORTED
530# define PNG_GET_INT_32_SUPPORTED
531# endif
532#endif
533
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600534#endif /* PNG_READ_SUPPORTED */
535
536#if defined(PNG_WRITE_SUPPORTED)
537
538# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
539 !defined(PNG_NO_WRITE_TRANSFORMS)
540# define PNG_WRITE_TRANSFORMS_SUPPORTED
541#endif
542
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600543#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600544# ifndef PNG_NO_WRITE_SHIFT
545# define PNG_WRITE_SHIFT_SUPPORTED
546# endif
547# ifndef PNG_NO_WRITE_PACK
548# define PNG_WRITE_PACK_SUPPORTED
549# endif
550# ifndef PNG_NO_WRITE_BGR
551# define PNG_WRITE_BGR_SUPPORTED
552# endif
553# ifndef PNG_NO_WRITE_SWAP
554# define PNG_WRITE_SWAP_SUPPORTED
555# endif
556# ifndef PNG_NO_WRITE_PACKSWAP
557# define PNG_WRITE_PACKSWAP_SUPPORTED
558# endif
559# ifndef PNG_NO_WRITE_INVERT
560# define PNG_WRITE_INVERT_SUPPORTED
561# endif
562# ifndef PNG_NO_WRITE_FILLER
563# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */
564# endif
565# ifndef PNG_NO_WRITE_SWAP_ALPHA
566# define PNG_WRITE_SWAP_ALPHA_SUPPORTED
567# endif
568# ifndef PNG_NO_WRITE_INVERT_ALPHA
569# define PNG_WRITE_INVERT_ALPHA_SUPPORTED
570# endif
571# ifndef PNG_NO_WRITE_USER_TRANSFORM
572# define PNG_WRITE_USER_TRANSFORM_SUPPORTED
573# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600574#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600575
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600576#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \
577 !defined(PNG_WRITE_INTERLACING_SUPPORTED)
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600578#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
579 encoders, but can cause trouble
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600580 if left undefined */
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600581#endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600582
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500583#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600584 !defined(PNG_WRITE_WEIGHTED_FILTER) && \
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500585 defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600586# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500587#endif
588
589#ifndef PNG_NO_WRITE_FLUSH
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600590# define PNG_WRITE_FLUSH_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500591#endif
592
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500593#if !defined(PNG_NO_SAVE_INT_32) || defined(PNG_WRITE_oFFS_SUPPORTED) || \
594 defined(PNG_WRITE_pCAL_SUPPORTED)
595# ifndef PNG_SAVE_INT_32_SUPPORTED
596# define PNG_SAVE_INT_32_SUPPORTED
597# endif
598#endif
599
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600600#endif /* PNG_WRITE_SUPPORTED */
601
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500602#ifndef PNG_NO_ERROR_NUMBERS
603# define PNG_ERROR_NUMBERS_SUPPORTED
604#endif
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500605
606#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
607 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
608# ifndef PNG_NO_USER_TRANSFORM_PTR
609# define PNG_USER_TRANSFORM_PTR_SUPPORTED
610# endif
611#endif
612
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500613#ifndef PNG_NO_STDIO
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600614# define PNG_TIME_RFC1123_SUPPORTED
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600615#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500616
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600617/* This adds extra functions in pngget.c for accessing data from the
618 * info pointer (added in version 0.99)
619 * png_get_image_width()
620 * png_get_image_height()
621 * png_get_bit_depth()
622 * png_get_color_type()
623 * png_get_compression_type()
624 * png_get_filter_type()
625 * png_get_interlace_type()
626 * png_get_pixel_aspect_ratio()
627 * png_get_pixels_per_meter()
628 * png_get_x_offset_pixels()
629 * png_get_y_offset_pixels()
630 * png_get_x_offset_microns()
631 * png_get_y_offset_microns()
632 */
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500633#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600634# define PNG_EASY_ACCESS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600635#endif
636
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500637/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
Glenn Randers-Pehrsoncdf140b2001-01-15 12:22:32 -0600638 even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500639#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
640# ifndef PNG_ASSEMBLER_CODE_SUPPORTED
641# define PNG_ASSEMBLER_CODE_SUPPORTED
642# endif
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600643# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) && \
644 defined(__MMX__)
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500645# define PNG_MMX_CODE_SUPPORTED
646# endif
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600647# if !defined(PNG_USE_PNGGCCRD) && !defined(PNG_NO_MMX_CODE) && \
Glenn Randers-Pehrsonf628ee22006-04-19 05:00:04 -0500648 !defined(PNG_USE_PNGVCRD) && defined(__MMX__)
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600649# define PNG_USE_PNGGCCRD
650# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500651#endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500652
Glenn Randers-Pehrson1ea0ff32001-08-07 22:25:59 -0500653/* If you are sure that you don't need thread safety and you are compiling
654 with PNG_USE_PNGCCRD for an MMX application, you can define this for
655 faster execution. See pnggccrd.c.
656#define PNG_THREAD_UNSAFE_OK
657*/
658
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500659#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
660# define PNG_USER_MEM_SUPPORTED
661#endif
662
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500663/* Added at libpng-1.2.6 */
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500664#ifndef PNG_SET_USER_LIMITS_SUPPORTED
665#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED)
666# define PNG_SET_USER_LIMITS_SUPPORTED
667#endif
668#endif
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500669
670/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter
671 * how large, set these limits to 0x7fffffffL
672 */
673#ifndef PNG_USER_WIDTH_MAX
674# define PNG_USER_WIDTH_MAX 1000000L
675#endif
676#ifndef PNG_USER_HEIGHT_MAX
677# define PNG_USER_HEIGHT_MAX 1000000L
678#endif
679
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600680/* These are currently experimental features, define them if you want */
681
682/* very little testing */
683/*
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600684#ifdef PNG_READ_SUPPORTED
685# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
686# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
687# endif
688#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600689*/
Andreas Dilger47a0c421997-05-16 02:46:07 -0500690
691/* This is only for PowerPC big-endian and 680x0 systems */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600692/* some testing */
693/*
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500694#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
695# define PNG_READ_BIG_ENDIAN_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600696#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600697*/
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500698
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -0500699/* Buggy compilers (e.g., gcc 2.7.2.2) need this */
700/*
701#define PNG_NO_POINTER_INDEXING
702*/
703
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600704/* These functions are turned off by default, as they will be phased out. */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600705/*
706#define PNG_USELESS_TESTS_SUPPORTED
707#define PNG_CORRECT_PALETTE_SUPPORTED
708*/
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600709
Andreas Dilger47a0c421997-05-16 02:46:07 -0500710/* Any chunks you are not interested in, you can undef here. The
711 * ones that allocate memory may be expecially important (hIST,
712 * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600713 * a bit smaller.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500714 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500715
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600716#if defined(PNG_READ_SUPPORTED) && \
717 !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500718 !defined(PNG_NO_READ_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600719# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600720#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600721
722#if defined(PNG_WRITE_SUPPORTED) && \
723 !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500724 !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600725# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600726#endif
727
728#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600729
730#ifdef PNG_NO_READ_TEXT
731# define PNG_NO_READ_iTXt
732# define PNG_NO_READ_tEXt
733# define PNG_NO_READ_zTXt
734#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500735#ifndef PNG_NO_READ_bKGD
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600736# define PNG_READ_bKGD_SUPPORTED
737# define PNG_bKGD_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500738#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500739#ifndef PNG_NO_READ_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600740# define PNG_READ_cHRM_SUPPORTED
741# define PNG_cHRM_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500742#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500743#ifndef PNG_NO_READ_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600744# define PNG_READ_gAMA_SUPPORTED
745# define PNG_gAMA_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500746#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500747#ifndef PNG_NO_READ_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600748# define PNG_READ_hIST_SUPPORTED
749# define PNG_hIST_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600750#endif
751#ifndef PNG_NO_READ_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600752# define PNG_READ_iCCP_SUPPORTED
753# define PNG_iCCP_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600754#endif
755#ifndef PNG_NO_READ_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500756# ifndef PNG_READ_iTXt_SUPPORTED
757# define PNG_READ_iTXt_SUPPORTED
758# endif
759# ifndef PNG_iTXt_SUPPORTED
760# define PNG_iTXt_SUPPORTED
761# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500762#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500763#ifndef PNG_NO_READ_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600764# define PNG_READ_oFFs_SUPPORTED
765# define PNG_oFFs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500766#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500767#ifndef PNG_NO_READ_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600768# define PNG_READ_pCAL_SUPPORTED
769# define PNG_pCAL_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600770#endif
771#ifndef PNG_NO_READ_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600772# define PNG_READ_sCAL_SUPPORTED
773# define PNG_sCAL_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500774#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500775#ifndef PNG_NO_READ_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600776# define PNG_READ_pHYs_SUPPORTED
777# define PNG_pHYs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500778#endif
779#ifndef PNG_NO_READ_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600780# define PNG_READ_sBIT_SUPPORTED
781# define PNG_sBIT_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600782#endif
783#ifndef PNG_NO_READ_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600784# define PNG_READ_sPLT_SUPPORTED
785# define PNG_sPLT_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500786#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500787#ifndef PNG_NO_READ_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600788# define PNG_READ_sRGB_SUPPORTED
789# define PNG_sRGB_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500790#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500791#ifndef PNG_NO_READ_tEXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600792# define PNG_READ_tEXt_SUPPORTED
793# define PNG_tEXt_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500794#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500795#ifndef PNG_NO_READ_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600796# define PNG_READ_tIME_SUPPORTED
797# define PNG_tIME_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500798#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500799#ifndef PNG_NO_READ_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600800# define PNG_READ_tRNS_SUPPORTED
801# define PNG_tRNS_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500802#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500803#ifndef PNG_NO_READ_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600804# define PNG_READ_zTXt_SUPPORTED
805# define PNG_zTXt_SUPPORTED
806#endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500807#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
808# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500809# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
810# define PNG_UNKNOWN_CHUNKS_SUPPORTED
811# endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500812# ifndef PNG_NO_HANDLE_AS_UNKNOWN
813# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
814# endif
815#endif
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -0500816#if !defined(PNG_NO_READ_USER_CHUNKS) && \
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500817 defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600818# define PNG_READ_USER_CHUNKS_SUPPORTED
819# define PNG_USER_CHUNKS_SUPPORTED
820# ifdef PNG_NO_READ_UNKNOWN_CHUNKS
821# undef PNG_NO_READ_UNKNOWN_CHUNKS
822# endif
823# ifdef PNG_NO_HANDLE_AS_UNKNOWN
824# undef PNG_NO_HANDLE_AS_UNKNOWN
825# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600826#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500827#ifndef PNG_NO_READ_OPT_PLTE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600828# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
829#endif /* optional PLTE chunk in RGB and RGBA images */
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600830#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600831 defined(PNG_READ_zTXt_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600832# define PNG_READ_TEXT_SUPPORTED
833# define PNG_TEXT_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600834#endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600835
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600836#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500837
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600838#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600839
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600840#ifdef PNG_NO_WRITE_TEXT
841# define PNG_NO_WRITE_iTXt
842# define PNG_NO_WRITE_tEXt
843# define PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600844#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600845#ifndef PNG_NO_WRITE_bKGD
846# define PNG_WRITE_bKGD_SUPPORTED
847# ifndef PNG_bKGD_SUPPORTED
848# define PNG_bKGD_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_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600852# define PNG_WRITE_cHRM_SUPPORTED
853# ifndef PNG_cHRM_SUPPORTED
854# define PNG_cHRM_SUPPORTED
855# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500856#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500857#ifndef PNG_NO_WRITE_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600858# define PNG_WRITE_gAMA_SUPPORTED
859# ifndef PNG_gAMA_SUPPORTED
860# define PNG_gAMA_SUPPORTED
861# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500862#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500863#ifndef PNG_NO_WRITE_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600864# define PNG_WRITE_hIST_SUPPORTED
865# ifndef PNG_hIST_SUPPORTED
866# define PNG_hIST_SUPPORTED
867# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600868#endif
869#ifndef PNG_NO_WRITE_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600870# define PNG_WRITE_iCCP_SUPPORTED
871# ifndef PNG_iCCP_SUPPORTED
872# define PNG_iCCP_SUPPORTED
873# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600874#endif
875#ifndef PNG_NO_WRITE_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500876# ifndef PNG_WRITE_iTXt_SUPPORTED
877# define PNG_WRITE_iTXt_SUPPORTED
878# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600879# ifndef PNG_iTXt_SUPPORTED
880# define PNG_iTXt_SUPPORTED
881# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500882#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500883#ifndef PNG_NO_WRITE_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600884# define PNG_WRITE_oFFs_SUPPORTED
885# ifndef PNG_oFFs_SUPPORTED
886# define PNG_oFFs_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_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600890# define PNG_WRITE_pCAL_SUPPORTED
891# ifndef PNG_pCAL_SUPPORTED
892# define PNG_pCAL_SUPPORTED
893# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600894#endif
895#ifndef PNG_NO_WRITE_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600896# define PNG_WRITE_sCAL_SUPPORTED
897# ifndef PNG_sCAL_SUPPORTED
898# define PNG_sCAL_SUPPORTED
899# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500900#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500901#ifndef PNG_NO_WRITE_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600902# define PNG_WRITE_pHYs_SUPPORTED
903# ifndef PNG_pHYs_SUPPORTED
904# define PNG_pHYs_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_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600908# define PNG_WRITE_sBIT_SUPPORTED
909# ifndef PNG_sBIT_SUPPORTED
910# define PNG_sBIT_SUPPORTED
911# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600912#endif
913#ifndef PNG_NO_WRITE_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600914# define PNG_WRITE_sPLT_SUPPORTED
915# ifndef PNG_sPLT_SUPPORTED
916# define PNG_sPLT_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_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600920# define PNG_WRITE_sRGB_SUPPORTED
921# ifndef PNG_sRGB_SUPPORTED
922# define PNG_sRGB_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_tEXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600926# define PNG_WRITE_tEXt_SUPPORTED
927# ifndef PNG_tEXt_SUPPORTED
928# define PNG_tEXt_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_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600932# define PNG_WRITE_tIME_SUPPORTED
933# ifndef PNG_tIME_SUPPORTED
934# define PNG_tIME_SUPPORTED
935# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500936#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500937#ifndef PNG_NO_WRITE_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600938# define PNG_WRITE_tRNS_SUPPORTED
939# ifndef PNG_tRNS_SUPPORTED
940# define PNG_tRNS_SUPPORTED
941# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500942#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500943#ifndef PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600944# define PNG_WRITE_zTXt_SUPPORTED
945# ifndef PNG_zTXt_SUPPORTED
946# define PNG_zTXt_SUPPORTED
947# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600948#endif
949#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600950# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
951# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
952# define PNG_UNKNOWN_CHUNKS_SUPPORTED
953# endif
954# ifndef PNG_NO_HANDLE_AS_UNKNOWN
955# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
956# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
957# endif
958# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600959#endif
960#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600961 defined(PNG_WRITE_zTXt_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600962# define PNG_WRITE_TEXT_SUPPORTED
963# ifndef PNG_TEXT_SUPPORTED
964# define PNG_TEXT_SUPPORTED
965# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500966#endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600967
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600968#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500969
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600970/* Turn this off to disable png_read_png() and
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600971 * png_write_png() and leave the row_pointers member
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600972 * out of the info structure.
973 */
974#ifndef PNG_NO_INFO_IMAGE
975# define PNG_INFO_IMAGE_SUPPORTED
976#endif
977
Andreas Dilger47a0c421997-05-16 02:46:07 -0500978/* need the time information for reading tIME chunks */
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600979#if defined(PNG_tIME_SUPPORTED)
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500980# if !defined(_WIN32_WCE)
981 /* "time.h" functions are not supported on WindowsCE */
982# include <time.h>
983# endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500984#endif
985
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600986/* Some typedefs to get us started. These should be safe on most of the
Andreas Dilger47a0c421997-05-16 02:46:07 -0500987 * common platforms. The typedefs should be at least as large as the
988 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
989 * don't have to be exactly that size. Some compilers dislike passing
990 * unsigned shorts as function parameters, so you may be better off using
991 * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may
992 * want to have unsigned int for png_uint_32 instead of unsigned long.
993 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500994
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500995#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
996typedef unsigned int png_uint_32;
997typedef int png_int_32;
998#else
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500999typedef unsigned long png_uint_32;
1000typedef long png_int_32;
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05001001#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001002typedef unsigned short png_uint_16;
1003typedef short png_int_16;
1004typedef unsigned char png_byte;
1005
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001006/* This is usually size_t. It is typedef'ed just in case you need it to
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001007 change (I'm not sure if you will or not, so I thought I'd be safe) */
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05001008#ifdef PNG_SIZE_T
1009 typedef PNG_SIZE_T png_size_t;
1010# define png_sizeof(x) png_convert_size(sizeof (x))
1011#else
1012 typedef size_t png_size_t;
1013# define png_sizeof(x) sizeof (x)
1014#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001015
Andreas Dilger47a0c421997-05-16 02:46:07 -05001016/* The following is needed for medium model support. It cannot be in the
1017 * PNG_INTERNAL section. Needs modification for other compilers besides
1018 * MSC. Model independent support declares all arrays and pointers to be
1019 * large using the far keyword. The zlib version used must also support
1020 * model independent data. As of version zlib 1.0.4, the necessary changes
1021 * have been made in zlib. The USE_FAR_KEYWORD define triggers other
1022 * changes that are needed. (Tim Wegner)
1023 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001024
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001025/* Separate compiler dependencies (problem here is that zlib.h always
1026 defines FAR. (SJT) */
Guy Schalnat6d764711995-12-19 03:22:19 -06001027#ifdef __BORLANDC__
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001028# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
1029# define LDATA 1
1030# else
1031# define LDATA 0
1032# endif
1033 /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
1034# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
1035# define PNG_MAX_MALLOC_64K
1036# if (LDATA != 1)
1037# ifndef FAR
1038# define FAR __far
1039# endif
1040# define USE_FAR_KEYWORD
1041# endif /* LDATA != 1 */
1042 /* Possibly useful for moving data out of default segment.
1043 * Uncomment it if you want. Could also define FARDATA as
1044 * const if your compiler supports it. (SJT)
1045# define FARDATA FAR
1046 */
1047# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
Guy Schalnatb2e01bd1996-01-26 01:38:47 -06001048#endif /* __BORLANDC__ */
Guy Schalnat6d764711995-12-19 03:22:19 -06001049
1050
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001051/* Suggest testing for specific compiler first before testing for
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001052 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
1053 * making reliance oncertain keywords suspect. (SJT)
1054 */
Guy Schalnat6d764711995-12-19 03:22:19 -06001055
1056/* MSC Medium model */
1057#if defined(FAR)
1058# if defined(M_I86MM)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001059# define USE_FAR_KEYWORD
1060# define FARDATA FAR
1061# include <dos.h>
Guy Schalnat6d764711995-12-19 03:22:19 -06001062# endif
1063#endif
1064
1065/* SJT: default case */
1066#ifndef FAR
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001067# define FAR
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001068#endif
1069
Andreas Dilger47a0c421997-05-16 02:46:07 -05001070/* At this point FAR is always defined */
Guy Schalnat6d764711995-12-19 03:22:19 -06001071#ifndef FARDATA
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001072# define FARDATA
Guy Schalnat6d764711995-12-19 03:22:19 -06001073#endif
1074
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001075/* Typedef for floating-point numbers that are converted
1076 to fixed-point with a multiple of 100,000, e.g., int_gamma */
1077typedef png_int_32 png_fixed_point;
1078
Andreas Dilger47a0c421997-05-16 02:46:07 -05001079/* Add typedefs for pointers */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001080typedef void FAR * png_voidp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001081typedef png_byte FAR * png_bytep;
1082typedef png_uint_32 FAR * png_uint_32p;
1083typedef png_int_32 FAR * png_int_32p;
1084typedef png_uint_16 FAR * png_uint_16p;
1085typedef png_int_16 FAR * png_int_16p;
1086typedef PNG_CONST char FAR * png_const_charp;
1087typedef char FAR * png_charp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001088typedef png_fixed_point FAR * png_fixed_point_p;
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001089
1090#ifndef PNG_NO_STDIO
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -05001091#if defined(_WIN32_WCE)
1092typedef HANDLE png_FILE_p;
1093#else
1094typedef FILE * png_FILE_p;
1095#endif
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001096#endif
1097
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001098#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001099typedef double FAR * png_doublep;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001100#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001101
Andreas Dilger47a0c421997-05-16 02:46:07 -05001102/* Pointers to pointers; i.e. arrays */
Guy Schalnat6d764711995-12-19 03:22:19 -06001103typedef png_byte FAR * FAR * png_bytepp;
1104typedef png_uint_32 FAR * FAR * png_uint_32pp;
1105typedef png_int_32 FAR * FAR * png_int_32pp;
1106typedef png_uint_16 FAR * FAR * png_uint_16pp;
1107typedef png_int_16 FAR * FAR * png_int_16pp;
1108typedef PNG_CONST char FAR * FAR * png_const_charpp;
1109typedef char FAR * FAR * png_charpp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001110typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001111#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001112typedef double FAR * FAR * png_doublepp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001113#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001114
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001115/* Pointers to pointers to pointers; i.e., pointer to array */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001116typedef char FAR * FAR * FAR * png_charppp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001117
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001118/*
1119 * Define PNG_BUILD_DLL if the module being built is a Windows
1120 * LIBPNG DLL.
1121 *
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001122 * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL.
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -06001123 * It is equivalent to Microsoft predefined macro _DLL that is
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001124 * automatically defined when you compile using the share
1125 * version of the CRT (C Run-Time library)
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001126 *
1127 * The cygwin mods make this behavior a little different:
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001128 * Define PNG_BUILD_DLL if you are building a dll for use with cygwin
1129 * Define PNG_STATIC if you are building a static library for use with cygwin,
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001130 * -or- if you are building an application that you want to link to the
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001131 * static library.
1132 * PNG_USE_DLL is defined by default (no user action needed) unless one of
1133 * the other flags is defined.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001134 */
1135
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001136#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001137# define PNG_DLL
1138#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001139/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib.
1140 * When building a static lib, default to no GLOBAL ARRAYS, but allow
1141 * command-line override
1142 */
1143#if defined(__CYGWIN__)
1144# if !defined(PNG_STATIC)
1145# if defined(PNG_USE_GLOBAL_ARRAYS)
1146# undef PNG_USE_GLOBAL_ARRAYS
1147# endif
1148# if !defined(PNG_USE_LOCAL_ARRAYS)
1149# define PNG_USE_LOCAL_ARRAYS
1150# endif
1151# else
1152# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS)
1153# if defined(PNG_USE_GLOBAL_ARRAYS)
1154# undef PNG_USE_GLOBAL_ARRAYS
1155# endif
1156# endif
1157# endif
1158# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
1159# define PNG_USE_LOCAL_ARRAYS
1160# endif
1161#endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001162
Glenn Randers-Pehrsonec61c232000-05-16 06:17:36 -05001163/* Do not use global arrays (helps with building DLL's)
1164 * They are no longer used in libpng itself, since version 1.0.5c,
1165 * but might be required for some pre-1.0.5c applications.
1166 */
1167#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
1168# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL))
1169# define PNG_USE_LOCAL_ARRAYS
1170# else
1171# define PNG_USE_GLOBAL_ARRAYS
1172# endif
1173#endif
1174
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001175#if defined(__CYGWIN__)
1176# undef PNGAPI
1177# define PNGAPI __cdecl
1178# undef PNG_IMPEXP
1179# define PNG_IMPEXP
1180#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001181
Glenn Randers-Pehrson25d82242002-05-01 11:51:26 -05001182/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
1183 * you may get warnings regarding the linkage of png_zalloc and png_zfree.
1184 * Don't ignore those warnings; you must also reset the default calling
1185 * convention in your compiler to match your PNGAPI, and you must build
1186 * zlib and your applications the same way you build libpng.
1187 */
1188
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001189#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001190# ifndef PNG_NO_MODULEDEF
1191# define PNG_NO_MODULEDEF
1192# endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001193#endif
1194
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001195#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001196# define PNG_IMPEXP
1197#endif
1198
1199#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001200 (( defined(_Windows) || defined(_WINDOWS) || \
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -05001201 defined(WIN32) || defined(_WIN32) || defined(__WIN32__) ))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001202
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001203# ifndef PNGAPI
1204# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
1205# define PNGAPI __cdecl
1206# else
1207# define PNGAPI _cdecl
1208# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001209# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001210
1211# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \
1212 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */)
1213# define PNG_IMPEXP
1214# endif
1215
1216# if !defined(PNG_IMPEXP)
1217
1218# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol
1219# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol
1220
1221 /* Borland/Microsoft */
1222# if defined(_MSC_VER) || defined(__BORLANDC__)
1223# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
1224# define PNG_EXPORT PNG_EXPORT_TYPE1
1225# else
1226# define PNG_EXPORT PNG_EXPORT_TYPE2
1227# if defined(PNG_BUILD_DLL)
1228# define PNG_IMPEXP __export
1229# else
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -05001230# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in
1231 VC++ */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001232# endif /* Exists in Borland C++ for
1233 C++ classes (== huge) */
1234# endif
1235# endif
1236
1237# if !defined(PNG_IMPEXP)
1238# if defined(PNG_BUILD_DLL)
1239# define PNG_IMPEXP __declspec(dllexport)
1240# else
1241# define PNG_IMPEXP __declspec(dllimport)
1242# endif
1243# endif
1244# endif /* PNG_IMPEXP */
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001245#else /* !(DLL || non-cygwin WINDOWS) */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001246# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
1247# ifndef PNGAPI
1248# define PNGAPI _System
Glenn Randers-Pehrsonf64a06f2001-04-11 07:38:00 -05001249# endif
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001250# else
1251# if 0 /* ... other platforms, with other meanings */
1252# endif
1253# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001254#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001255
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -06001256#ifndef PNGAPI
1257# define PNGAPI
1258#endif
1259#ifndef PNG_IMPEXP
1260# define PNG_IMPEXP
1261#endif
1262
Glenn Randers-Pehrsonc3dda6d2004-11-27 18:22:29 -06001263#ifdef PNG_BUILDSYMS
1264# ifndef PNG_EXPORT
1265# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END
1266# endif
1267# ifdef PNG_USE_GLOBAL_ARRAYS
1268# ifndef PNG_EXPORT_VAR
1269# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT
1270# endif
1271# endif
1272#endif
1273
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -05001274#ifndef PNG_EXPORT
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001275# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001276#endif
1277
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001278#ifdef PNG_USE_GLOBAL_ARRAYS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001279# ifndef PNG_EXPORT_VAR
1280# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type
1281# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001282#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001283
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001284/* User may want to use these so they are not in PNG_INTERNAL. Any library
1285 * functions that are passed far data must be model independent.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001286 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001287
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001288#ifdef PNG_SETJMP_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001289# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06001290#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001291# define png_jmpbuf(png_ptr) \
1292 (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED)
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001293#endif
1294
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001295/* memory model/platform independent fns */
1296#ifndef PNG_ABORT
1297# ifdef _WINDOWS_
1298# define PNG_ABORT() ExitProcess(0)
1299# else
1300# define PNG_ABORT() abort()
1301# endif
1302#endif
1303
1304#if defined(USE_FAR_KEYWORD)
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001305/* use this to make far-to-near assignments */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001306# define CHECK 1
1307# define NOCHECK 0
1308# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
1309# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001310# define png_strcpy _fstrcpy
1311# define png_strncpy _fstrncpy /* Added to v 1.2.6 */
1312# define png_strlen _fstrlen
1313# define png_memcmp _fmemcmp /* SJT: added */
1314# define png_memcpy _fmemcpy
1315# define png_memset _fmemset
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001316# define png_sprintf sprintf
1317#else
1318# if defined(_WINDOWS_) /* favor Windows over C runtime fns */
1319# define CVT_PTR(ptr) (ptr)
1320# define CVT_PTR_NOCHECK(ptr) (ptr)
1321# define png_strcpy lstrcpyA
1322# define png_strncpy lstrcpynA
1323# define png_strlen lstrlenA
1324# define png_memcmp memcmp
1325# define png_memcpy CopyMemory
1326# define png_memset memset
1327# define png_sprintf wsprintfA
1328# else
1329# define CVT_PTR(ptr) (ptr)
1330# define CVT_PTR_NOCHECK(ptr) (ptr)
1331# define png_strcpy strcpy
1332# define png_strncpy strncpy /* Added to v 1.2.6 */
1333# define png_strlen strlen
1334# define png_memcmp memcmp /* SJT: added */
1335# define png_memcpy memcpy
1336# define png_memset memset
1337# define png_sprintf sprintf
1338# endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001339#endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001340
1341#if defined(__TURBOC__) && !defined(__FLAT__)
1342# define png_mem_alloc farmalloc
1343# define png_mem_free farfree
1344 typedef unsigned long png_mem_size_t;
1345#else
1346# if defined(_MSC_VER) && defined(MAXSEG_64K)
1347# define png_mem_alloc(s) halloc(s, 1)
1348# define png_mem_free hfree
1349 typedef unsigned long png_mem_size_t;
1350#else
1351# if defined(_WINDOWS_)
1352# define png_mem_alloc(s) HeapAlloc(GetProcessHeap(), 0, s)
1353# define png_mem_free(p) HeapFree(GetProcessHeap(), 0, p)
1354 typedef SIZE_T png_mem_size_t;
1355# else
1356# define png_mem_alloc malloc
1357# define png_mem_free free
1358 typedef size_t png_mem_size_t;
1359# endif
1360# endif
1361#endif
1362/* End of memory model/platform independent support */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001363
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001364/* Just a little check that someone hasn't tried to define something
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001365 * contradictory.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001366 */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001367#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001368# undef PNG_ZBUF_SIZE
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001369# define PNG_ZBUF_SIZE 65536L
Andreas Dilger47a0c421997-05-16 02:46:07 -05001370#endif
1371
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001372
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -06001373/* Added at libpng-1.2.8 */
1374#endif /* PNG_VERSION_INFO_ONLY */
Glenn Randers-Pehrson40936072004-11-20 11:18:40 -06001375
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001376#endif /* PNGCONF_H */