blob: b81a544000ab472a78426ff0d2f6692c7e9a8fb1 [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-Pehrson glennrp@comcast.net389c6552009-05-02 21:52:10 -05004 * libpng version 1.4.0beta58 - May 3, 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.
Glenn Randers-Pehrsona93c9422009-04-13 11:41:33 -0500320 *
321 * You can bypass this test if you know that your application uses exactly
322 * the same setjmp.h that was included when libpng was built. Only define
323 * PNG_SKIP_SETJMP_CHECK while building your application, prior to the
324 * application's '#include "png.h"'. Don't define PNG_SKIP_SETJMP_CHECK
325 * while building a separate libpng library for general use.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600326 */
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500327
Glenn Randers-Pehrsona93c9422009-04-13 11:41:33 -0500328# ifndef PNG_SKIP_SETJMP_CHECK
329# ifdef __linux__
330# ifdef _BSD_SOURCE
331# define PNG_SAVE_BSD_SOURCE
332# undef _BSD_SOURCE
333# endif
334# ifdef _SETJMP_H
335 /* If you encounter a compiler error here, see the explanation
336 * near the end of INSTALL.
337 */
338 __pngconf.h__ in libpng already includes setjmp.h;
339 __dont__ include it again.;
340# endif
341# endif /* __linux__ */
342# endif /* PNG_SKIP_SETJMP_CHECK */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500343
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600344 /* include setjmp.h for error handling */
345# include <setjmp.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500346
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600347# ifdef __linux__
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500348# ifdef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson56f63962008-10-06 10:16:17 -0500349# ifdef _BSD_SOURCE
350# undef _BSD_SOURCE
351# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600352# define _BSD_SOURCE
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500353# undef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600354# endif
355# endif /* __linux__ */
356#endif /* PNG_SETJMP_SUPPORTED */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600357
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500358#ifdef BSD
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600359# include <strings.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500360#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600361# include <string.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500362#endif
363
Andreas Dilger47a0c421997-05-16 02:46:07 -0500364/* Other defines for things like memory and the like can go here. */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500365
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500366/* This controls how fine the dithering gets. As this allocates
367 * a largish chunk of memory (32K), those who are not as concerned
368 * with dithering quality can decrease some or all of these.
369 */
370#ifndef PNG_DITHER_RED_BITS
371# define PNG_DITHER_RED_BITS 5
372#endif
373#ifndef PNG_DITHER_GREEN_BITS
374# define PNG_DITHER_GREEN_BITS 5
375#endif
376#ifndef PNG_DITHER_BLUE_BITS
377# define PNG_DITHER_BLUE_BITS 5
378#endif
379
380/* This controls how fine the gamma correction becomes when you
381 * are only interested in 8 bits anyway. Increasing this value
382 * results in more memory being used, and more pow() functions
383 * being called to fill in the gamma tables. Don't set this value
384 * less then 8, and even that may not work (I haven't tested it).
385 */
386
387#ifndef PNG_MAX_GAMMA_8
388# define PNG_MAX_GAMMA_8 11
389#endif
390
391/* This controls how much a difference in gamma we can tolerate before
392 * we actually start doing gamma conversion.
393 */
394#ifndef PNG_GAMMA_THRESHOLD
395# define PNG_GAMMA_THRESHOLD 0.05
396#endif
397
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600398/* The following uses const char * instead of char * for error
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600399 * and warning message functions, so some compilers won't complain.
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600400 * If you do not want to use const, define PNG_NO_CONST here.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600401 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600402
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600403#ifndef PNG_NO_CONST
Guy Schalnat6d764711995-12-19 03:22:19 -0600404# define PNG_CONST const
405#else
406# define PNG_CONST
407#endif
408
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600409/* The following defines give you the ability to remove code from the
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600410 * library that you will not be using. I wish I could figure out how to
411 * automate this, but I can't do that without making it seriously hard
412 * on the users. So if you are not using an ability, change the #define
413 * to and #undef, and that part of the library will not be compiled. If
414 * your linker can't find a function, you may want to make sure the
415 * ability is defined here. Some of these depend upon some others being
416 * defined. I haven't figured out all the interactions here, so you may
417 * have to experiment awhile to get everything to compile. If you are
418 * creating or using a shared library, you probably shouldn't touch this,
419 * as it will affect the size of the structures, and this will cause bad
420 * things to happen if the library and/or application ever change.
421 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500422
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500423/* Any features you will not be using can be undef'ed here */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600424
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600425/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500426 * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS
427 * on the compile line, then pick and choose which ones to define without
428 * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED
429 * if you only want to have a png-compliant reader/writer but don't need
430 * any of the extra transformations. This saves about 80 kbytes in a
431 * typical installation of the library. (PNG_NO_* form added in version
432 * 1.0.1c, for consistency)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600433 */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600434
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500435/* The size of the png_text structure changed in libpng-1.0.6 when
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600436 * iTXt support was added. iTXt support was turned off by default through
437 * libpng-1.2.x, to support old apps that malloc the png_text structure
438 * instead of calling png_set_text() and letting libpng malloc it. It
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500439 * was turned on by default in libpng-1.4.0.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500440 */
441
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600442#if !defined(PNG_NO_iTXt_SUPPORTED)
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500443# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt)
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600444# define PNG_READ_iTXt
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500445# endif
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500446# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt)
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600447# define PNG_WRITE_iTXt
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500448# endif
449#endif
450
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500451/* The following support, added after version 1.0.0, can be turned off here en
452 * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility
453 * with old applications that require the length of png_struct and png_info
454 * to remain unchanged.
455 */
456
457#ifdef PNG_LEGACY_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600458# define PNG_NO_FREE_ME
459# define PNG_NO_READ_UNKNOWN_CHUNKS
460# define PNG_NO_WRITE_UNKNOWN_CHUNKS
461# define PNG_NO_READ_USER_CHUNKS
462# define PNG_NO_READ_iCCP
463# define PNG_NO_WRITE_iCCP
464# define PNG_NO_READ_iTXt
465# define PNG_NO_WRITE_iTXt
466# define PNG_NO_READ_sCAL
467# define PNG_NO_WRITE_sCAL
468# define PNG_NO_READ_sPLT
469# define PNG_NO_WRITE_sPLT
470# define PNG_NO_INFO_IMAGE
471# define PNG_NO_READ_RGB_TO_GRAY
472# define PNG_NO_READ_USER_TRANSFORM
473# define PNG_NO_WRITE_USER_TRANSFORM
474# define PNG_NO_USER_MEM
475# define PNG_NO_READ_EMPTY_PLTE
476# define PNG_NO_MNG_FEATURES
477# define PNG_NO_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500478#endif
479
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500480/* Ignore attempt to turn off both floating and fixed point support */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500481#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600482 !defined(PNG_NO_FIXED_POINT_SUPPORTED)
483# define PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500484#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600485
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500486#ifndef PNG_NO_FREE_ME
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600487# define PNG_FREE_ME_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500488#endif
489
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600490#if defined(PNG_READ_SUPPORTED)
491
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500492#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600493 !defined(PNG_NO_READ_TRANSFORMS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600494# define PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600495#endif
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600496
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600497#ifdef PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600498# ifndef PNG_NO_READ_EXPAND
499# define PNG_READ_EXPAND_SUPPORTED
500# endif
501# ifndef PNG_NO_READ_SHIFT
502# define PNG_READ_SHIFT_SUPPORTED
503# endif
504# ifndef PNG_NO_READ_PACK
505# define PNG_READ_PACK_SUPPORTED
506# endif
507# ifndef PNG_NO_READ_BGR
508# define PNG_READ_BGR_SUPPORTED
509# endif
510# ifndef PNG_NO_READ_SWAP
511# define PNG_READ_SWAP_SUPPORTED
512# endif
513# ifndef PNG_NO_READ_PACKSWAP
514# define PNG_READ_PACKSWAP_SUPPORTED
515# endif
516# ifndef PNG_NO_READ_INVERT
517# define PNG_READ_INVERT_SUPPORTED
518# endif
Glenn Randers-Pehrson4a82d692008-12-15 16:25:05 -0600519#if 0 /* removed from libpng-1.4.0 */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600520# ifndef PNG_NO_READ_DITHER
521# define PNG_READ_DITHER_SUPPORTED
522# endif
Glenn Randers-Pehrson4a82d692008-12-15 16:25:05 -0600523#endif /* 0 */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600524# ifndef PNG_NO_READ_BACKGROUND
525# define PNG_READ_BACKGROUND_SUPPORTED
526# endif
527# ifndef PNG_NO_READ_16_TO_8
528# define PNG_READ_16_TO_8_SUPPORTED
529# endif
530# ifndef PNG_NO_READ_FILLER
531# define PNG_READ_FILLER_SUPPORTED
532# endif
533# ifndef PNG_NO_READ_GAMMA
534# define PNG_READ_GAMMA_SUPPORTED
535# endif
536# ifndef PNG_NO_READ_GRAY_TO_RGB
537# define PNG_READ_GRAY_TO_RGB_SUPPORTED
538# endif
539# ifndef PNG_NO_READ_SWAP_ALPHA
540# define PNG_READ_SWAP_ALPHA_SUPPORTED
541# endif
542# ifndef PNG_NO_READ_INVERT_ALPHA
543# define PNG_READ_INVERT_ALPHA_SUPPORTED
544# endif
Glenn Randers-Pehrson1916f6a2008-08-14 13:44:49 -0500545# ifndef PNG_NO_READ_PREMULTIPLY_ALPHA
546# define PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
547# endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600548# ifndef PNG_NO_READ_STRIP_ALPHA
549# define PNG_READ_STRIP_ALPHA_SUPPORTED
550# endif
551# ifndef PNG_NO_READ_USER_TRANSFORM
552# define PNG_READ_USER_TRANSFORM_SUPPORTED
553# endif
554# ifndef PNG_NO_READ_RGB_TO_GRAY
555# define PNG_READ_RGB_TO_GRAY_SUPPORTED
556# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600557#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600558
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500559#if !defined(PNG_NO_PROGRESSIVE_READ) && \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600560 !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
561# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600562#endif /* about interlacing capability! You'll */
563 /* still have interlacing unless you change the following line: */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600564
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600565#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500566
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500567#ifndef PNG_NO_READ_COMPOSITE_NODIV
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600568# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
569# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
570# endif
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500571#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500572
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500573#if !defined(PNG_NO_GET_INT_32) || defined(PNG_READ_oFFS_SUPPORTED) || \
574 defined(PNG_READ_pCAL_SUPPORTED)
575# ifndef PNG_GET_INT_32_SUPPORTED
576# define PNG_GET_INT_32_SUPPORTED
577# endif
578#endif
579
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600580#endif /* PNG_READ_SUPPORTED */
581
582#if defined(PNG_WRITE_SUPPORTED)
583
584# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
585 !defined(PNG_NO_WRITE_TRANSFORMS)
586# define PNG_WRITE_TRANSFORMS_SUPPORTED
587#endif
588
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600589#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600590# ifndef PNG_NO_WRITE_SHIFT
591# define PNG_WRITE_SHIFT_SUPPORTED
592# endif
593# ifndef PNG_NO_WRITE_PACK
594# define PNG_WRITE_PACK_SUPPORTED
595# endif
596# ifndef PNG_NO_WRITE_BGR
597# define PNG_WRITE_BGR_SUPPORTED
598# endif
599# ifndef PNG_NO_WRITE_SWAP
600# define PNG_WRITE_SWAP_SUPPORTED
601# endif
602# ifndef PNG_NO_WRITE_PACKSWAP
603# define PNG_WRITE_PACKSWAP_SUPPORTED
604# endif
605# ifndef PNG_NO_WRITE_INVERT
606# define PNG_WRITE_INVERT_SUPPORTED
607# endif
608# ifndef PNG_NO_WRITE_FILLER
609# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */
610# endif
611# ifndef PNG_NO_WRITE_SWAP_ALPHA
612# define PNG_WRITE_SWAP_ALPHA_SUPPORTED
613# endif
614# ifndef PNG_NO_WRITE_INVERT_ALPHA
615# define PNG_WRITE_INVERT_ALPHA_SUPPORTED
616# endif
617# ifndef PNG_NO_WRITE_USER_TRANSFORM
618# define PNG_WRITE_USER_TRANSFORM_SUPPORTED
619# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600620#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600621
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600622#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \
623 !defined(PNG_WRITE_INTERLACING_SUPPORTED)
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600624#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
625 encoders, but can cause trouble
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600626 if left undefined */
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600627#endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600628
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500629#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600630 !defined(PNG_WRITE_WEIGHTED_FILTER) && \
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500631 defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600632# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500633#endif
634
635#ifndef PNG_NO_WRITE_FLUSH
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600636# define PNG_WRITE_FLUSH_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500637#endif
638
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500639#if !defined(PNG_NO_SAVE_INT_32) || defined(PNG_WRITE_oFFS_SUPPORTED) || \
640 defined(PNG_WRITE_pCAL_SUPPORTED)
641# ifndef PNG_SAVE_INT_32_SUPPORTED
642# define PNG_SAVE_INT_32_SUPPORTED
643# endif
644#endif
645
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600646#endif /* PNG_WRITE_SUPPORTED */
647
Glenn Randers-Pehrson895a9c92008-07-25 08:51:18 -0500648#define PNG_NO_ERROR_NUMBERS
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500649
650#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
651 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
652# ifndef PNG_NO_USER_TRANSFORM_PTR
653# define PNG_USER_TRANSFORM_PTR_SUPPORTED
654# endif
655#endif
656
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500657#ifndef PNG_NO_STDIO
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600658# define PNG_TIME_RFC1123_SUPPORTED
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600659#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500660
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600661/* This adds extra functions in pngget.c for accessing data from the
662 * info pointer (added in version 0.99)
663 * png_get_image_width()
664 * png_get_image_height()
665 * png_get_bit_depth()
666 * png_get_color_type()
667 * png_get_compression_type()
668 * png_get_filter_type()
669 * png_get_interlace_type()
670 * png_get_pixel_aspect_ratio()
671 * png_get_pixels_per_meter()
672 * png_get_x_offset_pixels()
673 * png_get_y_offset_pixels()
674 * png_get_x_offset_microns()
675 * png_get_y_offset_microns()
676 */
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500677#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600678# define PNG_EASY_ACCESS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600679#endif
680
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500681#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
682# define PNG_USER_MEM_SUPPORTED
683#endif
684
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500685/* Added at libpng-1.2.6 */
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500686#ifndef PNG_SET_USER_LIMITS_SUPPORTED
687#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED)
688# define PNG_SET_USER_LIMITS_SUPPORTED
689#endif
690#endif
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500691
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500692/* 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 -0500693 * how large, set these limits to 0x7fffffffL
694 */
695#ifndef PNG_USER_WIDTH_MAX
696# define PNG_USER_WIDTH_MAX 1000000L
697#endif
698#ifndef PNG_USER_HEIGHT_MAX
699# define PNG_USER_HEIGHT_MAX 1000000L
700#endif
701
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500702/* Added at libpng-1.4.0 */
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -0500703#ifndef PNG_USER_CHUNK_CACHE_MAX
704# define PNG_USER_CHUNK_CACHE_MAX 0x7ffffffLL
705#endif
706
707/* Added at libpng-1.4.0 */
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500708#if !defined(PNG_NO_IO_STATE) && !defined(PNG_IO_STATE_SUPPORTED)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500709# define PNG_IO_STATE_SUPPORTED
710#endif
711
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500712#ifndef PNG_LITERAL_SHARP
713# define PNG_LITERAL_SHARP 0x23
714#endif
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500715#ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500716# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500717#endif
718#ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500719# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500720#endif
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500721#ifndef PNG_STRING_NEWLINE
Glenn Randers-Pehrsone0784c72008-08-09 07:11:44 -0500722#define PNG_STRING_NEWLINE "\n"
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500723#endif
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500724
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600725/* These are currently experimental features, define them if you want */
726
727/* very little testing */
728/*
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600729#ifdef PNG_READ_SUPPORTED
730# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
731# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
732# endif
733#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600734*/
Andreas Dilger47a0c421997-05-16 02:46:07 -0500735
736/* This is only for PowerPC big-endian and 680x0 systems */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600737/* some testing */
738/*
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500739#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
740# define PNG_READ_BIG_ENDIAN_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600741#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600742*/
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500743
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500744#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
745# define PNG_USE_READ_MACROS
746#endif
747
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -0500748/* Buggy compilers (e.g., gcc 2.7.2.2) need this */
749/*
750#define PNG_NO_POINTER_INDEXING
751*/
752
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600753
Andreas Dilger47a0c421997-05-16 02:46:07 -0500754/* Any chunks you are not interested in, you can undef here. The
755 * ones that allocate memory may be expecially important (hIST,
756 * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600757 * a bit smaller.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500758 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500759
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600760#if defined(PNG_READ_SUPPORTED) && \
761 !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500762 !defined(PNG_NO_READ_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600763# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600764#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600765
766#if defined(PNG_WRITE_SUPPORTED) && \
767 !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500768 !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600769# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600770#endif
771
772#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600773
774#ifdef PNG_NO_READ_TEXT
775# define PNG_NO_READ_iTXt
776# define PNG_NO_READ_tEXt
777# define PNG_NO_READ_zTXt
778#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500779#ifndef PNG_NO_READ_bKGD
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600780# define PNG_READ_bKGD_SUPPORTED
781# define PNG_bKGD_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500782#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500783#ifndef PNG_NO_READ_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600784# define PNG_READ_cHRM_SUPPORTED
785# define PNG_cHRM_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500786#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500787#ifndef PNG_NO_READ_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600788# define PNG_READ_gAMA_SUPPORTED
789# define PNG_gAMA_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500790#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500791#ifndef PNG_NO_READ_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600792# define PNG_READ_hIST_SUPPORTED
793# define PNG_hIST_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600794#endif
795#ifndef PNG_NO_READ_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600796# define PNG_READ_iCCP_SUPPORTED
797# define PNG_iCCP_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600798#endif
799#ifndef PNG_NO_READ_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500800# ifndef PNG_READ_iTXt_SUPPORTED
801# define PNG_READ_iTXt_SUPPORTED
802# endif
803# ifndef PNG_iTXt_SUPPORTED
804# define PNG_iTXt_SUPPORTED
805# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500806#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500807#ifndef PNG_NO_READ_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600808# define PNG_READ_oFFs_SUPPORTED
809# define PNG_oFFs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500810#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500811#ifndef PNG_NO_READ_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600812# define PNG_READ_pCAL_SUPPORTED
813# define PNG_pCAL_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600814#endif
815#ifndef PNG_NO_READ_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600816# define PNG_READ_sCAL_SUPPORTED
817# define PNG_sCAL_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500818#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500819#ifndef PNG_NO_READ_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600820# define PNG_READ_pHYs_SUPPORTED
821# define PNG_pHYs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500822#endif
823#ifndef PNG_NO_READ_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600824# define PNG_READ_sBIT_SUPPORTED
825# define PNG_sBIT_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600826#endif
827#ifndef PNG_NO_READ_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600828# define PNG_READ_sPLT_SUPPORTED
829# define PNG_sPLT_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500830#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500831#ifndef PNG_NO_READ_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600832# define PNG_READ_sRGB_SUPPORTED
833# define PNG_sRGB_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500834#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500835#ifndef PNG_NO_READ_tEXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600836# define PNG_READ_tEXt_SUPPORTED
837# define PNG_tEXt_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500838#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500839#ifndef PNG_NO_READ_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600840# define PNG_READ_tIME_SUPPORTED
841# define PNG_tIME_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500842#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500843#ifndef PNG_NO_READ_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600844# define PNG_READ_tRNS_SUPPORTED
845# define PNG_tRNS_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500846#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500847#ifndef PNG_NO_READ_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600848# define PNG_READ_zTXt_SUPPORTED
849# define PNG_zTXt_SUPPORTED
850#endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500851#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
852# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500853# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
854# define PNG_UNKNOWN_CHUNKS_SUPPORTED
855# endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500856# ifndef PNG_NO_HANDLE_AS_UNKNOWN
857# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
858# endif
859#endif
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -0500860#if !defined(PNG_NO_READ_USER_CHUNKS) && \
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500861 defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600862# define PNG_READ_USER_CHUNKS_SUPPORTED
863# define PNG_USER_CHUNKS_SUPPORTED
864# ifdef PNG_NO_READ_UNKNOWN_CHUNKS
865# undef PNG_NO_READ_UNKNOWN_CHUNKS
866# endif
867# ifdef PNG_NO_HANDLE_AS_UNKNOWN
868# undef PNG_NO_HANDLE_AS_UNKNOWN
869# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600870#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500871#ifndef PNG_NO_READ_OPT_PLTE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600872# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
873#endif /* optional PLTE chunk in RGB and RGBA images */
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600874#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600875 defined(PNG_READ_zTXt_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600876# define PNG_READ_TEXT_SUPPORTED
877# define PNG_TEXT_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600878#endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600879
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600880#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500881
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600882#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600883
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600884#ifdef PNG_NO_WRITE_TEXT
885# define PNG_NO_WRITE_iTXt
886# define PNG_NO_WRITE_tEXt
887# define PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600888#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600889#ifndef PNG_NO_WRITE_bKGD
890# define PNG_WRITE_bKGD_SUPPORTED
891# ifndef PNG_bKGD_SUPPORTED
892# define PNG_bKGD_SUPPORTED
893# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500894#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500895#ifndef PNG_NO_WRITE_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600896# define PNG_WRITE_cHRM_SUPPORTED
897# ifndef PNG_cHRM_SUPPORTED
898# define PNG_cHRM_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_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600902# define PNG_WRITE_gAMA_SUPPORTED
903# ifndef PNG_gAMA_SUPPORTED
904# define PNG_gAMA_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_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600908# define PNG_WRITE_hIST_SUPPORTED
909# ifndef PNG_hIST_SUPPORTED
910# define PNG_hIST_SUPPORTED
911# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600912#endif
913#ifndef PNG_NO_WRITE_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600914# define PNG_WRITE_iCCP_SUPPORTED
915# ifndef PNG_iCCP_SUPPORTED
916# define PNG_iCCP_SUPPORTED
917# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600918#endif
919#ifndef PNG_NO_WRITE_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500920# ifndef PNG_WRITE_iTXt_SUPPORTED
921# define PNG_WRITE_iTXt_SUPPORTED
922# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600923# ifndef PNG_iTXt_SUPPORTED
924# define PNG_iTXt_SUPPORTED
925# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500926#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500927#ifndef PNG_NO_WRITE_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600928# define PNG_WRITE_oFFs_SUPPORTED
929# ifndef PNG_oFFs_SUPPORTED
930# define PNG_oFFs_SUPPORTED
931# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500932#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500933#ifndef PNG_NO_WRITE_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600934# define PNG_WRITE_pCAL_SUPPORTED
935# ifndef PNG_pCAL_SUPPORTED
936# define PNG_pCAL_SUPPORTED
937# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600938#endif
939#ifndef PNG_NO_WRITE_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600940# define PNG_WRITE_sCAL_SUPPORTED
941# ifndef PNG_sCAL_SUPPORTED
942# define PNG_sCAL_SUPPORTED
943# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500944#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500945#ifndef PNG_NO_WRITE_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600946# define PNG_WRITE_pHYs_SUPPORTED
947# ifndef PNG_pHYs_SUPPORTED
948# define PNG_pHYs_SUPPORTED
949# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500950#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500951#ifndef PNG_NO_WRITE_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600952# define PNG_WRITE_sBIT_SUPPORTED
953# ifndef PNG_sBIT_SUPPORTED
954# define PNG_sBIT_SUPPORTED
955# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600956#endif
957#ifndef PNG_NO_WRITE_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600958# define PNG_WRITE_sPLT_SUPPORTED
959# ifndef PNG_sPLT_SUPPORTED
960# define PNG_sPLT_SUPPORTED
961# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500962#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500963#ifndef PNG_NO_WRITE_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600964# define PNG_WRITE_sRGB_SUPPORTED
965# ifndef PNG_sRGB_SUPPORTED
966# define PNG_sRGB_SUPPORTED
967# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500968#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500969#ifndef PNG_NO_WRITE_tEXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600970# define PNG_WRITE_tEXt_SUPPORTED
971# ifndef PNG_tEXt_SUPPORTED
972# define PNG_tEXt_SUPPORTED
973# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500974#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500975#ifndef PNG_NO_WRITE_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600976# define PNG_WRITE_tIME_SUPPORTED
977# ifndef PNG_tIME_SUPPORTED
978# define PNG_tIME_SUPPORTED
979# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500980#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500981#ifndef PNG_NO_WRITE_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600982# define PNG_WRITE_tRNS_SUPPORTED
983# ifndef PNG_tRNS_SUPPORTED
984# define PNG_tRNS_SUPPORTED
985# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500986#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500987#ifndef PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600988# define PNG_WRITE_zTXt_SUPPORTED
989# ifndef PNG_zTXt_SUPPORTED
990# define PNG_zTXt_SUPPORTED
991# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600992#endif
993#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600994# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
995# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
996# define PNG_UNKNOWN_CHUNKS_SUPPORTED
997# endif
998# ifndef PNG_NO_HANDLE_AS_UNKNOWN
999# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
1000# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
1001# endif
1002# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001003#endif
1004#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001005 defined(PNG_WRITE_zTXt_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001006# define PNG_WRITE_TEXT_SUPPORTED
1007# ifndef PNG_TEXT_SUPPORTED
1008# define PNG_TEXT_SUPPORTED
1009# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05001010#endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001011
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -06001012#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001013
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001014/* Turn this off to disable png_read_png() and
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001015 * png_write_png() and leave the row_pointers member
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001016 * out of the info structure.
1017 */
1018#ifndef PNG_NO_INFO_IMAGE
1019# define PNG_INFO_IMAGE_SUPPORTED
1020#endif
1021
Andreas Dilger47a0c421997-05-16 02:46:07 -05001022/* need the time information for reading tIME chunks */
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001023#if defined(PNG_tIME_SUPPORTED)
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -05001024# if !defined(_WIN32_WCE)
1025 /* "time.h" functions are not supported on WindowsCE */
1026# include <time.h>
1027# endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001028#endif
1029
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001030/* Some typedefs to get us started. These should be safe on most of the
Andreas Dilger47a0c421997-05-16 02:46:07 -05001031 * common platforms. The typedefs should be at least as large as the
1032 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
1033 * don't have to be exactly that size. Some compilers dislike passing
1034 * unsigned shorts as function parameters, so you may be better off using
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001035 * unsigned int for png_uint_16.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001036 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001037
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05001038#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
1039typedef unsigned int png_uint_32;
1040typedef int png_int_32;
1041#else
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001042typedef unsigned long png_uint_32;
1043typedef long png_int_32;
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05001044#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001045typedef unsigned short png_uint_16;
1046typedef short png_int_16;
1047typedef unsigned char png_byte;
1048
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001049#ifdef PNG_NO_SIZE_T
1050 typedef unsigned int png_size_t;
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05001051#else
1052 typedef size_t png_size_t;
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05001053#endif
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001054#define png_sizeof(x) sizeof(x)
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001055
Andreas Dilger47a0c421997-05-16 02:46:07 -05001056/* The following is needed for medium model support. It cannot be in the
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05001057 * pngpriv.h header. Needs modification for other compilers besides
Andreas Dilger47a0c421997-05-16 02:46:07 -05001058 * MSC. Model independent support declares all arrays and pointers to be
1059 * large using the far keyword. The zlib version used must also support
1060 * model independent data. As of version zlib 1.0.4, the necessary changes
1061 * have been made in zlib. The USE_FAR_KEYWORD define triggers other
1062 * changes that are needed. (Tim Wegner)
1063 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001064
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001065/* Separate compiler dependencies (problem here is that zlib.h always
1066 defines FAR. (SJT) */
Guy Schalnat6d764711995-12-19 03:22:19 -06001067#ifdef __BORLANDC__
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001068# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
1069# define LDATA 1
1070# else
1071# define LDATA 0
1072# endif
1073 /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
1074# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
1075# define PNG_MAX_MALLOC_64K
1076# if (LDATA != 1)
1077# ifndef FAR
1078# define FAR __far
1079# endif
1080# define USE_FAR_KEYWORD
1081# endif /* LDATA != 1 */
1082 /* Possibly useful for moving data out of default segment.
1083 * Uncomment it if you want. Could also define FARDATA as
1084 * const if your compiler supports it. (SJT)
1085# define FARDATA FAR
1086 */
1087# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
Guy Schalnatb2e01bd1996-01-26 01:38:47 -06001088#endif /* __BORLANDC__ */
Guy Schalnat6d764711995-12-19 03:22:19 -06001089
1090
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001091/* Suggest testing for specific compiler first before testing for
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001092 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
1093 * making reliance oncertain keywords suspect. (SJT)
1094 */
Guy Schalnat6d764711995-12-19 03:22:19 -06001095
1096/* MSC Medium model */
1097#if defined(FAR)
1098# if defined(M_I86MM)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001099# define USE_FAR_KEYWORD
1100# define FARDATA FAR
1101# include <dos.h>
Guy Schalnat6d764711995-12-19 03:22:19 -06001102# endif
1103#endif
1104
1105/* SJT: default case */
1106#ifndef FAR
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001107# define FAR
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001108#endif
1109
Andreas Dilger47a0c421997-05-16 02:46:07 -05001110/* At this point FAR is always defined */
Guy Schalnat6d764711995-12-19 03:22:19 -06001111#ifndef FARDATA
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001112# define FARDATA
Guy Schalnat6d764711995-12-19 03:22:19 -06001113#endif
1114
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001115/* Typedef for floating-point numbers that are converted
1116 to fixed-point with a multiple of 100,000, e.g., int_gamma */
1117typedef png_int_32 png_fixed_point;
1118
Andreas Dilger47a0c421997-05-16 02:46:07 -05001119/* Add typedefs for pointers */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001120typedef void FAR * png_voidp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001121typedef png_byte FAR * png_bytep;
1122typedef png_uint_32 FAR * png_uint_32p;
1123typedef png_int_32 FAR * png_int_32p;
1124typedef png_uint_16 FAR * png_uint_16p;
1125typedef png_int_16 FAR * png_int_16p;
1126typedef PNG_CONST char FAR * png_const_charp;
1127typedef char FAR * png_charp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001128typedef png_fixed_point FAR * png_fixed_point_p;
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001129
1130#ifndef PNG_NO_STDIO
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -05001131#if defined(_WIN32_WCE)
1132typedef HANDLE png_FILE_p;
1133#else
1134typedef FILE * png_FILE_p;
1135#endif
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001136#endif
1137
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001138#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001139typedef double FAR * png_doublep;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001140#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001141
Andreas Dilger47a0c421997-05-16 02:46:07 -05001142/* Pointers to pointers; i.e. arrays */
Guy Schalnat6d764711995-12-19 03:22:19 -06001143typedef png_byte FAR * FAR * png_bytepp;
1144typedef png_uint_32 FAR * FAR * png_uint_32pp;
1145typedef png_int_32 FAR * FAR * png_int_32pp;
1146typedef png_uint_16 FAR * FAR * png_uint_16pp;
1147typedef png_int_16 FAR * FAR * png_int_16pp;
1148typedef PNG_CONST char FAR * FAR * png_const_charpp;
1149typedef char FAR * FAR * png_charpp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001150typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001151#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001152typedef double FAR * FAR * png_doublepp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001153#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001154
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001155/* Pointers to pointers to pointers; i.e., pointer to array */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001156typedef char FAR * FAR * FAR * png_charppp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001157
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001158/*
1159 * Define PNG_BUILD_DLL if the module being built is a Windows
1160 * LIBPNG DLL.
1161 *
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001162 * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL.
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -06001163 * It is equivalent to Microsoft predefined macro _DLL that is
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001164 * automatically defined when you compile using the share
1165 * version of the CRT (C Run-Time library)
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001166 *
1167 * The cygwin mods make this behavior a little different:
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001168 * Define PNG_BUILD_DLL if you are building a dll for use with cygwin
1169 * Define PNG_STATIC if you are building a static library for use with cygwin,
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001170 * -or- if you are building an application that you want to link to the
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001171 * static library.
1172 * PNG_USE_DLL is defined by default (no user action needed) unless one of
1173 * the other flags is defined.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001174 */
1175
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001176#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001177# define PNG_DLL
1178#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001179/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib.
1180 * When building a static lib, default to no GLOBAL ARRAYS, but allow
1181 * command-line override
1182 */
1183#if defined(__CYGWIN__)
1184# if !defined(PNG_STATIC)
1185# if defined(PNG_USE_GLOBAL_ARRAYS)
1186# undef PNG_USE_GLOBAL_ARRAYS
1187# endif
1188# if !defined(PNG_USE_LOCAL_ARRAYS)
1189# define PNG_USE_LOCAL_ARRAYS
1190# endif
1191# else
1192# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS)
1193# if defined(PNG_USE_GLOBAL_ARRAYS)
1194# undef PNG_USE_GLOBAL_ARRAYS
1195# endif
1196# endif
1197# endif
1198# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
1199# define PNG_USE_LOCAL_ARRAYS
1200# endif
1201#endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001202
Glenn Randers-Pehrsonec61c232000-05-16 06:17:36 -05001203/* Do not use global arrays (helps with building DLL's)
1204 * They are no longer used in libpng itself, since version 1.0.5c,
1205 * but might be required for some pre-1.0.5c applications.
1206 */
1207#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
1208# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL))
1209# define PNG_USE_LOCAL_ARRAYS
1210# else
1211# define PNG_USE_GLOBAL_ARRAYS
1212# endif
1213#endif
1214
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001215#if defined(__CYGWIN__)
1216# undef PNGAPI
1217# define PNGAPI __cdecl
1218# undef PNG_IMPEXP
1219# define PNG_IMPEXP
1220#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001221
Glenn Randers-Pehrson25d82242002-05-01 11:51:26 -05001222/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
1223 * you may get warnings regarding the linkage of png_zalloc and png_zfree.
1224 * Don't ignore those warnings; you must also reset the default calling
1225 * convention in your compiler to match your PNGAPI, and you must build
1226 * zlib and your applications the same way you build libpng.
1227 */
1228
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001229#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001230# ifndef PNG_NO_MODULEDEF
1231# define PNG_NO_MODULEDEF
1232# endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001233#endif
1234
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001235#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001236# define PNG_IMPEXP
1237#endif
1238
1239#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001240 (( defined(_Windows) || defined(_WINDOWS) || \
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -05001241 defined(WIN32) || defined(_WIN32) || defined(__WIN32__) ))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001242
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001243# ifndef PNGAPI
1244# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
1245# define PNGAPI __cdecl
1246# else
1247# define PNGAPI _cdecl
1248# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001249# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001250
1251# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \
1252 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */)
1253# define PNG_IMPEXP
1254# endif
1255
1256# if !defined(PNG_IMPEXP)
1257
1258# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol
1259# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol
1260
1261 /* Borland/Microsoft */
1262# if defined(_MSC_VER) || defined(__BORLANDC__)
1263# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
1264# define PNG_EXPORT PNG_EXPORT_TYPE1
1265# else
1266# define PNG_EXPORT PNG_EXPORT_TYPE2
1267# if defined(PNG_BUILD_DLL)
1268# define PNG_IMPEXP __export
1269# else
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -05001270# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in
1271 VC++ */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001272# endif /* Exists in Borland C++ for
1273 C++ classes (== huge) */
1274# endif
1275# endif
1276
1277# if !defined(PNG_IMPEXP)
1278# if defined(PNG_BUILD_DLL)
1279# define PNG_IMPEXP __declspec(dllexport)
1280# else
1281# define PNG_IMPEXP __declspec(dllimport)
1282# endif
1283# endif
1284# endif /* PNG_IMPEXP */
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001285#else /* !(DLL || non-cygwin WINDOWS) */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001286# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
1287# ifndef PNGAPI
1288# define PNGAPI _System
Glenn Randers-Pehrsonf64a06f2001-04-11 07:38:00 -05001289# endif
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001290# else
1291# if 0 /* ... other platforms, with other meanings */
1292# endif
1293# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001294#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001295
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -06001296#ifndef PNGAPI
1297# define PNGAPI
1298#endif
1299#ifndef PNG_IMPEXP
1300# define PNG_IMPEXP
1301#endif
1302
Glenn Randers-Pehrsonc3dda6d2004-11-27 18:22:29 -06001303#ifdef PNG_BUILDSYMS
1304# ifndef PNG_EXPORT
1305# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END
1306# endif
1307# ifdef PNG_USE_GLOBAL_ARRAYS
1308# ifndef PNG_EXPORT_VAR
1309# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT
1310# endif
1311# endif
1312#endif
1313
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -05001314#ifndef PNG_EXPORT
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001315# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001316#endif
1317
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001318#ifdef PNG_USE_GLOBAL_ARRAYS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001319# ifndef PNG_EXPORT_VAR
1320# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type
1321# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001322#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001323
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001324/* Users may want to use these so they are not private. Any library
1325 * functions that are passed far data must be model-independent.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001326 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001327
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001328#ifdef PNG_SETJMP_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001329# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06001330#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001331# define png_jmpbuf(png_ptr) \
1332 (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED)
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001333#endif
1334
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001335/* memory model/platform independent fns */
1336#ifndef PNG_ABORT
1337# ifdef _WINDOWS_
1338# define PNG_ABORT() ExitProcess(0)
1339# else
1340# define PNG_ABORT() abort()
1341# endif
1342#endif
1343
1344#if defined(USE_FAR_KEYWORD)
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001345/* use this to make far-to-near assignments */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001346# define CHECK 1
1347# define NOCHECK 0
1348# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
1349# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001350# define png_strcpy _fstrcpy
1351# define png_strncpy _fstrncpy /* Added to v 1.2.6 */
1352# define png_strlen _fstrlen
1353# define png_memcmp _fmemcmp /* SJT: added */
1354# define png_memcpy _fmemcpy
1355# define png_memset _fmemset
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001356# define png_sprintf sprintf
1357#else
1358# if defined(_WINDOWS_) /* favor Windows over C runtime fns */
1359# define CVT_PTR(ptr) (ptr)
1360# define CVT_PTR_NOCHECK(ptr) (ptr)
1361# define png_strcpy lstrcpyA
1362# define png_strncpy lstrcpynA
1363# define png_strlen lstrlenA
1364# define png_memcmp memcmp
1365# define png_memcpy CopyMemory
1366# define png_memset memset
1367# define png_sprintf wsprintfA
1368# else
1369# define CVT_PTR(ptr) (ptr)
1370# define CVT_PTR_NOCHECK(ptr) (ptr)
1371# define png_strcpy strcpy
1372# define png_strncpy strncpy /* Added to v 1.2.6 */
1373# define png_strlen strlen
1374# define png_memcmp memcmp /* SJT: added */
1375# define png_memcpy memcpy
1376# define png_memset memset
1377# define png_sprintf sprintf
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001378# ifndef PNG_NO_SNPRINTF
1379# ifdef _MSC_VER
1380# define png_snprintf _snprintf /* Added to v 1.2.19 */
1381# define png_snprintf2 _snprintf
1382# define png_snprintf6 _snprintf
1383# else
1384# define png_snprintf snprintf /* Added to v 1.2.19 */
1385# define png_snprintf2 snprintf
1386# define png_snprintf6 snprintf
1387# endif
1388# else
1389 /* You don't have or don't want to use snprintf(). Caution: Using
1390 * sprintf instead of snprintf exposes your application to accidental
1391 * or malevolent buffer overflows. If you don't have snprintf()
1392 * as a general rule you should provide one (you can get one from
1393 * Portable OpenSSH). */
1394# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1)
1395# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2)
1396# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
1397 sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
1398# endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001399# endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001400#endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001401
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001402/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
1403 * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
1404 * to png_alloc_size_t are not necessary; in fact, it is recommended
1405 * not to use them at all so that the compiler can complain when something
1406 * turns out to be problematic.
1407 * Casts in the other direction (from png_alloc_size_t to png_size_t or
1408 * png_uint_32) should be explicitly applied; however, we do not expect
1409 * to encounter practical situations that require such conversions.
1410 */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001411#if defined(__TURBOC__) && !defined(__FLAT__)
1412# define png_mem_alloc farmalloc
1413# define png_mem_free farfree
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001414 typedef unsigned long png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001415#else
1416# if defined(_MSC_VER) && defined(MAXSEG_64K)
1417# define png_mem_alloc(s) halloc(s, 1)
1418# define png_mem_free hfree
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001419 typedef unsigned long png_alloc_size_t;
1420# else
1421# if defined(_WINDOWS_) && (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001422# define png_mem_alloc(s) HeapAlloc(GetProcessHeap(), 0, s)
1423# define png_mem_free(p) HeapFree(GetProcessHeap(), 0, p)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001424 typedef DWORD png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001425# else
1426# define png_mem_alloc malloc
1427# define png_mem_free free
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001428 typedef png_size_t png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001429# endif
1430# endif
1431#endif
1432/* End of memory model/platform independent support */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001433
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001434/* Just a little check that someone hasn't tried to define something
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001435 * contradictory.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001436 */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001437#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001438# undef PNG_ZBUF_SIZE
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001439# define PNG_ZBUF_SIZE 65536L
Andreas Dilger47a0c421997-05-16 02:46:07 -05001440#endif
1441
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001442
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -06001443/* Added at libpng-1.2.8 */
1444#endif /* PNG_VERSION_INFO_ONLY */
Glenn Randers-Pehrson40936072004-11-20 11:18:40 -06001445
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001446#endif /* PNGCONF_H */