blob: f3a1514ed583b1c354ebe8127327c9d6dd0db333 [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-Pehrson6a9c2ce2009-03-27 19:30:10 -05004 * libpng version 1.4.0beta52 - March 28, 2009
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06005 * For conditions of distribution and use, see copyright notice in png.h
Glenn Randers-Pehrson79134c62009-02-14 10:32:18 -06006 * Copyright (c) 1998-2009 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-Pehrson6bc53be2006-06-16 07:52:03 -050020#ifndef PNG_NO_LIMITS_H
21#include <limits.h>
22#endif
23
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -050024/* Added at libpng-1.2.9 */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -050025
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -050026/* config.h is created by and PNG_CONFIGURE_LIBPNG is set by the "configure" script. */
Glenn Randers-Pehrsond5d63602006-04-15 06:37:45 -050027#ifdef PNG_CONFIGURE_LIBPNG
Glenn Randers-Pehrson170b70c2006-03-10 10:19:04 -060028#ifdef HAVE_CONFIG_H
Glenn Randers-Pehrsonb0270f72006-04-15 18:23:04 -050029#include "config.h"
Glenn Randers-Pehrsond5d63602006-04-15 06:37:45 -050030#endif
Glenn Randers-Pehrson170b70c2006-03-10 10:19:04 -060031#endif
32
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060033/*
34 * Added at libpng-1.2.8
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -050035 *
36 * PNG_USER_CONFIG has to be defined on the compiler command line. This
37 * includes the resource compiler for Windows DLL configurations.
38 */
39#ifdef PNG_USER_CONFIG
40# ifndef PNG_USER_PRIVATEBUILD
41# define PNG_USER_PRIVATEBUILD
42# endif
43#include "pngusr.h"
44#endif
45
Glenn Randers-Pehrson0ffb71a2009-02-28 06:08:20 -060046/* Added at libpng-1.4.0beta49 for testing */
47#ifndef PNG_NO_CALLOC
48# define PNG_CALLOC_SUPPORTED
49#endif
50
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -050051/*
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060052 * If you create a private DLL you need to define in "pngusr.h" the followings:
53 * #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
54 * the DLL was built>
55 * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
56 * #define PNG_USER_DLLFNAME_POSTFIX <two-letter postfix that serve to
57 * distinguish your DLL from those of the official release. These
58 * correspond to the trailing letters that come after the version
59 * number and must match your private DLL name>
60 * e.g. // private DLL "libpng13gx.dll"
61 * #define PNG_USER_DLLFNAME_POSTFIX "gx"
62 *
63 * The following macros are also at your disposal if you want to complete the
64 * DLL VERSIONINFO structure.
65 * - PNG_USER_VERSIONINFO_COMMENTS
66 * - PNG_USER_VERSIONINFO_COMPANYNAME
67 * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS
68 */
69
70#ifdef __STDC__
71#ifdef SPECIALBUILD
72# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\
73 are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.")
74#endif
75
76#ifdef PRIVATEBUILD
Glenn Randers-Pehrson3a512032006-03-31 05:29:33 -060077# pragma message("PRIVATEBUILD is deprecated.\
78 Use PNG_USER_PRIVATEBUILD instead.")
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060079# define PNG_USER_PRIVATEBUILD PRIVATEBUILD
80#endif
81#endif /* __STDC__ */
82
83#ifndef PNG_VERSION_INFO_ONLY
84
85/* End of material added to libpng-1.2.8 */
Glenn Randers-Pehrson878b31e2004-11-12 22:04:56 -060086
Andreas Dilger02ad0ef1997-01-17 01:34:35 -060087/* This is the size of the compression buffer, and thus the size of
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060088 * an IDAT chunk. Make this whatever size you feel is best for your
89 * machine. One of these will be allocated per png_struct. When this
90 * is full, it writes the data to the disk, and does some other
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -060091 * calculations. Making this an extremely small size will slow
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060092 * the library down, but you may want to experiment to determine
93 * where it becomes significant, if you are concerned with memory
94 * usage. Note that zlib allocates at least 32Kb also. For readers,
95 * this describes the size of the buffer available to read the data in.
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060096 * Unless this gets smaller than the size of a row (compressed),
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060097 * it should not make much difference how big this is.
98 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050099
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600100#ifndef PNG_ZBUF_SIZE
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600101# define PNG_ZBUF_SIZE 8192
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600102#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500103
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600104/* Enable if you want a write-only libpng */
105
106#ifndef PNG_NO_READ_SUPPORTED
107# define PNG_READ_SUPPORTED
108#endif
109
110/* Enable if you want a read-only libpng */
111
112#ifndef PNG_NO_WRITE_SUPPORTED
113# define PNG_WRITE_SUPPORTED
114#endif
115
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500116/* Enabled in 1.4.0. */
117#ifdef PNG_ALLOW_BENIGN_ERRORS
118# define png_benign_error png_warning
119# define png_chunk_benign_error png_chunk_warning
120#else
121# ifndef PNG_BENIGN_ERRORS_SUPPORTED
122# define png_benign_error png_error
123# define png_chunk_benign_error png_chunk_error
124# endif
125#endif
126
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500127/* Enabled by default in 1.2.0. You can disable this if you don't need to
128 support PNGs that are embedded in MNG datastreams */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500129#if !defined(PNG_NO_MNG_FEATURES)
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600130# ifndef PNG_MNG_FEATURES_SUPPORTED
131# define PNG_MNG_FEATURES_SUPPORTED
132# endif
133#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600134
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -0600135#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600136# ifndef PNG_FLOATING_POINT_SUPPORTED
137# define PNG_FLOATING_POINT_SUPPORTED
138# endif
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500139#endif
140
Andreas Dilger47a0c421997-05-16 02:46:07 -0500141/* If you are running on a machine where you cannot allocate more
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600142 * than 64K of memory at once, uncomment this. While libpng will not
143 * normally need that much memory in a chunk (unless you load up a very
144 * large file), zlib needs to know how big of a chunk it can use, and
145 * libpng thus makes sure to check any memory allocation to verify it
146 * will fit into memory.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500147#define PNG_MAX_MALLOC_64K
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600148 */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500149#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600150# define PNG_MAX_MALLOC_64K
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500151#endif
152
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500153/* Special munging to support doing things the 'cygwin' way:
154 * 'Normal' png-on-win32 defines/defaults:
155 * PNG_BUILD_DLL -- building dll
156 * PNG_USE_DLL -- building an application, linking to dll
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -0600157 * (no define) -- building static library, or building an
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500158 * application and linking to the static lib
159 * 'Cygwin' defines/defaults:
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500160 * PNG_BUILD_DLL -- (ignored) building the dll
161 * (no define) -- (ignored) building an application, linking to the dll
162 * PNG_STATIC -- (ignored) building the static lib, or building an
163 * application that links to the static lib.
164 * ALL_STATIC -- (ignored) building various static libs, or building an
165 * application that links to the static libs.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500166 * Thus,
167 * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
168 * this bit of #ifdefs will define the 'correct' config variables based on
169 * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but
170 * unnecessary.
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500171 *
172 * Also, the precedence order is:
173 * ALL_STATIC (since we can't #undef something outside our namespace)
174 * PNG_BUILD_DLL
175 * PNG_STATIC
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500176 * (nothing) == PNG_USE_DLL
177 *
178 * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
179 * of auto-import in binutils, we no longer need to worry about
180 * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore,
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500181 * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
182 * to __declspec() stuff. However, we DO need to worry about
183 * PNG_BUILD_DLL and PNG_STATIC because those change some defaults
184 * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500185 */
186#if defined(__CYGWIN__)
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500187# if defined(ALL_STATIC)
188# if defined(PNG_BUILD_DLL)
189# undef PNG_BUILD_DLL
190# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500191# if defined(PNG_USE_DLL)
192# undef PNG_USE_DLL
193# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500194# if defined(PNG_DLL)
195# undef PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500196# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500197# if !defined(PNG_STATIC)
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -0600198# define PNG_STATIC
199# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500200# else
201# if defined (PNG_BUILD_DLL)
202# if defined(PNG_STATIC)
203# undef PNG_STATIC
204# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500205# if defined(PNG_USE_DLL)
206# undef PNG_USE_DLL
207# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500208# if !defined(PNG_DLL)
209# define PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500210# endif
211# else
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500212# if defined(PNG_STATIC)
213# if defined(PNG_USE_DLL)
214# undef PNG_USE_DLL
215# endif
216# if defined(PNG_DLL)
217# undef PNG_DLL
218# endif
219# else
220# if !defined(PNG_USE_DLL)
221# define PNG_USE_DLL
222# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500223# if !defined(PNG_DLL)
224# define PNG_DLL
225# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500226# endif
227# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500228# endif
229#endif
230
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500231/* This protects us against compilers that run on a windowing system
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600232 * and thus don't have or would rather us not use the stdio types:
233 * stdin, stdout, and stderr. The only one currently used is stderr
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600234 * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will
235 * prevent these from being compiled and used. #defining PNG_NO_STDIO
236 * will also prevent these, plus will prevent the entire set of stdio
237 * macros and functions (FILE *, printf, etc.) from being compiled and used,
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500238 * unless (PNG_DEBUG > 0) has been #defined.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600239 *
240 * #define PNG_NO_CONSOLE_IO
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600241 * #define PNG_NO_STDIO
242 */
Guy Schalnat6d764711995-12-19 03:22:19 -0600243
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500244#if defined(_WIN32_WCE)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600245# include <windows.h>
246 /* Console I/O functions are not supported on WindowsCE */
247# define PNG_NO_CONSOLE_IO
248# ifdef PNG_DEBUG
249# undef PNG_DEBUG
250# endif
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500251#endif
252
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -0500253#ifdef PNG_BUILD_DLL
254# ifndef PNG_CONSOLE_IO_SUPPORTED
255# ifndef PNG_NO_CONSOLE_IO
256# define PNG_NO_CONSOLE_IO
257# endif
258# endif
259#endif
260
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600261# ifdef PNG_NO_STDIO
262# ifndef PNG_NO_CONSOLE_IO
263# define PNG_NO_CONSOLE_IO
264# endif
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500265# ifdef PNG_DEBUG
266# if (PNG_DEBUG > 0)
267# include <stdio.h>
268# endif
269# endif
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600270# else
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500271# include <stdio.h>
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600272# endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600273
274/* This macro protects us against machines that don't have function
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600275 * prototypes (ie K&R style headers). If your compiler does not handle
276 * function prototypes, define this macro and use the included ansi2knr.
277 * I've always been able to use _NO_PROTO as the indicator, but you may
278 * need to drag the empty declaration out in front of here, or change the
279 * ifdef to suit your own needs.
280 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500281#ifndef PNGARG
282
Andreas Dilger47a0c421997-05-16 02:46:07 -0500283#ifdef OF /* zlib prototype munger */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600284# define PNGARG(arglist) OF(arglist)
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500285#else
286
287#ifdef _NO_PROTO
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600288# define PNGARG(arglist) ()
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500289#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600290# define PNGARG(arglist) arglist
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500291#endif /* _NO_PROTO */
292
293#endif /* OF */
294
295#endif /* PNGARG */
296
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600297/* Try to determine if we are compiling on a Mac. Note that testing for
298 * just __MWERKS__ is not good enough, because the Codewarrior is now used
299 * on non-Mac platforms.
300 */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600301#ifndef MACOS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600302# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
303 defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
304# define MACOS
305# endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600306#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600307
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500308/* enough people need this for various reasons to include it here */
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500309#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600310# include <sys/types.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500311#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600312
Glenn Randers-Pehrsonb1828932001-06-23 08:03:17 -0500313#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600314# define PNG_SETJMP_SUPPORTED
315#endif
316
317#ifdef PNG_SETJMP_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -0500318/* This is an attempt to force a single setjmp behaviour on Linux. If
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600319 * the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
320 */
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500321
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600322# ifdef __linux__
323# ifdef _BSD_SOURCE
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500324# define PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600325# undef _BSD_SOURCE
326# endif
327# ifdef _SETJMP_H
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -0500328 /* If you encounter a compiler error here, see the explanation
329 * near the end of INSTALL.
330 */
331 __png.h__ already includes setjmp.h;
332 __dont__ include it again.;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600333# endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600334# endif /* __linux__ */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500335
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600336 /* include setjmp.h for error handling */
337# include <setjmp.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500338
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600339# ifdef __linux__
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500340# ifdef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson56f63962008-10-06 10:16:17 -0500341# ifdef _BSD_SOURCE
342# undef _BSD_SOURCE
343# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600344# define _BSD_SOURCE
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500345# undef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600346# endif
347# endif /* __linux__ */
348#endif /* PNG_SETJMP_SUPPORTED */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600349
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500350#ifdef BSD
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600351# include <strings.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500352#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600353# include <string.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500354#endif
355
Andreas Dilger47a0c421997-05-16 02:46:07 -0500356/* Other defines for things like memory and the like can go here. */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500357
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500358/* This controls how fine the dithering gets. As this allocates
359 * a largish chunk of memory (32K), those who are not as concerned
360 * with dithering quality can decrease some or all of these.
361 */
362#ifndef PNG_DITHER_RED_BITS
363# define PNG_DITHER_RED_BITS 5
364#endif
365#ifndef PNG_DITHER_GREEN_BITS
366# define PNG_DITHER_GREEN_BITS 5
367#endif
368#ifndef PNG_DITHER_BLUE_BITS
369# define PNG_DITHER_BLUE_BITS 5
370#endif
371
372/* This controls how fine the gamma correction becomes when you
373 * are only interested in 8 bits anyway. Increasing this value
374 * results in more memory being used, and more pow() functions
375 * being called to fill in the gamma tables. Don't set this value
376 * less then 8, and even that may not work (I haven't tested it).
377 */
378
379#ifndef PNG_MAX_GAMMA_8
380# define PNG_MAX_GAMMA_8 11
381#endif
382
383/* This controls how much a difference in gamma we can tolerate before
384 * we actually start doing gamma conversion.
385 */
386#ifndef PNG_GAMMA_THRESHOLD
387# define PNG_GAMMA_THRESHOLD 0.05
388#endif
389
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600390/* The following uses const char * instead of char * for error
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600391 * and warning message functions, so some compilers won't complain.
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600392 * If you do not want to use const, define PNG_NO_CONST here.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600393 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600394
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600395#ifndef PNG_NO_CONST
Guy Schalnat6d764711995-12-19 03:22:19 -0600396# define PNG_CONST const
397#else
398# define PNG_CONST
399#endif
400
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600401/* The following defines give you the ability to remove code from the
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600402 * library that you will not be using. I wish I could figure out how to
403 * automate this, but I can't do that without making it seriously hard
404 * on the users. So if you are not using an ability, change the #define
405 * to and #undef, and that part of the library will not be compiled. If
406 * your linker can't find a function, you may want to make sure the
407 * ability is defined here. Some of these depend upon some others being
408 * defined. I haven't figured out all the interactions here, so you may
409 * have to experiment awhile to get everything to compile. If you are
410 * creating or using a shared library, you probably shouldn't touch this,
411 * as it will affect the size of the structures, and this will cause bad
412 * things to happen if the library and/or application ever change.
413 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500414
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500415/* Any features you will not be using can be undef'ed here */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600416
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600417/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500418 * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS
419 * on the compile line, then pick and choose which ones to define without
420 * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED
421 * if you only want to have a png-compliant reader/writer but don't need
422 * any of the extra transformations. This saves about 80 kbytes in a
423 * typical installation of the library. (PNG_NO_* form added in version
424 * 1.0.1c, for consistency)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600425 */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600426
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500427/* The size of the png_text structure changed in libpng-1.0.6 when
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600428 * iTXt support was added. iTXt support was turned off by default through
429 * libpng-1.2.x, to support old apps that malloc the png_text structure
430 * instead of calling png_set_text() and letting libpng malloc it. It
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500431 * was turned on by default in libpng-1.4.0.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500432 */
433
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600434#if !defined(PNG_NO_iTXt_SUPPORTED)
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500435# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt)
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600436# define PNG_READ_iTXt
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500437# endif
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500438# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt)
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600439# define PNG_WRITE_iTXt
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500440# endif
441#endif
442
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500443/* The following support, added after version 1.0.0, can be turned off here en
444 * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility
445 * with old applications that require the length of png_struct and png_info
446 * to remain unchanged.
447 */
448
449#ifdef PNG_LEGACY_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600450# define PNG_NO_FREE_ME
451# define PNG_NO_READ_UNKNOWN_CHUNKS
452# define PNG_NO_WRITE_UNKNOWN_CHUNKS
453# define PNG_NO_READ_USER_CHUNKS
454# define PNG_NO_READ_iCCP
455# define PNG_NO_WRITE_iCCP
456# define PNG_NO_READ_iTXt
457# define PNG_NO_WRITE_iTXt
458# define PNG_NO_READ_sCAL
459# define PNG_NO_WRITE_sCAL
460# define PNG_NO_READ_sPLT
461# define PNG_NO_WRITE_sPLT
462# define PNG_NO_INFO_IMAGE
463# define PNG_NO_READ_RGB_TO_GRAY
464# define PNG_NO_READ_USER_TRANSFORM
465# define PNG_NO_WRITE_USER_TRANSFORM
466# define PNG_NO_USER_MEM
467# define PNG_NO_READ_EMPTY_PLTE
468# define PNG_NO_MNG_FEATURES
469# define PNG_NO_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500470#endif
471
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500472/* Ignore attempt to turn off both floating and fixed point support */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500473#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600474 !defined(PNG_NO_FIXED_POINT_SUPPORTED)
475# define PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500476#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600477
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500478#ifndef PNG_NO_FREE_ME
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600479# define PNG_FREE_ME_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500480#endif
481
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600482#if defined(PNG_READ_SUPPORTED)
483
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500484#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600485 !defined(PNG_NO_READ_TRANSFORMS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600486# define PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600487#endif
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600488
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600489#ifdef PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600490# ifndef PNG_NO_READ_EXPAND
491# define PNG_READ_EXPAND_SUPPORTED
492# endif
493# ifndef PNG_NO_READ_SHIFT
494# define PNG_READ_SHIFT_SUPPORTED
495# endif
496# ifndef PNG_NO_READ_PACK
497# define PNG_READ_PACK_SUPPORTED
498# endif
499# ifndef PNG_NO_READ_BGR
500# define PNG_READ_BGR_SUPPORTED
501# endif
502# ifndef PNG_NO_READ_SWAP
503# define PNG_READ_SWAP_SUPPORTED
504# endif
505# ifndef PNG_NO_READ_PACKSWAP
506# define PNG_READ_PACKSWAP_SUPPORTED
507# endif
508# ifndef PNG_NO_READ_INVERT
509# define PNG_READ_INVERT_SUPPORTED
510# endif
Glenn Randers-Pehrson4a82d692008-12-15 16:25:05 -0600511#if 0 /* removed from libpng-1.4.0 */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600512# ifndef PNG_NO_READ_DITHER
513# define PNG_READ_DITHER_SUPPORTED
514# endif
Glenn Randers-Pehrson4a82d692008-12-15 16:25:05 -0600515#endif /* 0 */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600516# ifndef PNG_NO_READ_BACKGROUND
517# define PNG_READ_BACKGROUND_SUPPORTED
518# endif
519# ifndef PNG_NO_READ_16_TO_8
520# define PNG_READ_16_TO_8_SUPPORTED
521# endif
522# ifndef PNG_NO_READ_FILLER
523# define PNG_READ_FILLER_SUPPORTED
524# endif
525# ifndef PNG_NO_READ_GAMMA
526# define PNG_READ_GAMMA_SUPPORTED
527# endif
528# ifndef PNG_NO_READ_GRAY_TO_RGB
529# define PNG_READ_GRAY_TO_RGB_SUPPORTED
530# endif
531# ifndef PNG_NO_READ_SWAP_ALPHA
532# define PNG_READ_SWAP_ALPHA_SUPPORTED
533# endif
534# ifndef PNG_NO_READ_INVERT_ALPHA
535# define PNG_READ_INVERT_ALPHA_SUPPORTED
536# endif
Glenn Randers-Pehrson1916f6a2008-08-14 13:44:49 -0500537# ifndef PNG_NO_READ_PREMULTIPLY_ALPHA
538# define PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
539# endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600540# ifndef PNG_NO_READ_STRIP_ALPHA
541# define PNG_READ_STRIP_ALPHA_SUPPORTED
542# endif
543# ifndef PNG_NO_READ_USER_TRANSFORM
544# define PNG_READ_USER_TRANSFORM_SUPPORTED
545# endif
546# ifndef PNG_NO_READ_RGB_TO_GRAY
547# define PNG_READ_RGB_TO_GRAY_SUPPORTED
548# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600549#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600550
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500551#if !defined(PNG_NO_PROGRESSIVE_READ) && \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600552 !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
553# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600554#endif /* about interlacing capability! You'll */
555 /* still have interlacing unless you change the following line: */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600556
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600557#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500558
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500559#ifndef PNG_NO_READ_COMPOSITE_NODIV
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600560# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
561# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
562# endif
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500563#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500564
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500565#if !defined(PNG_NO_GET_INT_32) || defined(PNG_READ_oFFS_SUPPORTED) || \
566 defined(PNG_READ_pCAL_SUPPORTED)
567# ifndef PNG_GET_INT_32_SUPPORTED
568# define PNG_GET_INT_32_SUPPORTED
569# endif
570#endif
571
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600572#endif /* PNG_READ_SUPPORTED */
573
574#if defined(PNG_WRITE_SUPPORTED)
575
576# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
577 !defined(PNG_NO_WRITE_TRANSFORMS)
578# define PNG_WRITE_TRANSFORMS_SUPPORTED
579#endif
580
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600581#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600582# ifndef PNG_NO_WRITE_SHIFT
583# define PNG_WRITE_SHIFT_SUPPORTED
584# endif
585# ifndef PNG_NO_WRITE_PACK
586# define PNG_WRITE_PACK_SUPPORTED
587# endif
588# ifndef PNG_NO_WRITE_BGR
589# define PNG_WRITE_BGR_SUPPORTED
590# endif
591# ifndef PNG_NO_WRITE_SWAP
592# define PNG_WRITE_SWAP_SUPPORTED
593# endif
594# ifndef PNG_NO_WRITE_PACKSWAP
595# define PNG_WRITE_PACKSWAP_SUPPORTED
596# endif
597# ifndef PNG_NO_WRITE_INVERT
598# define PNG_WRITE_INVERT_SUPPORTED
599# endif
600# ifndef PNG_NO_WRITE_FILLER
601# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */
602# endif
603# ifndef PNG_NO_WRITE_SWAP_ALPHA
604# define PNG_WRITE_SWAP_ALPHA_SUPPORTED
605# endif
606# ifndef PNG_NO_WRITE_INVERT_ALPHA
607# define PNG_WRITE_INVERT_ALPHA_SUPPORTED
608# endif
609# ifndef PNG_NO_WRITE_USER_TRANSFORM
610# define PNG_WRITE_USER_TRANSFORM_SUPPORTED
611# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600612#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600613
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600614#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \
615 !defined(PNG_WRITE_INTERLACING_SUPPORTED)
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600616#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
617 encoders, but can cause trouble
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600618 if left undefined */
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600619#endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600620
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500621#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600622 !defined(PNG_WRITE_WEIGHTED_FILTER) && \
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500623 defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600624# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500625#endif
626
627#ifndef PNG_NO_WRITE_FLUSH
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600628# define PNG_WRITE_FLUSH_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500629#endif
630
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500631#if !defined(PNG_NO_SAVE_INT_32) || defined(PNG_WRITE_oFFS_SUPPORTED) || \
632 defined(PNG_WRITE_pCAL_SUPPORTED)
633# ifndef PNG_SAVE_INT_32_SUPPORTED
634# define PNG_SAVE_INT_32_SUPPORTED
635# endif
636#endif
637
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600638#endif /* PNG_WRITE_SUPPORTED */
639
Glenn Randers-Pehrson895a9c92008-07-25 08:51:18 -0500640#define PNG_NO_ERROR_NUMBERS
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500641
642#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
643 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
644# ifndef PNG_NO_USER_TRANSFORM_PTR
645# define PNG_USER_TRANSFORM_PTR_SUPPORTED
646# endif
647#endif
648
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500649#ifndef PNG_NO_STDIO
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600650# define PNG_TIME_RFC1123_SUPPORTED
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600651#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500652
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600653/* This adds extra functions in pngget.c for accessing data from the
654 * info pointer (added in version 0.99)
655 * png_get_image_width()
656 * png_get_image_height()
657 * png_get_bit_depth()
658 * png_get_color_type()
659 * png_get_compression_type()
660 * png_get_filter_type()
661 * png_get_interlace_type()
662 * png_get_pixel_aspect_ratio()
663 * png_get_pixels_per_meter()
664 * png_get_x_offset_pixels()
665 * png_get_y_offset_pixels()
666 * png_get_x_offset_microns()
667 * png_get_y_offset_microns()
668 */
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500669#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600670# define PNG_EASY_ACCESS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600671#endif
672
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500673#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
674# define PNG_USER_MEM_SUPPORTED
675#endif
676
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500677/* Added at libpng-1.2.6 */
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500678#ifndef PNG_SET_USER_LIMITS_SUPPORTED
679#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED)
680# define PNG_SET_USER_LIMITS_SUPPORTED
681#endif
682#endif
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500683
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500684/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGs no matter
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500685 * how large, set these limits to 0x7fffffffL
686 */
687#ifndef PNG_USER_WIDTH_MAX
688# define PNG_USER_WIDTH_MAX 1000000L
689#endif
690#ifndef PNG_USER_HEIGHT_MAX
691# define PNG_USER_HEIGHT_MAX 1000000L
692#endif
693
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500694/* Added at libpng-1.4.0 */
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -0500695#ifndef PNG_USER_CHUNK_CACHE_MAX
696# define PNG_USER_CHUNK_CACHE_MAX 0x7ffffffLL
697#endif
698
699/* Added at libpng-1.4.0 */
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500700#if !defined(PNG_NO_IO_STATE) && !defined(PNG_IO_STATE_SUPPORTED)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500701# define PNG_IO_STATE_SUPPORTED
702#endif
703
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500704#ifndef PNG_LITERAL_SHARP
705# define PNG_LITERAL_SHARP 0x23
706#endif
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500707#ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500708# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500709#endif
710#ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500711# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500712#endif
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500713#ifndef PNG_STRING_NEWLINE
Glenn Randers-Pehrsone0784c72008-08-09 07:11:44 -0500714#define PNG_STRING_NEWLINE "\n"
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500715#endif
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500716
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600717/* These are currently experimental features, define them if you want */
718
719/* very little testing */
720/*
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600721#ifdef PNG_READ_SUPPORTED
722# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
723# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
724# endif
725#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600726*/
Andreas Dilger47a0c421997-05-16 02:46:07 -0500727
728/* This is only for PowerPC big-endian and 680x0 systems */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600729/* some testing */
730/*
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500731#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
732# define PNG_READ_BIG_ENDIAN_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600733#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600734*/
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500735
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500736#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
737# define PNG_USE_READ_MACROS
738#endif
739
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -0500740/* Buggy compilers (e.g., gcc 2.7.2.2) need this */
741/*
742#define PNG_NO_POINTER_INDEXING
743*/
744
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600745
Andreas Dilger47a0c421997-05-16 02:46:07 -0500746/* Any chunks you are not interested in, you can undef here. The
747 * ones that allocate memory may be expecially important (hIST,
748 * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600749 * a bit smaller.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500750 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500751
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600752#if defined(PNG_READ_SUPPORTED) && \
753 !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500754 !defined(PNG_NO_READ_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600755# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600756#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600757
758#if defined(PNG_WRITE_SUPPORTED) && \
759 !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500760 !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600761# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600762#endif
763
764#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600765
766#ifdef PNG_NO_READ_TEXT
767# define PNG_NO_READ_iTXt
768# define PNG_NO_READ_tEXt
769# define PNG_NO_READ_zTXt
770#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500771#ifndef PNG_NO_READ_bKGD
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600772# define PNG_READ_bKGD_SUPPORTED
773# define PNG_bKGD_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500774#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500775#ifndef PNG_NO_READ_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600776# define PNG_READ_cHRM_SUPPORTED
777# define PNG_cHRM_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500778#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500779#ifndef PNG_NO_READ_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600780# define PNG_READ_gAMA_SUPPORTED
781# define PNG_gAMA_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500782#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500783#ifndef PNG_NO_READ_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600784# define PNG_READ_hIST_SUPPORTED
785# define PNG_hIST_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600786#endif
787#ifndef PNG_NO_READ_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600788# define PNG_READ_iCCP_SUPPORTED
789# define PNG_iCCP_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600790#endif
791#ifndef PNG_NO_READ_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500792# ifndef PNG_READ_iTXt_SUPPORTED
793# define PNG_READ_iTXt_SUPPORTED
794# endif
795# ifndef PNG_iTXt_SUPPORTED
796# define PNG_iTXt_SUPPORTED
797# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500798#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500799#ifndef PNG_NO_READ_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600800# define PNG_READ_oFFs_SUPPORTED
801# define PNG_oFFs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500802#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500803#ifndef PNG_NO_READ_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600804# define PNG_READ_pCAL_SUPPORTED
805# define PNG_pCAL_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600806#endif
807#ifndef PNG_NO_READ_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600808# define PNG_READ_sCAL_SUPPORTED
809# define PNG_sCAL_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500810#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500811#ifndef PNG_NO_READ_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600812# define PNG_READ_pHYs_SUPPORTED
813# define PNG_pHYs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500814#endif
815#ifndef PNG_NO_READ_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600816# define PNG_READ_sBIT_SUPPORTED
817# define PNG_sBIT_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600818#endif
819#ifndef PNG_NO_READ_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600820# define PNG_READ_sPLT_SUPPORTED
821# define PNG_sPLT_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500822#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500823#ifndef PNG_NO_READ_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600824# define PNG_READ_sRGB_SUPPORTED
825# define PNG_sRGB_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500826#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500827#ifndef PNG_NO_READ_tEXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600828# define PNG_READ_tEXt_SUPPORTED
829# define PNG_tEXt_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500830#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500831#ifndef PNG_NO_READ_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600832# define PNG_READ_tIME_SUPPORTED
833# define PNG_tIME_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500834#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500835#ifndef PNG_NO_READ_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600836# define PNG_READ_tRNS_SUPPORTED
837# define PNG_tRNS_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500838#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500839#ifndef PNG_NO_READ_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600840# define PNG_READ_zTXt_SUPPORTED
841# define PNG_zTXt_SUPPORTED
842#endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500843#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
844# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500845# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
846# define PNG_UNKNOWN_CHUNKS_SUPPORTED
847# endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500848# ifndef PNG_NO_HANDLE_AS_UNKNOWN
849# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
850# endif
851#endif
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -0500852#if !defined(PNG_NO_READ_USER_CHUNKS) && \
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500853 defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600854# define PNG_READ_USER_CHUNKS_SUPPORTED
855# define PNG_USER_CHUNKS_SUPPORTED
856# ifdef PNG_NO_READ_UNKNOWN_CHUNKS
857# undef PNG_NO_READ_UNKNOWN_CHUNKS
858# endif
859# ifdef PNG_NO_HANDLE_AS_UNKNOWN
860# undef PNG_NO_HANDLE_AS_UNKNOWN
861# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600862#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500863#ifndef PNG_NO_READ_OPT_PLTE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600864# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
865#endif /* optional PLTE chunk in RGB and RGBA images */
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600866#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600867 defined(PNG_READ_zTXt_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600868# define PNG_READ_TEXT_SUPPORTED
869# define PNG_TEXT_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600870#endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600871
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600872#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500873
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600874#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600875
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600876#ifdef PNG_NO_WRITE_TEXT
877# define PNG_NO_WRITE_iTXt
878# define PNG_NO_WRITE_tEXt
879# define PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600880#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600881#ifndef PNG_NO_WRITE_bKGD
882# define PNG_WRITE_bKGD_SUPPORTED
883# ifndef PNG_bKGD_SUPPORTED
884# define PNG_bKGD_SUPPORTED
885# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500886#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500887#ifndef PNG_NO_WRITE_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600888# define PNG_WRITE_cHRM_SUPPORTED
889# ifndef PNG_cHRM_SUPPORTED
890# define PNG_cHRM_SUPPORTED
891# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500892#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500893#ifndef PNG_NO_WRITE_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600894# define PNG_WRITE_gAMA_SUPPORTED
895# ifndef PNG_gAMA_SUPPORTED
896# define PNG_gAMA_SUPPORTED
897# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500898#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500899#ifndef PNG_NO_WRITE_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600900# define PNG_WRITE_hIST_SUPPORTED
901# ifndef PNG_hIST_SUPPORTED
902# define PNG_hIST_SUPPORTED
903# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600904#endif
905#ifndef PNG_NO_WRITE_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600906# define PNG_WRITE_iCCP_SUPPORTED
907# ifndef PNG_iCCP_SUPPORTED
908# define PNG_iCCP_SUPPORTED
909# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600910#endif
911#ifndef PNG_NO_WRITE_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500912# ifndef PNG_WRITE_iTXt_SUPPORTED
913# define PNG_WRITE_iTXt_SUPPORTED
914# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600915# ifndef PNG_iTXt_SUPPORTED
916# define PNG_iTXt_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_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600920# define PNG_WRITE_oFFs_SUPPORTED
921# ifndef PNG_oFFs_SUPPORTED
922# define PNG_oFFs_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_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600926# define PNG_WRITE_pCAL_SUPPORTED
927# ifndef PNG_pCAL_SUPPORTED
928# define PNG_pCAL_SUPPORTED
929# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600930#endif
931#ifndef PNG_NO_WRITE_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600932# define PNG_WRITE_sCAL_SUPPORTED
933# ifndef PNG_sCAL_SUPPORTED
934# define PNG_sCAL_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_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600938# define PNG_WRITE_pHYs_SUPPORTED
939# ifndef PNG_pHYs_SUPPORTED
940# define PNG_pHYs_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_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600944# define PNG_WRITE_sBIT_SUPPORTED
945# ifndef PNG_sBIT_SUPPORTED
946# define PNG_sBIT_SUPPORTED
947# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600948#endif
949#ifndef PNG_NO_WRITE_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600950# define PNG_WRITE_sPLT_SUPPORTED
951# ifndef PNG_sPLT_SUPPORTED
952# define PNG_sPLT_SUPPORTED
953# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500954#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500955#ifndef PNG_NO_WRITE_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600956# define PNG_WRITE_sRGB_SUPPORTED
957# ifndef PNG_sRGB_SUPPORTED
958# define PNG_sRGB_SUPPORTED
959# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500960#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500961#ifndef PNG_NO_WRITE_tEXt
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-Pehrson8686fff1998-05-21 09:27:50 -0500967#ifndef PNG_NO_WRITE_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600968# define PNG_WRITE_tIME_SUPPORTED
969# ifndef PNG_tIME_SUPPORTED
970# define PNG_tIME_SUPPORTED
971# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500972#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500973#ifndef PNG_NO_WRITE_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600974# define PNG_WRITE_tRNS_SUPPORTED
975# ifndef PNG_tRNS_SUPPORTED
976# define PNG_tRNS_SUPPORTED
977# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500978#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500979#ifndef PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600980# define PNG_WRITE_zTXt_SUPPORTED
981# ifndef PNG_zTXt_SUPPORTED
982# define PNG_zTXt_SUPPORTED
983# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600984#endif
985#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600986# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
987# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
988# define PNG_UNKNOWN_CHUNKS_SUPPORTED
989# endif
990# ifndef PNG_NO_HANDLE_AS_UNKNOWN
991# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
992# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
993# endif
994# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600995#endif
996#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600997 defined(PNG_WRITE_zTXt_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600998# define PNG_WRITE_TEXT_SUPPORTED
999# ifndef PNG_TEXT_SUPPORTED
1000# define PNG_TEXT_SUPPORTED
1001# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05001002#endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001003
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -06001004#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001005
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001006/* Turn this off to disable png_read_png() and
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001007 * png_write_png() and leave the row_pointers member
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001008 * out of the info structure.
1009 */
1010#ifndef PNG_NO_INFO_IMAGE
1011# define PNG_INFO_IMAGE_SUPPORTED
1012#endif
1013
Andreas Dilger47a0c421997-05-16 02:46:07 -05001014/* need the time information for reading tIME chunks */
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001015#if defined(PNG_tIME_SUPPORTED)
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -05001016# if !defined(_WIN32_WCE)
1017 /* "time.h" functions are not supported on WindowsCE */
1018# include <time.h>
1019# endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001020#endif
1021
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001022/* Some typedefs to get us started. These should be safe on most of the
Andreas Dilger47a0c421997-05-16 02:46:07 -05001023 * common platforms. The typedefs should be at least as large as the
1024 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
1025 * don't have to be exactly that size. Some compilers dislike passing
1026 * unsigned shorts as function parameters, so you may be better off using
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001027 * unsigned int for png_uint_16.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001028 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001029
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05001030#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
1031typedef unsigned int png_uint_32;
1032typedef int png_int_32;
1033#else
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001034typedef unsigned long png_uint_32;
1035typedef long png_int_32;
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05001036#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001037typedef unsigned short png_uint_16;
1038typedef short png_int_16;
1039typedef unsigned char png_byte;
1040
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001041#ifdef PNG_NO_SIZE_T
1042 typedef unsigned int png_size_t;
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05001043#else
1044 typedef size_t png_size_t;
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05001045#endif
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001046#define png_sizeof(x) sizeof(x)
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001047
Andreas Dilger47a0c421997-05-16 02:46:07 -05001048/* The following is needed for medium model support. It cannot be in the
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05001049 * pngpriv.h header. Needs modification for other compilers besides
Andreas Dilger47a0c421997-05-16 02:46:07 -05001050 * MSC. Model independent support declares all arrays and pointers to be
1051 * large using the far keyword. The zlib version used must also support
1052 * model independent data. As of version zlib 1.0.4, the necessary changes
1053 * have been made in zlib. The USE_FAR_KEYWORD define triggers other
1054 * changes that are needed. (Tim Wegner)
1055 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001056
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001057/* Separate compiler dependencies (problem here is that zlib.h always
1058 defines FAR. (SJT) */
Guy Schalnat6d764711995-12-19 03:22:19 -06001059#ifdef __BORLANDC__
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001060# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
1061# define LDATA 1
1062# else
1063# define LDATA 0
1064# endif
1065 /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
1066# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
1067# define PNG_MAX_MALLOC_64K
1068# if (LDATA != 1)
1069# ifndef FAR
1070# define FAR __far
1071# endif
1072# define USE_FAR_KEYWORD
1073# endif /* LDATA != 1 */
1074 /* Possibly useful for moving data out of default segment.
1075 * Uncomment it if you want. Could also define FARDATA as
1076 * const if your compiler supports it. (SJT)
1077# define FARDATA FAR
1078 */
1079# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
Guy Schalnatb2e01bd1996-01-26 01:38:47 -06001080#endif /* __BORLANDC__ */
Guy Schalnat6d764711995-12-19 03:22:19 -06001081
1082
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001083/* Suggest testing for specific compiler first before testing for
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001084 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
1085 * making reliance oncertain keywords suspect. (SJT)
1086 */
Guy Schalnat6d764711995-12-19 03:22:19 -06001087
1088/* MSC Medium model */
1089#if defined(FAR)
1090# if defined(M_I86MM)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001091# define USE_FAR_KEYWORD
1092# define FARDATA FAR
1093# include <dos.h>
Guy Schalnat6d764711995-12-19 03:22:19 -06001094# endif
1095#endif
1096
1097/* SJT: default case */
1098#ifndef FAR
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001099# define FAR
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001100#endif
1101
Andreas Dilger47a0c421997-05-16 02:46:07 -05001102/* At this point FAR is always defined */
Guy Schalnat6d764711995-12-19 03:22:19 -06001103#ifndef FARDATA
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001104# define FARDATA
Guy Schalnat6d764711995-12-19 03:22:19 -06001105#endif
1106
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001107/* Typedef for floating-point numbers that are converted
1108 to fixed-point with a multiple of 100,000, e.g., int_gamma */
1109typedef png_int_32 png_fixed_point;
1110
Andreas Dilger47a0c421997-05-16 02:46:07 -05001111/* Add typedefs for pointers */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001112typedef void FAR * png_voidp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001113typedef png_byte FAR * png_bytep;
1114typedef png_uint_32 FAR * png_uint_32p;
1115typedef png_int_32 FAR * png_int_32p;
1116typedef png_uint_16 FAR * png_uint_16p;
1117typedef png_int_16 FAR * png_int_16p;
1118typedef PNG_CONST char FAR * png_const_charp;
1119typedef char FAR * png_charp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001120typedef png_fixed_point FAR * png_fixed_point_p;
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001121
1122#ifndef PNG_NO_STDIO
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -05001123#if defined(_WIN32_WCE)
1124typedef HANDLE png_FILE_p;
1125#else
1126typedef FILE * png_FILE_p;
1127#endif
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001128#endif
1129
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001130#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001131typedef double FAR * png_doublep;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001132#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001133
Andreas Dilger47a0c421997-05-16 02:46:07 -05001134/* Pointers to pointers; i.e. arrays */
Guy Schalnat6d764711995-12-19 03:22:19 -06001135typedef png_byte FAR * FAR * png_bytepp;
1136typedef png_uint_32 FAR * FAR * png_uint_32pp;
1137typedef png_int_32 FAR * FAR * png_int_32pp;
1138typedef png_uint_16 FAR * FAR * png_uint_16pp;
1139typedef png_int_16 FAR * FAR * png_int_16pp;
1140typedef PNG_CONST char FAR * FAR * png_const_charpp;
1141typedef char FAR * FAR * png_charpp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001142typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001143#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001144typedef double FAR * FAR * png_doublepp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001145#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001146
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001147/* Pointers to pointers to pointers; i.e., pointer to array */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001148typedef char FAR * FAR * FAR * png_charppp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001149
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001150/*
1151 * Define PNG_BUILD_DLL if the module being built is a Windows
1152 * LIBPNG DLL.
1153 *
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001154 * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL.
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -06001155 * It is equivalent to Microsoft predefined macro _DLL that is
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001156 * automatically defined when you compile using the share
1157 * version of the CRT (C Run-Time library)
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001158 *
1159 * The cygwin mods make this behavior a little different:
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001160 * Define PNG_BUILD_DLL if you are building a dll for use with cygwin
1161 * Define PNG_STATIC if you are building a static library for use with cygwin,
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001162 * -or- if you are building an application that you want to link to the
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001163 * static library.
1164 * PNG_USE_DLL is defined by default (no user action needed) unless one of
1165 * the other flags is defined.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001166 */
1167
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001168#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001169# define PNG_DLL
1170#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001171/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib.
1172 * When building a static lib, default to no GLOBAL ARRAYS, but allow
1173 * command-line override
1174 */
1175#if defined(__CYGWIN__)
1176# if !defined(PNG_STATIC)
1177# if defined(PNG_USE_GLOBAL_ARRAYS)
1178# undef PNG_USE_GLOBAL_ARRAYS
1179# endif
1180# if !defined(PNG_USE_LOCAL_ARRAYS)
1181# define PNG_USE_LOCAL_ARRAYS
1182# endif
1183# else
1184# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS)
1185# if defined(PNG_USE_GLOBAL_ARRAYS)
1186# undef PNG_USE_GLOBAL_ARRAYS
1187# endif
1188# endif
1189# endif
1190# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
1191# define PNG_USE_LOCAL_ARRAYS
1192# endif
1193#endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001194
Glenn Randers-Pehrsonec61c232000-05-16 06:17:36 -05001195/* Do not use global arrays (helps with building DLL's)
1196 * They are no longer used in libpng itself, since version 1.0.5c,
1197 * but might be required for some pre-1.0.5c applications.
1198 */
1199#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
1200# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL))
1201# define PNG_USE_LOCAL_ARRAYS
1202# else
1203# define PNG_USE_GLOBAL_ARRAYS
1204# endif
1205#endif
1206
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001207#if defined(__CYGWIN__)
1208# undef PNGAPI
1209# define PNGAPI __cdecl
1210# undef PNG_IMPEXP
1211# define PNG_IMPEXP
1212#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001213
Glenn Randers-Pehrson25d82242002-05-01 11:51:26 -05001214/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
1215 * you may get warnings regarding the linkage of png_zalloc and png_zfree.
1216 * Don't ignore those warnings; you must also reset the default calling
1217 * convention in your compiler to match your PNGAPI, and you must build
1218 * zlib and your applications the same way you build libpng.
1219 */
1220
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001221#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001222# ifndef PNG_NO_MODULEDEF
1223# define PNG_NO_MODULEDEF
1224# endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001225#endif
1226
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001227#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001228# define PNG_IMPEXP
1229#endif
1230
1231#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001232 (( defined(_Windows) || defined(_WINDOWS) || \
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -05001233 defined(WIN32) || defined(_WIN32) || defined(__WIN32__) ))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001234
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001235# ifndef PNGAPI
1236# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
1237# define PNGAPI __cdecl
1238# else
1239# define PNGAPI _cdecl
1240# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001241# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001242
1243# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \
1244 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */)
1245# define PNG_IMPEXP
1246# endif
1247
1248# if !defined(PNG_IMPEXP)
1249
1250# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol
1251# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol
1252
1253 /* Borland/Microsoft */
1254# if defined(_MSC_VER) || defined(__BORLANDC__)
1255# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
1256# define PNG_EXPORT PNG_EXPORT_TYPE1
1257# else
1258# define PNG_EXPORT PNG_EXPORT_TYPE2
1259# if defined(PNG_BUILD_DLL)
1260# define PNG_IMPEXP __export
1261# else
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -05001262# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in
1263 VC++ */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001264# endif /* Exists in Borland C++ for
1265 C++ classes (== huge) */
1266# endif
1267# endif
1268
1269# if !defined(PNG_IMPEXP)
1270# if defined(PNG_BUILD_DLL)
1271# define PNG_IMPEXP __declspec(dllexport)
1272# else
1273# define PNG_IMPEXP __declspec(dllimport)
1274# endif
1275# endif
1276# endif /* PNG_IMPEXP */
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001277#else /* !(DLL || non-cygwin WINDOWS) */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001278# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
1279# ifndef PNGAPI
1280# define PNGAPI _System
Glenn Randers-Pehrsonf64a06f2001-04-11 07:38:00 -05001281# endif
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001282# else
1283# if 0 /* ... other platforms, with other meanings */
1284# endif
1285# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001286#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001287
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -06001288#ifndef PNGAPI
1289# define PNGAPI
1290#endif
1291#ifndef PNG_IMPEXP
1292# define PNG_IMPEXP
1293#endif
1294
Glenn Randers-Pehrsonc3dda6d2004-11-27 18:22:29 -06001295#ifdef PNG_BUILDSYMS
1296# ifndef PNG_EXPORT
1297# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END
1298# endif
1299# ifdef PNG_USE_GLOBAL_ARRAYS
1300# ifndef PNG_EXPORT_VAR
1301# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT
1302# endif
1303# endif
1304#endif
1305
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -05001306#ifndef PNG_EXPORT
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001307# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001308#endif
1309
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001310#ifdef PNG_USE_GLOBAL_ARRAYS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001311# ifndef PNG_EXPORT_VAR
1312# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type
1313# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001314#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001315
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001316/* Users may want to use these so they are not private. Any library
1317 * functions that are passed far data must be model-independent.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001318 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001319
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001320#ifdef PNG_SETJMP_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001321# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06001322#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001323# define png_jmpbuf(png_ptr) \
1324 (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED)
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001325#endif
1326
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001327/* memory model/platform independent fns */
1328#ifndef PNG_ABORT
1329# ifdef _WINDOWS_
1330# define PNG_ABORT() ExitProcess(0)
1331# else
1332# define PNG_ABORT() abort()
1333# endif
1334#endif
1335
1336#if defined(USE_FAR_KEYWORD)
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001337/* use this to make far-to-near assignments */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001338# define CHECK 1
1339# define NOCHECK 0
1340# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
1341# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001342# define png_strcpy _fstrcpy
1343# define png_strncpy _fstrncpy /* Added to v 1.2.6 */
1344# define png_strlen _fstrlen
1345# define png_memcmp _fmemcmp /* SJT: added */
1346# define png_memcpy _fmemcpy
1347# define png_memset _fmemset
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001348# define png_sprintf sprintf
1349#else
1350# if defined(_WINDOWS_) /* favor Windows over C runtime fns */
1351# define CVT_PTR(ptr) (ptr)
1352# define CVT_PTR_NOCHECK(ptr) (ptr)
1353# define png_strcpy lstrcpyA
1354# define png_strncpy lstrcpynA
1355# define png_strlen lstrlenA
1356# define png_memcmp memcmp
1357# define png_memcpy CopyMemory
1358# define png_memset memset
1359# define png_sprintf wsprintfA
1360# else
1361# define CVT_PTR(ptr) (ptr)
1362# define CVT_PTR_NOCHECK(ptr) (ptr)
1363# define png_strcpy strcpy
1364# define png_strncpy strncpy /* Added to v 1.2.6 */
1365# define png_strlen strlen
1366# define png_memcmp memcmp /* SJT: added */
1367# define png_memcpy memcpy
1368# define png_memset memset
1369# define png_sprintf sprintf
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001370# ifndef PNG_NO_SNPRINTF
1371# ifdef _MSC_VER
1372# define png_snprintf _snprintf /* Added to v 1.2.19 */
1373# define png_snprintf2 _snprintf
1374# define png_snprintf6 _snprintf
1375# else
1376# define png_snprintf snprintf /* Added to v 1.2.19 */
1377# define png_snprintf2 snprintf
1378# define png_snprintf6 snprintf
1379# endif
1380# else
1381 /* You don't have or don't want to use snprintf(). Caution: Using
1382 * sprintf instead of snprintf exposes your application to accidental
1383 * or malevolent buffer overflows. If you don't have snprintf()
1384 * as a general rule you should provide one (you can get one from
1385 * Portable OpenSSH). */
1386# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1)
1387# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2)
1388# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
1389 sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
1390# endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001391# endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001392#endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001393
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001394/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
1395 * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
1396 * to png_alloc_size_t are not necessary; in fact, it is recommended
1397 * not to use them at all so that the compiler can complain when something
1398 * turns out to be problematic.
1399 * Casts in the other direction (from png_alloc_size_t to png_size_t or
1400 * png_uint_32) should be explicitly applied; however, we do not expect
1401 * to encounter practical situations that require such conversions.
1402 */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001403#if defined(__TURBOC__) && !defined(__FLAT__)
1404# define png_mem_alloc farmalloc
1405# define png_mem_free farfree
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001406 typedef unsigned long png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001407#else
1408# if defined(_MSC_VER) && defined(MAXSEG_64K)
1409# define png_mem_alloc(s) halloc(s, 1)
1410# define png_mem_free hfree
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001411 typedef unsigned long png_alloc_size_t;
1412# else
1413# if defined(_WINDOWS_) && (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001414# define png_mem_alloc(s) HeapAlloc(GetProcessHeap(), 0, s)
1415# define png_mem_free(p) HeapFree(GetProcessHeap(), 0, p)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001416 typedef DWORD png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001417# else
1418# define png_mem_alloc malloc
1419# define png_mem_free free
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001420 typedef png_size_t png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001421# endif
1422# endif
1423#endif
1424/* End of memory model/platform independent support */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001425
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001426/* Just a little check that someone hasn't tried to define something
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001427 * contradictory.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001428 */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001429#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001430# undef PNG_ZBUF_SIZE
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001431# define PNG_ZBUF_SIZE 65536L
Andreas Dilger47a0c421997-05-16 02:46:07 -05001432#endif
1433
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001434
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -06001435/* Added at libpng-1.2.8 */
1436#endif /* PNG_VERSION_INFO_ONLY */
Glenn Randers-Pehrson40936072004-11-20 11:18:40 -06001437
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001438#endif /* PNGCONF_H */