blob: 2149dd29db2e579c0cdcb4962d58fec26ca5fa36 [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-Pehrson4e6b5e92009-09-23 10:24:53 -05004 * libpng version 1.4.0beta81 - September 23, 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-Pehrson3e61d792009-06-24 09:31:28 -05009 *
Glenn Randers-Pehrsonbfbf8652009-06-26 21:46:52 -050010 * This code is released under the libpng license.
Glenn Randers-Pehrsonc332bbc2009-06-25 13:43:50 -050011 * For conditions of distribution and use, see the disclaimer
Glenn Randers-Pehrson037023b2009-06-24 10:27:36 -050012 * and license in png.h
Glenn Randers-Pehrson3e61d792009-06-24 09:31:28 -050013 *
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060014 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050015
16/* Any machine specific code is near the front of this file, so if you
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060017 * are configuring libpng for a machine, you may want to read the section
18 * starting here down to where it starts to typedef png_color, png_text,
19 * and png_info.
20 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050021
22#ifndef PNGCONF_H
23#define PNGCONF_H
24
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -050025#ifndef PNG_NO_LIMITS_H
26#include <limits.h>
27#endif
28
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -050029/* Added at libpng-1.2.9 */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -050030
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -050031/* config.h is created by and PNG_CONFIGURE_LIBPNG is set by the "configure" script. */
Glenn Randers-Pehrsond5d63602006-04-15 06:37:45 -050032#ifdef PNG_CONFIGURE_LIBPNG
Glenn Randers-Pehrson170b70c2006-03-10 10:19:04 -060033#ifdef HAVE_CONFIG_H
Glenn Randers-Pehrsonb0270f72006-04-15 18:23:04 -050034#include "config.h"
Glenn Randers-Pehrsond5d63602006-04-15 06:37:45 -050035#endif
Glenn Randers-Pehrson170b70c2006-03-10 10:19:04 -060036#endif
37
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060038/*
39 * Added at libpng-1.2.8
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -050040 *
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -050041 * PNG_USER_CONFIG has to be defined on the compiler command line. This
42 * includes the resource compiler for Windows DLL configurations.
43 */
44#ifdef PNG_USER_CONFIG
45# ifndef PNG_USER_PRIVATEBUILD
46# define PNG_USER_PRIVATEBUILD
47# endif
48#include "pngusr.h"
49#endif
50
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -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"
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -050062 *
63 * The following macros are also at your disposal if you want to complete the
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060064 * 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
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060083/* End of material added to libpng-1.2.8 */
Glenn Randers-Pehrson878b31e2004-11-12 22:04:56 -060084
Glenn Randers-Pehrson5d95de72009-09-01 11:28:09 -050085#ifndef PNG_VERSION_INFO_ONLY
86
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-Pehrsondbd40142009-08-31 08:42:02 -0500127/* Added at libpng version 1.4.0 */
128#if !defined(PNG_NO_WARNINGS) && !defined(PNG_WARNINGS_SUPPORTED)
129# define PNG_WARNINGS_SUPPORTED
130#endif
131
132#if !defined(PNG_NO_ERROR_TEXT) && !defined(PNG_ERROR_TEXT_SUPPORTED)
133# define PNG_ERROR_TEXT_SUPPORTED
134#endif
135
136#if !defined(PNG_NO_CHECK_cHRM) && !defined(PNG_CHECK_cHRM_SUPPORTED)
137# define PNG_CHECK_cHRM_SUPPORTED
138#endif
139
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500140/* Enabled by default in 1.2.0. You can disable this if you don't need to
141 support PNGs that are embedded in MNG datastreams */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500142#ifndef PNG_NO_MNG_FEATURES
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600143# ifndef PNG_MNG_FEATURES_SUPPORTED
144# define PNG_MNG_FEATURES_SUPPORTED
145# endif
146#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600147
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500148/* Added at libpng version 1.4.0 */
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -0600149#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600150# ifndef PNG_FLOATING_POINT_SUPPORTED
151# define PNG_FLOATING_POINT_SUPPORTED
152# endif
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500153#endif
154
Glenn Randers-Pehrson5d95de72009-09-01 11:28:09 -0500155/* Added at libpng-1.4.0beta49 for testing (no longer used in libpng) */
156#define PNG_CALLOC_SUPPORTED
157
Andreas Dilger47a0c421997-05-16 02:46:07 -0500158/* If you are running on a machine where you cannot allocate more
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600159 * than 64K of memory at once, uncomment this. While libpng will not
160 * normally need that much memory in a chunk (unless you load up a very
161 * large file), zlib needs to know how big of a chunk it can use, and
162 * libpng thus makes sure to check any memory allocation to verify it
163 * will fit into memory.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500164#define PNG_MAX_MALLOC_64K
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600165 */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500166#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600167# define PNG_MAX_MALLOC_64K
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500168#endif
169
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500170/* Special munging to support doing things the 'cygwin' way:
171 * 'Normal' png-on-win32 defines/defaults:
172 * PNG_BUILD_DLL -- building dll
173 * PNG_USE_DLL -- building an application, linking to dll
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -0600174 * (no define) -- building static library, or building an
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500175 * application and linking to the static lib
176 * 'Cygwin' defines/defaults:
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500177 * PNG_BUILD_DLL -- (ignored) building the dll
178 * (no define) -- (ignored) building an application, linking to the dll
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500179 * PNG_STATIC -- (ignored) building the static lib, or building an
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500180 * application that links to the static lib.
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500181 * ALL_STATIC -- (ignored) building various static libs, or building an
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500182 * application that links to the static libs.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500183 * Thus,
184 * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
185 * this bit of #ifdefs will define the 'correct' config variables based on
186 * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but
187 * unnecessary.
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500188 *
189 * Also, the precedence order is:
190 * ALL_STATIC (since we can't #undef something outside our namespace)
191 * PNG_BUILD_DLL
192 * PNG_STATIC
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500193 * (nothing) == PNG_USE_DLL
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500194 *
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500195 * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500196 * of auto-import in binutils, we no longer need to worry about
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500197 * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore,
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500198 * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500199 * to __declspec() stuff. However, we DO need to worry about
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500200 * PNG_BUILD_DLL and PNG_STATIC because those change some defaults
Glenn Randers-Pehrson86312502009-08-31 14:17:23 -0500201 * such as CONSOLE_IO.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500202 */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500203#ifdef __CYGWIN__
204# ifdef ALL_STATIC
205# ifdef PNG_BUILD_DLL
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500206# undef PNG_BUILD_DLL
207# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500208# ifdef PNG_USE_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500209# undef PNG_USE_DLL
210# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500211# ifdef PNG_DLL
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500212# undef PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500213# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500214# ifndef PNG_STATIC
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -0600215# define PNG_STATIC
216# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500217# else
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500218# ifdef PNG_BUILD_DLL
219# ifdef PNG_STATIC
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500220# undef PNG_STATIC
221# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500222# ifdef PNG_USE_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500223# undef PNG_USE_DLL
224# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500225# ifndef PNG_DLL
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500226# define PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500227# endif
228# else
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500229# ifdef PNG_STATIC
230# ifdef PNG_USE_DLL
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500231# undef PNG_USE_DLL
232# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500233# ifdef PNG_DLL
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500234# undef PNG_DLL
235# endif
236# else
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500237# ifndef PNG_USE_DLL
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500238# define PNG_USE_DLL
239# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500240# ifndef PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500241# define PNG_DLL
242# endif
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500243# endif
244# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500245# endif
246#endif
247
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500248/* This protects us against compilers that run on a windowing system
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600249 * and thus don't have or would rather us not use the stdio types:
250 * stdin, stdout, and stderr. The only one currently used is stderr
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600251 * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will
252 * prevent these from being compiled and used. #defining PNG_NO_STDIO
253 * will also prevent these, plus will prevent the entire set of stdio
254 * macros and functions (FILE *, printf, etc.) from being compiled and used,
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500255 * unless (PNG_DEBUG > 0) has been #defined.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600256 *
257 * #define PNG_NO_CONSOLE_IO
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600258 * #define PNG_NO_STDIO
259 */
Guy Schalnat6d764711995-12-19 03:22:19 -0600260
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500261#if !defined(PNG_NO_STDIO) && !defined(PNG_STDIO_SUPPORTED)
262# define PNG_STDIO_SUPPORTED
263#endif
264
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500265#ifdef _WIN32_WCE
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600266# include <windows.h>
267 /* Console I/O functions are not supported on WindowsCE */
268# define PNG_NO_CONSOLE_IO
269# ifdef PNG_DEBUG
270# undef PNG_DEBUG
271# endif
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500272#endif
273
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -0500274#ifdef PNG_BUILD_DLL
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500275# if !defined(PNG_CONSOLE_IO_SUPPORTED) && !defined(PNG_NO_CONSOLE_IO)
276# define PNG_NO_CONSOLE_IO
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -0500277# endif
278#endif
279
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600280# ifdef PNG_NO_STDIO
281# ifndef PNG_NO_CONSOLE_IO
282# define PNG_NO_CONSOLE_IO
283# endif
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500284# ifdef PNG_DEBUG
285# if (PNG_DEBUG > 0)
286# include <stdio.h>
287# endif
288# endif
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600289# else
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500290# include <stdio.h>
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600291# endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600292
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500293#if !(defined PNG_NO_CONSOLE_IO) && !defined(PNG_CONSOLE_IO_SUPPORTED)
294# define PNG_CONSOLE_IO_SUPPORTED
295#endif
296
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600297/* This macro protects us against machines that don't have function
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600298 * prototypes (ie K&R style headers). If your compiler does not handle
299 * function prototypes, define this macro and use the included ansi2knr.
300 * I've always been able to use _NO_PROTO as the indicator, but you may
301 * need to drag the empty declaration out in front of here, or change the
302 * ifdef to suit your own needs.
303 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500304#ifndef PNGARG
305
Andreas Dilger47a0c421997-05-16 02:46:07 -0500306#ifdef OF /* zlib prototype munger */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600307# define PNGARG(arglist) OF(arglist)
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500308#else
309
310#ifdef _NO_PROTO
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600311# define PNGARG(arglist) ()
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500312#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600313# define PNGARG(arglist) arglist
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500314#endif /* _NO_PROTO */
315
316#endif /* OF */
317
318#endif /* PNGARG */
319
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600320/* Try to determine if we are compiling on a Mac. Note that testing for
321 * just __MWERKS__ is not good enough, because the Codewarrior is now used
322 * on non-Mac platforms.
323 */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600324#ifndef MACOS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600325# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
326 defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
327# define MACOS
328# endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600329#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600330
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500331/* Enough people need this for various reasons to include it here */
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500332#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600333# include <sys/types.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500334#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600335
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500336/* PNG_SETJMP_NOT_SUPPORTED and PNG_NO_SETJMP_SUPPORTED are deprecated. */
337#if !defined(PNG_NO_SETJMP) && \
338 !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600339# define PNG_SETJMP_SUPPORTED
340#endif
341
342#ifdef PNG_SETJMP_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -0500343/* This is an attempt to force a single setjmp behaviour on Linux. If
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600344 * the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
Glenn Randers-Pehrsona93c9422009-04-13 11:41:33 -0500345 *
346 * You can bypass this test if you know that your application uses exactly
347 * the same setjmp.h that was included when libpng was built. Only define
348 * PNG_SKIP_SETJMP_CHECK while building your application, prior to the
349 * application's '#include "png.h"'. Don't define PNG_SKIP_SETJMP_CHECK
350 * while building a separate libpng library for general use.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600351 */
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500352
Glenn Randers-Pehrsona93c9422009-04-13 11:41:33 -0500353# ifndef PNG_SKIP_SETJMP_CHECK
354# ifdef __linux__
355# ifdef _BSD_SOURCE
356# define PNG_SAVE_BSD_SOURCE
357# undef _BSD_SOURCE
358# endif
359# ifdef _SETJMP_H
360 /* If you encounter a compiler error here, see the explanation
361 * near the end of INSTALL.
362 */
363 __pngconf.h__ in libpng already includes setjmp.h;
364 __dont__ include it again.;
365# endif
366# endif /* __linux__ */
367# endif /* PNG_SKIP_SETJMP_CHECK */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500368
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500369 /* Include setjmp.h for error handling */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600370# include <setjmp.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500371
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600372# ifdef __linux__
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500373# ifdef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson56f63962008-10-06 10:16:17 -0500374# ifdef _BSD_SOURCE
375# undef _BSD_SOURCE
376# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600377# define _BSD_SOURCE
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500378# undef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600379# endif
380# endif /* __linux__ */
381#endif /* PNG_SETJMP_SUPPORTED */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600382
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500383#ifdef BSD
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600384# include <strings.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500385#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600386# include <string.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500387#endif
388
Andreas Dilger47a0c421997-05-16 02:46:07 -0500389/* Other defines for things like memory and the like can go here. */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500390
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500391/* This controls how fine the dithering gets. As this allocates
392 * a largish chunk of memory (32K), those who are not as concerned
393 * with dithering quality can decrease some or all of these.
394 */
395#ifndef PNG_DITHER_RED_BITS
396# define PNG_DITHER_RED_BITS 5
397#endif
398#ifndef PNG_DITHER_GREEN_BITS
399# define PNG_DITHER_GREEN_BITS 5
400#endif
401#ifndef PNG_DITHER_BLUE_BITS
402# define PNG_DITHER_BLUE_BITS 5
403#endif
404
405/* This controls how fine the gamma correction becomes when you
406 * are only interested in 8 bits anyway. Increasing this value
407 * results in more memory being used, and more pow() functions
408 * being called to fill in the gamma tables. Don't set this value
409 * less then 8, and even that may not work (I haven't tested it).
410 */
411
412#ifndef PNG_MAX_GAMMA_8
413# define PNG_MAX_GAMMA_8 11
414#endif
415
416/* This controls how much a difference in gamma we can tolerate before
417 * we actually start doing gamma conversion.
418 */
419#ifndef PNG_GAMMA_THRESHOLD
420# define PNG_GAMMA_THRESHOLD 0.05
421#endif
422
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600423/* The following uses const char * instead of char * for error
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600424 * and warning message functions, so some compilers won't complain.
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600425 * If you do not want to use const, define PNG_NO_CONST here.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600426 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600427
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600428#ifndef PNG_NO_CONST
Guy Schalnat6d764711995-12-19 03:22:19 -0600429# define PNG_CONST const
430#else
431# define PNG_CONST
432#endif
433
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600434/* The following defines give you the ability to remove code from the
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600435 * library that you will not be using. I wish I could figure out how to
436 * automate this, but I can't do that without making it seriously hard
437 * on the users. So if you are not using an ability, change the #define
438 * to and #undef, and that part of the library will not be compiled. If
439 * your linker can't find a function, you may want to make sure the
440 * ability is defined here. Some of these depend upon some others being
441 * defined. I haven't figured out all the interactions here, so you may
442 * have to experiment awhile to get everything to compile. If you are
443 * creating or using a shared library, you probably shouldn't touch this,
444 * as it will affect the size of the structures, and this will cause bad
445 * things to happen if the library and/or application ever change.
446 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500447
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500448/* Any features you will not be using can be undef'ed here */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600449
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600450/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500451 * to turn it off with PNG_NO_READ|WRITE_TRANSFORMS on the compile line,
452 * then pick and choose which ones to define without having to edit this
453 * file. It is safe to use the PNG_NO_READ|WRITE_TRANSFORMS
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500454 * if you only want to have a png-compliant reader/writer but don't need
455 * any of the extra transformations. This saves about 80 kbytes in a
456 * typical installation of the library. (PNG_NO_* form added in version
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500457 * 1.0.1c, for consistency; PNG_*_TRANSFORMS_NOT_SUPPORTED deprecated in
458 * 1.4.0)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600459 */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600460
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500461/* Ignore attempt to turn off both floating and fixed point support */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500462#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600463 !defined(PNG_NO_FIXED_POINT_SUPPORTED)
464# define PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500465#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600466
Glenn Randers-Pehrson3b3e0902009-06-16 17:20:43 -0500467#ifdef PNG_READ_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600468
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500469/* PNG_READ_TRANSFORMS_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500470#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600471 !defined(PNG_NO_READ_TRANSFORMS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600472# define PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600473#endif
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600474
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600475#ifdef PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600476# ifndef PNG_NO_READ_EXPAND
477# define PNG_READ_EXPAND_SUPPORTED
478# endif
479# ifndef PNG_NO_READ_SHIFT
480# define PNG_READ_SHIFT_SUPPORTED
481# endif
482# ifndef PNG_NO_READ_PACK
483# define PNG_READ_PACK_SUPPORTED
484# endif
485# ifndef PNG_NO_READ_BGR
486# define PNG_READ_BGR_SUPPORTED
487# endif
488# ifndef PNG_NO_READ_SWAP
489# define PNG_READ_SWAP_SUPPORTED
490# endif
491# ifndef PNG_NO_READ_PACKSWAP
492# define PNG_READ_PACKSWAP_SUPPORTED
493# endif
494# ifndef PNG_NO_READ_INVERT
495# define PNG_READ_INVERT_SUPPORTED
496# endif
Glenn Randers-Pehrson4a82d692008-12-15 16:25:05 -0600497#if 0 /* removed from libpng-1.4.0 */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600498# ifndef PNG_NO_READ_DITHER
499# define PNG_READ_DITHER_SUPPORTED
500# endif
Glenn Randers-Pehrson4a82d692008-12-15 16:25:05 -0600501#endif /* 0 */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600502# ifndef PNG_NO_READ_BACKGROUND
503# define PNG_READ_BACKGROUND_SUPPORTED
504# endif
505# ifndef PNG_NO_READ_16_TO_8
506# define PNG_READ_16_TO_8_SUPPORTED
507# endif
508# ifndef PNG_NO_READ_FILLER
509# define PNG_READ_FILLER_SUPPORTED
510# endif
511# ifndef PNG_NO_READ_GAMMA
512# define PNG_READ_GAMMA_SUPPORTED
513# endif
514# ifndef PNG_NO_READ_GRAY_TO_RGB
515# define PNG_READ_GRAY_TO_RGB_SUPPORTED
516# endif
517# ifndef PNG_NO_READ_SWAP_ALPHA
518# define PNG_READ_SWAP_ALPHA_SUPPORTED
519# endif
520# ifndef PNG_NO_READ_INVERT_ALPHA
521# define PNG_READ_INVERT_ALPHA_SUPPORTED
522# endif
Glenn Randers-Pehrson1916f6a2008-08-14 13:44:49 -0500523# ifndef PNG_NO_READ_PREMULTIPLY_ALPHA
524# define PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
525# endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600526# ifndef PNG_NO_READ_STRIP_ALPHA
527# define PNG_READ_STRIP_ALPHA_SUPPORTED
528# endif
529# ifndef PNG_NO_READ_USER_TRANSFORM
530# define PNG_READ_USER_TRANSFORM_SUPPORTED
531# endif
532# ifndef PNG_NO_READ_RGB_TO_GRAY
533# define PNG_READ_RGB_TO_GRAY_SUPPORTED
534# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600535#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600536
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500537/* PNG_PROGRESSIVE_READ_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500538#if !defined(PNG_NO_PROGRESSIVE_READ) && \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600539 !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
540# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600541#endif /* about interlacing capability! You'll */
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500542 /* still have interlacing unless you change the following define: */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600543
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600544#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500545
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500546/* PNG_NO_SEQUENTIAL_READ_SUPPORTED is deprecated. */
547#if !defined(PNG_NO_SEQUENTIAL_READ) && \
548 !defined(PNG_SEQUENTIAL_READ_SUPPORTED) && \
549 !defined(PNG_NO_SEQUENTIAL_READ_SUPPORTED)
550# define PNG_SEQUENTIAL_READ_SUPPORTED
551#endif
552
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500553#ifndef PNG_NO_READ_COMPOSITE_NODIV
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600554# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
555# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
556# endif
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500557#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500558
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500559#if !defined(PNG_NO_GET_INT_32) || defined(PNG_READ_oFFS_SUPPORTED) || \
560 defined(PNG_READ_pCAL_SUPPORTED)
561# ifndef PNG_GET_INT_32_SUPPORTED
562# define PNG_GET_INT_32_SUPPORTED
563# endif
564#endif
565
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600566#endif /* PNG_READ_SUPPORTED */
567
Glenn Randers-Pehrson3b3e0902009-06-16 17:20:43 -0500568#ifdef PNG_WRITE_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600569
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500570/* PNG_WRITE_TRANSFORMS_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600571# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
572 !defined(PNG_NO_WRITE_TRANSFORMS)
573# define PNG_WRITE_TRANSFORMS_SUPPORTED
574#endif
575
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600576#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600577# ifndef PNG_NO_WRITE_SHIFT
578# define PNG_WRITE_SHIFT_SUPPORTED
579# endif
580# ifndef PNG_NO_WRITE_PACK
581# define PNG_WRITE_PACK_SUPPORTED
582# endif
583# ifndef PNG_NO_WRITE_BGR
584# define PNG_WRITE_BGR_SUPPORTED
585# endif
586# ifndef PNG_NO_WRITE_SWAP
587# define PNG_WRITE_SWAP_SUPPORTED
588# endif
589# ifndef PNG_NO_WRITE_PACKSWAP
590# define PNG_WRITE_PACKSWAP_SUPPORTED
591# endif
592# ifndef PNG_NO_WRITE_INVERT
593# define PNG_WRITE_INVERT_SUPPORTED
594# endif
595# ifndef PNG_NO_WRITE_FILLER
596# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */
597# endif
598# ifndef PNG_NO_WRITE_SWAP_ALPHA
599# define PNG_WRITE_SWAP_ALPHA_SUPPORTED
600# endif
601# ifndef PNG_NO_WRITE_INVERT_ALPHA
602# define PNG_WRITE_INVERT_ALPHA_SUPPORTED
603# endif
604# ifndef PNG_NO_WRITE_USER_TRANSFORM
605# define PNG_WRITE_USER_TRANSFORM_SUPPORTED
606# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600607#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600608
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600609#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \
610 !defined(PNG_WRITE_INTERLACING_SUPPORTED)
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600611#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
612 encoders, but can cause trouble
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600613 if left undefined */
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600614#endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600615
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500616#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600617 !defined(PNG_WRITE_WEIGHTED_FILTER) && \
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500618 defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600619# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500620#endif
621
622#ifndef PNG_NO_WRITE_FLUSH
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600623# define PNG_WRITE_FLUSH_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500624#endif
625
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500626#if !defined(PNG_NO_SAVE_INT_32) || defined(PNG_WRITE_oFFS_SUPPORTED) || \
627 defined(PNG_WRITE_pCAL_SUPPORTED)
628# ifndef PNG_SAVE_INT_32_SUPPORTED
629# define PNG_SAVE_INT_32_SUPPORTED
630# endif
631#endif
632
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600633#endif /* PNG_WRITE_SUPPORTED */
634
Glenn Randers-Pehrson895a9c92008-07-25 08:51:18 -0500635#define PNG_NO_ERROR_NUMBERS
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500636
637#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
638 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
639# ifndef PNG_NO_USER_TRANSFORM_PTR
640# define PNG_USER_TRANSFORM_PTR_SUPPORTED
641# endif
642#endif
643
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500644#if defined(PNG_STDIO_SUPPORTED) && !defined(PNG_TIME_RFC1123_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600645# define PNG_TIME_RFC1123_SUPPORTED
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600646#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500647
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600648/* This adds extra functions in pngget.c for accessing data from the
649 * info pointer (added in version 0.99)
650 * png_get_image_width()
651 * png_get_image_height()
652 * png_get_bit_depth()
653 * png_get_color_type()
654 * png_get_compression_type()
655 * png_get_filter_type()
656 * png_get_interlace_type()
657 * png_get_pixel_aspect_ratio()
658 * png_get_pixels_per_meter()
659 * png_get_x_offset_pixels()
660 * png_get_y_offset_pixels()
661 * png_get_x_offset_microns()
662 * png_get_y_offset_microns()
663 */
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500664#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600665# define PNG_EASY_ACCESS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600666#endif
667
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500668#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
669# define PNG_USER_MEM_SUPPORTED
670#endif
671
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500672/* Added at libpng-1.2.6 */
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500673#ifndef PNG_SET_USER_LIMITS_SUPPORTED
674#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED)
675# define PNG_SET_USER_LIMITS_SUPPORTED
676#endif
677#endif
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500678
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500679/* 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 -0500680 * how large, set these limits to 0x7fffffffL
681 */
682#ifndef PNG_USER_WIDTH_MAX
683# define PNG_USER_WIDTH_MAX 1000000L
684#endif
685#ifndef PNG_USER_HEIGHT_MAX
686# define PNG_USER_HEIGHT_MAX 1000000L
687#endif
688
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500689/* Added at libpng-1.4.0 */
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -0500690#ifndef PNG_USER_CHUNK_CACHE_MAX
691# define PNG_USER_CHUNK_CACHE_MAX 0x7ffffffLL
692#endif
693
694/* Added at libpng-1.4.0 */
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500695#if !defined(PNG_NO_IO_STATE) && !defined(PNG_IO_STATE_SUPPORTED)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500696# define PNG_IO_STATE_SUPPORTED
697#endif
698
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500699#ifndef PNG_LITERAL_SHARP
700# define PNG_LITERAL_SHARP 0x23
701#endif
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500702#ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500703# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500704#endif
705#ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500706# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500707#endif
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500708#ifndef PNG_STRING_NEWLINE
Glenn Randers-Pehrsone0784c72008-08-09 07:11:44 -0500709#define PNG_STRING_NEWLINE "\n"
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500710#endif
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500711
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600712/* These are currently experimental features, define them if you want */
713
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500714/* Very little testing */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600715/*
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600716#ifdef PNG_READ_SUPPORTED
717# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
718# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
719# endif
720#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600721*/
Andreas Dilger47a0c421997-05-16 02:46:07 -0500722
723/* This is only for PowerPC big-endian and 680x0 systems */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600724/* some testing */
725/*
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500726#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
727# define PNG_READ_BIG_ENDIAN_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600728#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600729*/
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500730
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500731#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
732# define PNG_USE_READ_MACROS
733#endif
734
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500735/* Buggy compilers (e.g., gcc 2.7.2.2) need PNG_NO_POINTER_INDEXING */
736
737#if !defined(PNG_NO_POINTER_INDEXING) && \
738 !defined(PNG_POINTER_INDEXING_SUPPORTED)
739# define PNG_POINTER_INDEXING_SUPPORTED
740#endif
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -0500741
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600742
Andreas Dilger47a0c421997-05-16 02:46:07 -0500743/* Any chunks you are not interested in, you can undef here. The
744 * ones that allocate memory may be expecially important (hIST,
745 * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600746 * a bit smaller.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500747 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500748
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500749/* The size of the png_text structure changed in libpng-1.0.6 when
750 * iTXt support was added. iTXt support was turned off by default through
751 * libpng-1.2.x, to support old apps that malloc the png_text structure
752 * instead of calling png_set_text() and letting libpng malloc it. It
753 * was turned on by default in libpng-1.4.0.
754 */
755
756/* PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600757#if defined(PNG_READ_SUPPORTED) && \
758 !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500759 !defined(PNG_NO_READ_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600760# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600761#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600762
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500763/* PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600764#if defined(PNG_WRITE_SUPPORTED) && \
765 !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500766 !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600767# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600768#endif
769
770#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600771
772#ifdef PNG_NO_READ_TEXT
773# define PNG_NO_READ_iTXt
774# define PNG_NO_READ_tEXt
775# define PNG_NO_READ_zTXt
776#endif
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500777
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500778#ifndef PNG_NO_READ_bKGD
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600779# define PNG_READ_bKGD_SUPPORTED
780# define PNG_bKGD_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500781#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500782#ifndef PNG_NO_READ_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600783# define PNG_READ_cHRM_SUPPORTED
784# define PNG_cHRM_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500785#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500786#ifndef PNG_NO_READ_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600787# define PNG_READ_gAMA_SUPPORTED
788# define PNG_gAMA_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500789#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500790#ifndef PNG_NO_READ_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600791# define PNG_READ_hIST_SUPPORTED
792# define PNG_hIST_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600793#endif
794#ifndef PNG_NO_READ_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600795# define PNG_READ_iCCP_SUPPORTED
796# define PNG_iCCP_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600797#endif
798#ifndef PNG_NO_READ_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500799# ifndef PNG_READ_iTXt_SUPPORTED
800# define PNG_READ_iTXt_SUPPORTED
801# endif
802# ifndef PNG_iTXt_SUPPORTED
803# define PNG_iTXt_SUPPORTED
804# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500805#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500806#ifndef PNG_NO_READ_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600807# define PNG_READ_oFFs_SUPPORTED
808# define PNG_oFFs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500809#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500810#ifndef PNG_NO_READ_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600811# define PNG_READ_pCAL_SUPPORTED
812# define PNG_pCAL_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600813#endif
814#ifndef PNG_NO_READ_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600815# define PNG_READ_sCAL_SUPPORTED
816# define PNG_sCAL_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500817#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500818#ifndef PNG_NO_READ_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600819# define PNG_READ_pHYs_SUPPORTED
820# define PNG_pHYs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500821#endif
822#ifndef PNG_NO_READ_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600823# define PNG_READ_sBIT_SUPPORTED
824# define PNG_sBIT_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600825#endif
826#ifndef PNG_NO_READ_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600827# define PNG_READ_sPLT_SUPPORTED
828# define PNG_sPLT_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500829#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500830#ifndef PNG_NO_READ_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600831# define PNG_READ_sRGB_SUPPORTED
832# define PNG_sRGB_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500833#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500834#ifndef PNG_NO_READ_tEXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600835# define PNG_READ_tEXt_SUPPORTED
836# define PNG_tEXt_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500837#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500838#ifndef PNG_NO_READ_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600839# define PNG_READ_tIME_SUPPORTED
840# define PNG_tIME_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500841#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500842#ifndef PNG_NO_READ_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600843# define PNG_READ_tRNS_SUPPORTED
844# define PNG_tRNS_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500845#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500846#ifndef PNG_NO_READ_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600847# define PNG_READ_zTXt_SUPPORTED
848# define PNG_zTXt_SUPPORTED
849#endif
Glenn Randers-Pehrson658ea432009-06-16 16:24:57 -0500850#ifndef PNG_NO_READ_OPT_PLTE
851# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
852#endif /* optional PLTE chunk in RGB and RGBA images */
853#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
854 defined(PNG_READ_zTXt_SUPPORTED)
855# define PNG_READ_TEXT_SUPPORTED
856# define PNG_TEXT_SUPPORTED
857#endif
858
859#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
860
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500861#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
862# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500863# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
864# define PNG_UNKNOWN_CHUNKS_SUPPORTED
865# endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500866#endif
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -0500867#if !defined(PNG_NO_READ_USER_CHUNKS) && \
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500868 defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600869# define PNG_READ_USER_CHUNKS_SUPPORTED
870# define PNG_USER_CHUNKS_SUPPORTED
871# ifdef PNG_NO_READ_UNKNOWN_CHUNKS
872# undef PNG_NO_READ_UNKNOWN_CHUNKS
873# endif
874# ifdef PNG_NO_HANDLE_AS_UNKNOWN
875# undef PNG_NO_HANDLE_AS_UNKNOWN
876# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600877#endif
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500878#ifndef PNG_NO_HANDLE_AS_UNKNOWN
879# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
880# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
881# endif
882#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500883
Glenn Randers-Pehrson3b3e0902009-06-16 17:20:43 -0500884#ifdef PNG_WRITE_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600885#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600886
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600887#ifdef PNG_NO_WRITE_TEXT
888# define PNG_NO_WRITE_iTXt
889# define PNG_NO_WRITE_tEXt
890# define PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600891#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600892#ifndef PNG_NO_WRITE_bKGD
893# define PNG_WRITE_bKGD_SUPPORTED
894# ifndef PNG_bKGD_SUPPORTED
895# define PNG_bKGD_SUPPORTED
896# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500897#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500898#ifndef PNG_NO_WRITE_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600899# define PNG_WRITE_cHRM_SUPPORTED
900# ifndef PNG_cHRM_SUPPORTED
901# define PNG_cHRM_SUPPORTED
902# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500903#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500904#ifndef PNG_NO_WRITE_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600905# define PNG_WRITE_gAMA_SUPPORTED
906# ifndef PNG_gAMA_SUPPORTED
907# define PNG_gAMA_SUPPORTED
908# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500909#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500910#ifndef PNG_NO_WRITE_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600911# define PNG_WRITE_hIST_SUPPORTED
912# ifndef PNG_hIST_SUPPORTED
913# define PNG_hIST_SUPPORTED
914# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600915#endif
916#ifndef PNG_NO_WRITE_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600917# define PNG_WRITE_iCCP_SUPPORTED
918# ifndef PNG_iCCP_SUPPORTED
919# define PNG_iCCP_SUPPORTED
920# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600921#endif
922#ifndef PNG_NO_WRITE_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500923# ifndef PNG_WRITE_iTXt_SUPPORTED
924# define PNG_WRITE_iTXt_SUPPORTED
925# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600926# ifndef PNG_iTXt_SUPPORTED
927# define PNG_iTXt_SUPPORTED
928# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500929#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500930#ifndef PNG_NO_WRITE_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600931# define PNG_WRITE_oFFs_SUPPORTED
932# ifndef PNG_oFFs_SUPPORTED
933# define PNG_oFFs_SUPPORTED
934# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500935#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500936#ifndef PNG_NO_WRITE_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600937# define PNG_WRITE_pCAL_SUPPORTED
938# ifndef PNG_pCAL_SUPPORTED
939# define PNG_pCAL_SUPPORTED
940# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600941#endif
942#ifndef PNG_NO_WRITE_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600943# define PNG_WRITE_sCAL_SUPPORTED
944# ifndef PNG_sCAL_SUPPORTED
945# define PNG_sCAL_SUPPORTED
946# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500947#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500948#ifndef PNG_NO_WRITE_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600949# define PNG_WRITE_pHYs_SUPPORTED
950# ifndef PNG_pHYs_SUPPORTED
951# define PNG_pHYs_SUPPORTED
952# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500953#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500954#ifndef PNG_NO_WRITE_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600955# define PNG_WRITE_sBIT_SUPPORTED
956# ifndef PNG_sBIT_SUPPORTED
957# define PNG_sBIT_SUPPORTED
958# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600959#endif
960#ifndef PNG_NO_WRITE_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600961# define PNG_WRITE_sPLT_SUPPORTED
962# ifndef PNG_sPLT_SUPPORTED
963# define PNG_sPLT_SUPPORTED
964# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500965#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500966#ifndef PNG_NO_WRITE_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600967# define PNG_WRITE_sRGB_SUPPORTED
968# ifndef PNG_sRGB_SUPPORTED
969# define PNG_sRGB_SUPPORTED
970# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500971#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500972#ifndef PNG_NO_WRITE_tEXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600973# define PNG_WRITE_tEXt_SUPPORTED
974# ifndef PNG_tEXt_SUPPORTED
975# define PNG_tEXt_SUPPORTED
976# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500977#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500978#ifndef PNG_NO_WRITE_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600979# define PNG_WRITE_tIME_SUPPORTED
980# ifndef PNG_tIME_SUPPORTED
981# define PNG_tIME_SUPPORTED
982# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500983#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500984#ifndef PNG_NO_WRITE_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600985# define PNG_WRITE_tRNS_SUPPORTED
986# ifndef PNG_tRNS_SUPPORTED
987# define PNG_tRNS_SUPPORTED
988# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500989#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500990#ifndef PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600991# define PNG_WRITE_zTXt_SUPPORTED
992# ifndef PNG_zTXt_SUPPORTED
993# define PNG_zTXt_SUPPORTED
994# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600995#endif
Glenn Randers-Pehrson658ea432009-06-16 16:24:57 -0500996#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
997 defined(PNG_WRITE_zTXt_SUPPORTED)
998# define PNG_WRITE_TEXT_SUPPORTED
999# ifndef PNG_TEXT_SUPPORTED
1000# define PNG_TEXT_SUPPORTED
1001# endif
1002#endif
1003
1004#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
1005
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -05001006#if !defined(PNG_NO_WRITE_FILTER) && !defined(PNG_WRITE_FILTER_SUPPORTED)
1007# define PNG_WRITE_FILTER_SUPPORTED
1008#endif
1009
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001010#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001011# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
1012# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
1013# define PNG_UNKNOWN_CHUNKS_SUPPORTED
1014# endif
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -05001015#endif
1016#ifndef PNG_NO_HANDLE_AS_UNKNOWN
1017# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
1018# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001019# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001020#endif
Glenn Randers-Pehrson3b3e0902009-06-16 17:20:43 -05001021#endif /* PNG_WRITE_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001022
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001023/* Turn this off to disable png_read_png() and
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001024 * png_write_png() and leave the row_pointers member
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001025 * out of the info structure.
1026 */
1027#ifndef PNG_NO_INFO_IMAGE
1028# define PNG_INFO_IMAGE_SUPPORTED
1029#endif
1030
Andreas Dilger47a0c421997-05-16 02:46:07 -05001031/* need the time information for reading tIME chunks */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -05001032#ifdef PNG_tIME_SUPPORTED
1033# ifndef _WIN32_WCE
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -05001034 /* "time.h" functions are not supported on WindowsCE */
1035# include <time.h>
1036# endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001037#endif
1038
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001039/* Some typedefs to get us started. These should be safe on most of the
Andreas Dilger47a0c421997-05-16 02:46:07 -05001040 * common platforms. The typedefs should be at least as large as the
1041 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
1042 * don't have to be exactly that size. Some compilers dislike passing
1043 * unsigned shorts as function parameters, so you may be better off using
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001044 * unsigned int for png_uint_16.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001045 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001046
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05001047#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
1048typedef unsigned int png_uint_32;
1049typedef int png_int_32;
1050#else
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001051typedef unsigned long png_uint_32;
1052typedef long png_int_32;
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05001053#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001054typedef unsigned short png_uint_16;
1055typedef short png_int_16;
1056typedef unsigned char png_byte;
1057
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001058#ifdef PNG_NO_SIZE_T
1059 typedef unsigned int png_size_t;
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05001060#else
1061 typedef size_t png_size_t;
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05001062#endif
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001063#define png_sizeof(x) sizeof(x)
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001064
Andreas Dilger47a0c421997-05-16 02:46:07 -05001065/* The following is needed for medium model support. It cannot be in the
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05001066 * pngpriv.h header. Needs modification for other compilers besides
Andreas Dilger47a0c421997-05-16 02:46:07 -05001067 * MSC. Model independent support declares all arrays and pointers to be
1068 * large using the far keyword. The zlib version used must also support
1069 * model independent data. As of version zlib 1.0.4, the necessary changes
1070 * have been made in zlib. The USE_FAR_KEYWORD define triggers other
1071 * changes that are needed. (Tim Wegner)
1072 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001073
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001074/* Separate compiler dependencies (problem here is that zlib.h always
1075 defines FAR. (SJT) */
Guy Schalnat6d764711995-12-19 03:22:19 -06001076#ifdef __BORLANDC__
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001077# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
1078# define LDATA 1
1079# else
1080# define LDATA 0
1081# endif
1082 /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
1083# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
1084# define PNG_MAX_MALLOC_64K
1085# if (LDATA != 1)
1086# ifndef FAR
1087# define FAR __far
1088# endif
1089# define USE_FAR_KEYWORD
1090# endif /* LDATA != 1 */
1091 /* Possibly useful for moving data out of default segment.
1092 * Uncomment it if you want. Could also define FARDATA as
1093 * const if your compiler supports it. (SJT)
1094# define FARDATA FAR
1095 */
1096# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
Guy Schalnatb2e01bd1996-01-26 01:38:47 -06001097#endif /* __BORLANDC__ */
Guy Schalnat6d764711995-12-19 03:22:19 -06001098
1099
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001100/* Suggest testing for specific compiler first before testing for
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001101 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
1102 * making reliance oncertain keywords suspect. (SJT)
1103 */
Guy Schalnat6d764711995-12-19 03:22:19 -06001104
1105/* MSC Medium model */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -05001106#ifdef FAR
1107# ifdef M_I86MM
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001108# define USE_FAR_KEYWORD
1109# define FARDATA FAR
1110# include <dos.h>
Guy Schalnat6d764711995-12-19 03:22:19 -06001111# endif
1112#endif
1113
1114/* SJT: default case */
1115#ifndef FAR
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001116# define FAR
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001117#endif
1118
Andreas Dilger47a0c421997-05-16 02:46:07 -05001119/* At this point FAR is always defined */
Guy Schalnat6d764711995-12-19 03:22:19 -06001120#ifndef FARDATA
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001121# define FARDATA
Guy Schalnat6d764711995-12-19 03:22:19 -06001122#endif
1123
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001124/* Typedef for floating-point numbers that are converted
1125 to fixed-point with a multiple of 100,000, e.g., int_gamma */
1126typedef png_int_32 png_fixed_point;
1127
Andreas Dilger47a0c421997-05-16 02:46:07 -05001128/* Add typedefs for pointers */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001129typedef void FAR * png_voidp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001130typedef png_byte FAR * png_bytep;
1131typedef png_uint_32 FAR * png_uint_32p;
1132typedef png_int_32 FAR * png_int_32p;
1133typedef png_uint_16 FAR * png_uint_16p;
1134typedef png_int_16 FAR * png_int_16p;
1135typedef PNG_CONST char FAR * png_const_charp;
1136typedef char FAR * png_charp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001137typedef png_fixed_point FAR * png_fixed_point_p;
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001138
1139#ifndef PNG_NO_STDIO
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -05001140#ifdef _WIN32_WCE
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -05001141typedef HANDLE png_FILE_p;
1142#else
1143typedef FILE * png_FILE_p;
1144#endif
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001145#endif
1146
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001147#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001148typedef double FAR * png_doublep;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001149#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001150
Andreas Dilger47a0c421997-05-16 02:46:07 -05001151/* Pointers to pointers; i.e. arrays */
Guy Schalnat6d764711995-12-19 03:22:19 -06001152typedef png_byte FAR * FAR * png_bytepp;
1153typedef png_uint_32 FAR * FAR * png_uint_32pp;
1154typedef png_int_32 FAR * FAR * png_int_32pp;
1155typedef png_uint_16 FAR * FAR * png_uint_16pp;
1156typedef png_int_16 FAR * FAR * png_int_16pp;
1157typedef PNG_CONST char FAR * FAR * png_const_charpp;
1158typedef char FAR * FAR * png_charpp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001159typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001160#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001161typedef double FAR * FAR * png_doublepp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001162#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001163
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001164/* Pointers to pointers to pointers; i.e., pointer to array */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001165typedef char FAR * FAR * FAR * png_charppp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001166
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001167/*
1168 * Define PNG_BUILD_DLL if the module being built is a Windows
1169 * LIBPNG DLL.
1170 *
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001171 * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL.
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -06001172 * It is equivalent to Microsoft predefined macro _DLL that is
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001173 * automatically defined when you compile using the share
1174 * version of the CRT (C Run-Time library)
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001175 *
1176 * The cygwin mods make this behavior a little different:
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001177 * Define PNG_BUILD_DLL if you are building a dll for use with cygwin
1178 * Define PNG_STATIC if you are building a static library for use with cygwin,
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001179 * -or- if you are building an application that you want to link to the
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001180 * static library.
1181 * PNG_USE_DLL is defined by default (no user action needed) unless one of
1182 * the other flags is defined.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001183 */
1184
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001185#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001186# define PNG_DLL
1187#endif
Glenn Randers-Pehrsonec61c232000-05-16 06:17:36 -05001188
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -05001189#ifdef __CYGWIN__
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001190# undef PNGAPI
1191# define PNGAPI __cdecl
1192# undef PNG_IMPEXP
1193# define PNG_IMPEXP
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -05001194#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001195
Glenn Randers-Pehrson9e978842009-08-31 14:28:33 -05001196#define PNG_USE_LOCAL_ARRAYS /* Not used in libpng, defined for legacy apps */
1197
Glenn Randers-Pehrson25d82242002-05-01 11:51:26 -05001198/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
1199 * you may get warnings regarding the linkage of png_zalloc and png_zfree.
1200 * Don't ignore those warnings; you must also reset the default calling
1201 * convention in your compiler to match your PNGAPI, and you must build
1202 * zlib and your applications the same way you build libpng.
1203 */
1204
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001205#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001206# ifndef PNG_NO_MODULEDEF
1207# define PNG_NO_MODULEDEF
1208# endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001209#endif
1210
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001211#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001212# define PNG_IMPEXP
1213#endif
1214
1215#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001216 (( defined(_Windows) || defined(_WINDOWS) || \
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -05001217 defined(WIN32) || defined(_WIN32) || defined(__WIN32__) ))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001218
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001219# ifndef PNGAPI
1220# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
1221# define PNGAPI __cdecl
1222# else
1223# define PNGAPI _cdecl
1224# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001225# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001226
1227# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \
1228 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */)
1229# define PNG_IMPEXP
1230# endif
1231
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -05001232# ifndef PNG_IMPEXP
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001233
1234# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol
1235# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol
1236
1237 /* Borland/Microsoft */
1238# if defined(_MSC_VER) || defined(__BORLANDC__)
1239# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
1240# define PNG_EXPORT PNG_EXPORT_TYPE1
1241# else
1242# define PNG_EXPORT PNG_EXPORT_TYPE2
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -05001243# ifdef PNG_BUILD_DLL
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001244# define PNG_IMPEXP __export
1245# else
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -05001246# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in
1247 VC++ */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001248# endif /* Exists in Borland C++ for
1249 C++ classes (== huge) */
1250# endif
1251# endif
1252
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -05001253# ifndef PNG_IMPEXP
1254# ifdef PNG_BUILD_DLL
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001255# define PNG_IMPEXP __declspec(dllexport)
1256# else
1257# define PNG_IMPEXP __declspec(dllimport)
1258# endif
1259# endif
1260# endif /* PNG_IMPEXP */
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001261#else /* !(DLL || non-cygwin WINDOWS) */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001262# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
1263# ifndef PNGAPI
1264# define PNGAPI _System
Glenn Randers-Pehrsonf64a06f2001-04-11 07:38:00 -05001265# endif
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001266# else
1267# if 0 /* ... other platforms, with other meanings */
1268# endif
1269# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001270#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001271
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -06001272#ifndef PNGAPI
1273# define PNGAPI
1274#endif
1275#ifndef PNG_IMPEXP
1276# define PNG_IMPEXP
1277#endif
1278
Glenn Randers-Pehrsonc3dda6d2004-11-27 18:22:29 -06001279#ifdef PNG_BUILDSYMS
1280# ifndef PNG_EXPORT
1281# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END
1282# endif
Glenn Randers-Pehrsonc3dda6d2004-11-27 18:22:29 -06001283#endif
1284
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -05001285#ifndef PNG_EXPORT
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001286# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001287#endif
1288
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001289/* Users may want to use these so they are not private. Any library
1290 * functions that are passed far data must be model-independent.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001291 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001292
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001293#ifdef PNG_SETJMP_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001294# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06001295#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001296# define png_jmpbuf(png_ptr) \
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -05001297 (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001298#endif
1299
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001300/* memory model/platform independent fns */
1301#ifndef PNG_ABORT
1302# ifdef _WINDOWS_
1303# define PNG_ABORT() ExitProcess(0)
1304# else
1305# define PNG_ABORT() abort()
1306# endif
1307#endif
1308
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -05001309#ifdef USE_FAR_KEYWORD
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001310/* use this to make far-to-near assignments */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001311# define CHECK 1
1312# define NOCHECK 0
1313# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
1314# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001315# define png_strcpy _fstrcpy
1316# define png_strncpy _fstrncpy /* Added to v 1.2.6 */
1317# define png_strlen _fstrlen
1318# define png_memcmp _fmemcmp /* SJT: added */
1319# define png_memcpy _fmemcpy
Glenn Randers-Pehrson8551d592009-08-29 16:25:19 -05001320# define png_memset _fmemset
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001321# define png_sprintf sprintf
1322#else
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -05001323# ifdef _WINDOWS_ /* favor Windows over C runtime fns */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001324# define CVT_PTR(ptr) (ptr)
1325# define CVT_PTR_NOCHECK(ptr) (ptr)
1326# define png_strcpy lstrcpyA
1327# define png_strncpy lstrcpynA
1328# define png_strlen lstrlenA
1329# define png_memcmp memcmp
1330# define png_memcpy CopyMemory
1331# define png_memset memset
1332# define png_sprintf wsprintfA
1333# else
1334# define CVT_PTR(ptr) (ptr)
1335# define CVT_PTR_NOCHECK(ptr) (ptr)
1336# define png_strcpy strcpy
1337# define png_strncpy strncpy /* Added to v 1.2.6 */
1338# define png_strlen strlen
1339# define png_memcmp memcmp /* SJT: added */
1340# define png_memcpy memcpy
1341# define png_memset memset
1342# define png_sprintf sprintf
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001343# ifndef PNG_NO_SNPRINTF
1344# ifdef _MSC_VER
1345# define png_snprintf _snprintf /* Added to v 1.2.19 */
1346# define png_snprintf2 _snprintf
1347# define png_snprintf6 _snprintf
1348# else
1349# define png_snprintf snprintf /* Added to v 1.2.19 */
1350# define png_snprintf2 snprintf
1351# define png_snprintf6 snprintf
1352# endif
1353# else
1354 /* You don't have or don't want to use snprintf(). Caution: Using
1355 * sprintf instead of snprintf exposes your application to accidental
1356 * or malevolent buffer overflows. If you don't have snprintf()
1357 * as a general rule you should provide one (you can get one from
1358 * Portable OpenSSH). */
1359# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1)
1360# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2)
1361# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
1362 sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
1363# endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001364# endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001365#endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001366
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001367/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
1368 * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
1369 * to png_alloc_size_t are not necessary; in fact, it is recommended
1370 * not to use them at all so that the compiler can complain when something
1371 * turns out to be problematic.
1372 * Casts in the other direction (from png_alloc_size_t to png_size_t or
1373 * png_uint_32) should be explicitly applied; however, we do not expect
1374 * to encounter practical situations that require such conversions.
1375 */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001376#if defined(__TURBOC__) && !defined(__FLAT__)
1377# define png_mem_alloc farmalloc
1378# define png_mem_free farfree
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001379 typedef unsigned long png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001380#else
1381# if defined(_MSC_VER) && defined(MAXSEG_64K)
1382# define png_mem_alloc(s) halloc(s, 1)
1383# define png_mem_free hfree
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001384 typedef unsigned long png_alloc_size_t;
1385# else
1386# if defined(_WINDOWS_) && (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001387# define png_mem_alloc(s) HeapAlloc(GetProcessHeap(), 0, s)
1388# define png_mem_free(p) HeapFree(GetProcessHeap(), 0, p)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001389 typedef DWORD png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001390# else
1391# define png_mem_alloc malloc
1392# define png_mem_free free
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001393 typedef png_size_t png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001394# endif
1395# endif
1396#endif
1397/* End of memory model/platform independent support */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001398
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001399/* Just a little check that someone hasn't tried to define something
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001400 * contradictory.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001401 */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001402#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001403# undef PNG_ZBUF_SIZE
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001404# define PNG_ZBUF_SIZE 65536L
Andreas Dilger47a0c421997-05-16 02:46:07 -05001405#endif
1406
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001407
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -06001408/* Added at libpng-1.2.8 */
1409#endif /* PNG_VERSION_INFO_ONLY */
Glenn Randers-Pehrson40936072004-11-20 11:18:40 -06001410
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001411#endif /* PNGCONF_H */