blob: d384d4e3e2e8b659ef5efb52b0281e133f87a93a [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-Pehrsondbd40142009-08-31 08:42:02 -05004 * libpng version 1.4.0beta78 - August 31, 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-Pehrson0ffb71a2009-02-28 06:08:20 -060051/* Added at libpng-1.4.0beta49 for testing */
52#ifndef PNG_NO_CALLOC
53# define PNG_CALLOC_SUPPORTED
54#endif
55
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -050056/*
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060057 * If you create a private DLL you need to define in "pngusr.h" the followings:
58 * #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
59 * the DLL was built>
60 * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
61 * #define PNG_USER_DLLFNAME_POSTFIX <two-letter postfix that serve to
62 * distinguish your DLL from those of the official release. These
63 * correspond to the trailing letters that come after the version
64 * number and must match your private DLL name>
65 * e.g. // private DLL "libpng13gx.dll"
66 * #define PNG_USER_DLLFNAME_POSTFIX "gx"
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -050067 *
68 * The following macros are also at your disposal if you want to complete the
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060069 * DLL VERSIONINFO structure.
70 * - PNG_USER_VERSIONINFO_COMMENTS
71 * - PNG_USER_VERSIONINFO_COMPANYNAME
72 * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS
73 */
74
75#ifdef __STDC__
76#ifdef SPECIALBUILD
77# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\
78 are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.")
79#endif
80
81#ifdef PRIVATEBUILD
Glenn Randers-Pehrson3a512032006-03-31 05:29:33 -060082# pragma message("PRIVATEBUILD is deprecated.\
83 Use PNG_USER_PRIVATEBUILD instead.")
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060084# define PNG_USER_PRIVATEBUILD PRIVATEBUILD
85#endif
86#endif /* __STDC__ */
87
88#ifndef PNG_VERSION_INFO_ONLY
89
90/* End of material added to libpng-1.2.8 */
Glenn Randers-Pehrson878b31e2004-11-12 22:04:56 -060091
Andreas Dilger02ad0ef1997-01-17 01:34:35 -060092/* This is the size of the compression buffer, and thus the size of
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060093 * an IDAT chunk. Make this whatever size you feel is best for your
94 * machine. One of these will be allocated per png_struct. When this
95 * is full, it writes the data to the disk, and does some other
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -060096 * calculations. Making this an extremely small size will slow
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060097 * the library down, but you may want to experiment to determine
98 * where it becomes significant, if you are concerned with memory
99 * usage. Note that zlib allocates at least 32Kb also. For readers,
100 * this describes the size of the buffer available to read the data in.
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600101 * Unless this gets smaller than the size of a row (compressed),
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600102 * it should not make much difference how big this is.
103 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500104
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600105#ifndef PNG_ZBUF_SIZE
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600106# define PNG_ZBUF_SIZE 8192
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600107#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500108
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600109/* Enable if you want a write-only libpng */
110
111#ifndef PNG_NO_READ_SUPPORTED
112# define PNG_READ_SUPPORTED
113#endif
114
115/* Enable if you want a read-only libpng */
116
117#ifndef PNG_NO_WRITE_SUPPORTED
118# define PNG_WRITE_SUPPORTED
119#endif
120
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500121/* Enabled in 1.4.0. */
122#ifdef PNG_ALLOW_BENIGN_ERRORS
123# define png_benign_error png_warning
124# define png_chunk_benign_error png_chunk_warning
125#else
126# ifndef PNG_BENIGN_ERRORS_SUPPORTED
127# define png_benign_error png_error
128# define png_chunk_benign_error png_chunk_error
129# endif
130#endif
131
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500132/* Added at libpng version 1.4.0 */
133#if !defined(PNG_NO_WARNINGS) && !defined(PNG_WARNINGS_SUPPORTED)
134# define PNG_WARNINGS_SUPPORTED
135#endif
136
137#if !defined(PNG_NO_ERROR_TEXT) && !defined(PNG_ERROR_TEXT_SUPPORTED)
138# define PNG_ERROR_TEXT_SUPPORTED
139#endif
140
141#if !defined(PNG_NO_CHECK_cHRM) && !defined(PNG_CHECK_cHRM_SUPPORTED)
142# define PNG_CHECK_cHRM_SUPPORTED
143#endif
144
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500145/* Enabled by default in 1.2.0. You can disable this if you don't need to
146 support PNGs that are embedded in MNG datastreams */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500147#if !defined(PNG_NO_MNG_FEATURES)
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600148# ifndef PNG_MNG_FEATURES_SUPPORTED
149# define PNG_MNG_FEATURES_SUPPORTED
150# endif
151#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600152
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500153/* Added at libpng version 1.4.0 */
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -0600154#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600155# ifndef PNG_FLOATING_POINT_SUPPORTED
156# define PNG_FLOATING_POINT_SUPPORTED
157# endif
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500158#endif
159
Andreas Dilger47a0c421997-05-16 02:46:07 -0500160/* If you are running on a machine where you cannot allocate more
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600161 * than 64K of memory at once, uncomment this. While libpng will not
162 * normally need that much memory in a chunk (unless you load up a very
163 * large file), zlib needs to know how big of a chunk it can use, and
164 * libpng thus makes sure to check any memory allocation to verify it
165 * will fit into memory.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500166#define PNG_MAX_MALLOC_64K
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600167 */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500168#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600169# define PNG_MAX_MALLOC_64K
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500170#endif
171
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500172/* Special munging to support doing things the 'cygwin' way:
173 * 'Normal' png-on-win32 defines/defaults:
174 * PNG_BUILD_DLL -- building dll
175 * PNG_USE_DLL -- building an application, linking to dll
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -0600176 * (no define) -- building static library, or building an
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500177 * application and linking to the static lib
178 * 'Cygwin' defines/defaults:
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500179 * PNG_BUILD_DLL -- (ignored) building the dll
180 * (no define) -- (ignored) building an application, linking to the dll
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500181 * PNG_STATIC -- (ignored) building the static lib, or building an
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500182 * application that links to the static lib.
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500183 * ALL_STATIC -- (ignored) building various static libs, or building an
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500184 * application that links to the static libs.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500185 * Thus,
186 * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
187 * this bit of #ifdefs will define the 'correct' config variables based on
188 * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but
189 * unnecessary.
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500190 *
191 * Also, the precedence order is:
192 * ALL_STATIC (since we can't #undef something outside our namespace)
193 * PNG_BUILD_DLL
194 * PNG_STATIC
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500195 * (nothing) == PNG_USE_DLL
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500196 *
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500197 * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500198 * of auto-import in binutils, we no longer need to worry about
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500199 * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore,
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500200 * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500201 * to __declspec() stuff. However, we DO need to worry about
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500202 * PNG_BUILD_DLL and PNG_STATIC because those change some defaults
203 * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500204 */
205#if defined(__CYGWIN__)
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500206# if defined(ALL_STATIC)
207# if defined(PNG_BUILD_DLL)
208# undef PNG_BUILD_DLL
209# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500210# if defined(PNG_USE_DLL)
211# undef PNG_USE_DLL
212# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500213# if defined(PNG_DLL)
214# undef PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500215# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500216# if !defined(PNG_STATIC)
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -0600217# define PNG_STATIC
218# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500219# else
220# if defined (PNG_BUILD_DLL)
221# if defined(PNG_STATIC)
222# undef PNG_STATIC
223# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500224# if defined(PNG_USE_DLL)
225# undef PNG_USE_DLL
226# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500227# if !defined(PNG_DLL)
228# define PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500229# endif
230# else
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500231# if defined(PNG_STATIC)
232# if defined(PNG_USE_DLL)
233# undef PNG_USE_DLL
234# endif
235# if defined(PNG_DLL)
236# undef PNG_DLL
237# endif
238# else
239# if !defined(PNG_USE_DLL)
240# define PNG_USE_DLL
241# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500242# if !defined(PNG_DLL)
243# define PNG_DLL
244# endif
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500245# endif
246# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500247# endif
248#endif
249
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500250/* This protects us against compilers that run on a windowing system
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600251 * and thus don't have or would rather us not use the stdio types:
252 * stdin, stdout, and stderr. The only one currently used is stderr
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600253 * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will
254 * prevent these from being compiled and used. #defining PNG_NO_STDIO
255 * will also prevent these, plus will prevent the entire set of stdio
256 * macros and functions (FILE *, printf, etc.) from being compiled and used,
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500257 * unless (PNG_DEBUG > 0) has been #defined.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600258 *
259 * #define PNG_NO_CONSOLE_IO
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600260 * #define PNG_NO_STDIO
261 */
Guy Schalnat6d764711995-12-19 03:22:19 -0600262
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500263#if !defined(PNG_NO_STDIO) && !defined(PNG_STDIO_SUPPORTED)
264# define PNG_STDIO_SUPPORTED
265#endif
266
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500267#if defined(_WIN32_WCE)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600268# include <windows.h>
269 /* Console I/O functions are not supported on WindowsCE */
270# define PNG_NO_CONSOLE_IO
271# ifdef PNG_DEBUG
272# undef PNG_DEBUG
273# endif
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500274#endif
275
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -0500276#ifdef PNG_BUILD_DLL
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500277# if !defined(PNG_CONSOLE_IO_SUPPORTED) && !defined(PNG_NO_CONSOLE_IO)
278# define PNG_NO_CONSOLE_IO
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -0500279# endif
280#endif
281
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600282# ifdef PNG_NO_STDIO
283# ifndef PNG_NO_CONSOLE_IO
284# define PNG_NO_CONSOLE_IO
285# endif
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500286# ifdef PNG_DEBUG
287# if (PNG_DEBUG > 0)
288# include <stdio.h>
289# endif
290# endif
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600291# else
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500292# include <stdio.h>
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600293# endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600294
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500295#if !(defined PNG_NO_CONSOLE_IO) && !defined(PNG_CONSOLE_IO_SUPPORTED)
296# define PNG_CONSOLE_IO_SUPPORTED
297#endif
298
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600299/* This macro protects us against machines that don't have function
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600300 * prototypes (ie K&R style headers). If your compiler does not handle
301 * function prototypes, define this macro and use the included ansi2knr.
302 * I've always been able to use _NO_PROTO as the indicator, but you may
303 * need to drag the empty declaration out in front of here, or change the
304 * ifdef to suit your own needs.
305 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500306#ifndef PNGARG
307
Andreas Dilger47a0c421997-05-16 02:46:07 -0500308#ifdef OF /* zlib prototype munger */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600309# define PNGARG(arglist) OF(arglist)
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500310#else
311
312#ifdef _NO_PROTO
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600313# define PNGARG(arglist) ()
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500314#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600315# define PNGARG(arglist) arglist
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500316#endif /* _NO_PROTO */
317
318#endif /* OF */
319
320#endif /* PNGARG */
321
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600322/* Try to determine if we are compiling on a Mac. Note that testing for
323 * just __MWERKS__ is not good enough, because the Codewarrior is now used
324 * on non-Mac platforms.
325 */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600326#ifndef MACOS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600327# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
328 defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
329# define MACOS
330# endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600331#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600332
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500333/* Enough people need this for various reasons to include it here */
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500334#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600335# include <sys/types.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500336#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600337
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500338/* PNG_SETJMP_NOT_SUPPORTED and PNG_NO_SETJMP_SUPPORTED are deprecated. */
339#if !defined(PNG_NO_SETJMP) && \
340 !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600341# define PNG_SETJMP_SUPPORTED
342#endif
343
344#ifdef PNG_SETJMP_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -0500345/* This is an attempt to force a single setjmp behaviour on Linux. If
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600346 * the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
Glenn Randers-Pehrsona93c9422009-04-13 11:41:33 -0500347 *
348 * You can bypass this test if you know that your application uses exactly
349 * the same setjmp.h that was included when libpng was built. Only define
350 * PNG_SKIP_SETJMP_CHECK while building your application, prior to the
351 * application's '#include "png.h"'. Don't define PNG_SKIP_SETJMP_CHECK
352 * while building a separate libpng library for general use.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600353 */
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500354
Glenn Randers-Pehrsona93c9422009-04-13 11:41:33 -0500355# ifndef PNG_SKIP_SETJMP_CHECK
356# ifdef __linux__
357# ifdef _BSD_SOURCE
358# define PNG_SAVE_BSD_SOURCE
359# undef _BSD_SOURCE
360# endif
361# ifdef _SETJMP_H
362 /* If you encounter a compiler error here, see the explanation
363 * near the end of INSTALL.
364 */
365 __pngconf.h__ in libpng already includes setjmp.h;
366 __dont__ include it again.;
367# endif
368# endif /* __linux__ */
369# endif /* PNG_SKIP_SETJMP_CHECK */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500370
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500371 /* Include setjmp.h for error handling */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600372# include <setjmp.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500373
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600374# ifdef __linux__
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500375# ifdef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson56f63962008-10-06 10:16:17 -0500376# ifdef _BSD_SOURCE
377# undef _BSD_SOURCE
378# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600379# define _BSD_SOURCE
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500380# undef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600381# endif
382# endif /* __linux__ */
383#endif /* PNG_SETJMP_SUPPORTED */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600384
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500385#ifdef BSD
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600386# include <strings.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500387#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600388# include <string.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500389#endif
390
Andreas Dilger47a0c421997-05-16 02:46:07 -0500391/* Other defines for things like memory and the like can go here. */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500392
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500393/* This controls how fine the dithering gets. As this allocates
394 * a largish chunk of memory (32K), those who are not as concerned
395 * with dithering quality can decrease some or all of these.
396 */
397#ifndef PNG_DITHER_RED_BITS
398# define PNG_DITHER_RED_BITS 5
399#endif
400#ifndef PNG_DITHER_GREEN_BITS
401# define PNG_DITHER_GREEN_BITS 5
402#endif
403#ifndef PNG_DITHER_BLUE_BITS
404# define PNG_DITHER_BLUE_BITS 5
405#endif
406
407/* This controls how fine the gamma correction becomes when you
408 * are only interested in 8 bits anyway. Increasing this value
409 * results in more memory being used, and more pow() functions
410 * being called to fill in the gamma tables. Don't set this value
411 * less then 8, and even that may not work (I haven't tested it).
412 */
413
414#ifndef PNG_MAX_GAMMA_8
415# define PNG_MAX_GAMMA_8 11
416#endif
417
418/* This controls how much a difference in gamma we can tolerate before
419 * we actually start doing gamma conversion.
420 */
421#ifndef PNG_GAMMA_THRESHOLD
422# define PNG_GAMMA_THRESHOLD 0.05
423#endif
424
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600425/* The following uses const char * instead of char * for error
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600426 * and warning message functions, so some compilers won't complain.
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600427 * If you do not want to use const, define PNG_NO_CONST here.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600428 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600429
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600430#ifndef PNG_NO_CONST
Guy Schalnat6d764711995-12-19 03:22:19 -0600431# define PNG_CONST const
432#else
433# define PNG_CONST
434#endif
435
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600436/* The following defines give you the ability to remove code from the
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600437 * library that you will not be using. I wish I could figure out how to
438 * automate this, but I can't do that without making it seriously hard
439 * on the users. So if you are not using an ability, change the #define
440 * to and #undef, and that part of the library will not be compiled. If
441 * your linker can't find a function, you may want to make sure the
442 * ability is defined here. Some of these depend upon some others being
443 * defined. I haven't figured out all the interactions here, so you may
444 * have to experiment awhile to get everything to compile. If you are
445 * creating or using a shared library, you probably shouldn't touch this,
446 * as it will affect the size of the structures, and this will cause bad
447 * things to happen if the library and/or application ever change.
448 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500449
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500450/* Any features you will not be using can be undef'ed here */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600451
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600452/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500453 * to turn it off with PNG_NO_READ|WRITE_TRANSFORMS on the compile line,
454 * then pick and choose which ones to define without having to edit this
455 * file. It is safe to use the PNG_NO_READ|WRITE_TRANSFORMS
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500456 * if you only want to have a png-compliant reader/writer but don't need
457 * any of the extra transformations. This saves about 80 kbytes in a
458 * typical installation of the library. (PNG_NO_* form added in version
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500459 * 1.0.1c, for consistency; PNG_*_TRANSFORMS_NOT_SUPPORTED deprecated in
460 * 1.4.0)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600461 */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600462
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500463/* Ignore attempt to turn off both floating and fixed point support */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500464#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600465 !defined(PNG_NO_FIXED_POINT_SUPPORTED)
466# define PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500467#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600468
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500469#ifndef PNG_NO_FREE_ME
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600470# define PNG_FREE_ME_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500471#endif
472
Glenn Randers-Pehrson3b3e0902009-06-16 17:20:43 -0500473#ifdef PNG_READ_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600474
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500475/* PNG_READ_TRANSFORMS_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500476#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600477 !defined(PNG_NO_READ_TRANSFORMS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600478# define PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600479#endif
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600480
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600481#ifdef PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600482# ifndef PNG_NO_READ_EXPAND
483# define PNG_READ_EXPAND_SUPPORTED
484# endif
485# ifndef PNG_NO_READ_SHIFT
486# define PNG_READ_SHIFT_SUPPORTED
487# endif
488# ifndef PNG_NO_READ_PACK
489# define PNG_READ_PACK_SUPPORTED
490# endif
491# ifndef PNG_NO_READ_BGR
492# define PNG_READ_BGR_SUPPORTED
493# endif
494# ifndef PNG_NO_READ_SWAP
495# define PNG_READ_SWAP_SUPPORTED
496# endif
497# ifndef PNG_NO_READ_PACKSWAP
498# define PNG_READ_PACKSWAP_SUPPORTED
499# endif
500# ifndef PNG_NO_READ_INVERT
501# define PNG_READ_INVERT_SUPPORTED
502# endif
Glenn Randers-Pehrson4a82d692008-12-15 16:25:05 -0600503#if 0 /* removed from libpng-1.4.0 */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600504# ifndef PNG_NO_READ_DITHER
505# define PNG_READ_DITHER_SUPPORTED
506# endif
Glenn Randers-Pehrson4a82d692008-12-15 16:25:05 -0600507#endif /* 0 */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600508# ifndef PNG_NO_READ_BACKGROUND
509# define PNG_READ_BACKGROUND_SUPPORTED
510# endif
511# ifndef PNG_NO_READ_16_TO_8
512# define PNG_READ_16_TO_8_SUPPORTED
513# endif
514# ifndef PNG_NO_READ_FILLER
515# define PNG_READ_FILLER_SUPPORTED
516# endif
517# ifndef PNG_NO_READ_GAMMA
518# define PNG_READ_GAMMA_SUPPORTED
519# endif
520# ifndef PNG_NO_READ_GRAY_TO_RGB
521# define PNG_READ_GRAY_TO_RGB_SUPPORTED
522# endif
523# ifndef PNG_NO_READ_SWAP_ALPHA
524# define PNG_READ_SWAP_ALPHA_SUPPORTED
525# endif
526# ifndef PNG_NO_READ_INVERT_ALPHA
527# define PNG_READ_INVERT_ALPHA_SUPPORTED
528# endif
Glenn Randers-Pehrson1916f6a2008-08-14 13:44:49 -0500529# ifndef PNG_NO_READ_PREMULTIPLY_ALPHA
530# define PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
531# endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600532# ifndef PNG_NO_READ_STRIP_ALPHA
533# define PNG_READ_STRIP_ALPHA_SUPPORTED
534# endif
535# ifndef PNG_NO_READ_USER_TRANSFORM
536# define PNG_READ_USER_TRANSFORM_SUPPORTED
537# endif
538# ifndef PNG_NO_READ_RGB_TO_GRAY
539# define PNG_READ_RGB_TO_GRAY_SUPPORTED
540# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600541#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600542
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500543/* PNG_PROGRESSIVE_READ_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500544#if !defined(PNG_NO_PROGRESSIVE_READ) && \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600545 !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
546# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600547#endif /* about interlacing capability! You'll */
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500548 /* still have interlacing unless you change the following define: */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600549
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600550#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500551
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500552/* PNG_NO_SEQUENTIAL_READ_SUPPORTED is deprecated. */
553#if !defined(PNG_NO_SEQUENTIAL_READ) && \
554 !defined(PNG_SEQUENTIAL_READ_SUPPORTED) && \
555 !defined(PNG_NO_SEQUENTIAL_READ_SUPPORTED)
556# define PNG_SEQUENTIAL_READ_SUPPORTED
557#endif
558
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500559#ifndef PNG_NO_READ_COMPOSITE_NODIV
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600560# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
561# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
562# endif
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500563#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500564
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500565#if !defined(PNG_NO_GET_INT_32) || defined(PNG_READ_oFFS_SUPPORTED) || \
566 defined(PNG_READ_pCAL_SUPPORTED)
567# ifndef PNG_GET_INT_32_SUPPORTED
568# define PNG_GET_INT_32_SUPPORTED
569# endif
570#endif
571
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600572#endif /* PNG_READ_SUPPORTED */
573
Glenn Randers-Pehrson3b3e0902009-06-16 17:20:43 -0500574#ifdef PNG_WRITE_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600575
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500576/* PNG_WRITE_TRANSFORMS_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600577# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
578 !defined(PNG_NO_WRITE_TRANSFORMS)
579# define PNG_WRITE_TRANSFORMS_SUPPORTED
580#endif
581
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600582#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600583# ifndef PNG_NO_WRITE_SHIFT
584# define PNG_WRITE_SHIFT_SUPPORTED
585# endif
586# ifndef PNG_NO_WRITE_PACK
587# define PNG_WRITE_PACK_SUPPORTED
588# endif
589# ifndef PNG_NO_WRITE_BGR
590# define PNG_WRITE_BGR_SUPPORTED
591# endif
592# ifndef PNG_NO_WRITE_SWAP
593# define PNG_WRITE_SWAP_SUPPORTED
594# endif
595# ifndef PNG_NO_WRITE_PACKSWAP
596# define PNG_WRITE_PACKSWAP_SUPPORTED
597# endif
598# ifndef PNG_NO_WRITE_INVERT
599# define PNG_WRITE_INVERT_SUPPORTED
600# endif
601# ifndef PNG_NO_WRITE_FILLER
602# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */
603# endif
604# ifndef PNG_NO_WRITE_SWAP_ALPHA
605# define PNG_WRITE_SWAP_ALPHA_SUPPORTED
606# endif
607# ifndef PNG_NO_WRITE_INVERT_ALPHA
608# define PNG_WRITE_INVERT_ALPHA_SUPPORTED
609# endif
610# ifndef PNG_NO_WRITE_USER_TRANSFORM
611# define PNG_WRITE_USER_TRANSFORM_SUPPORTED
612# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600613#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600614
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600615#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \
616 !defined(PNG_WRITE_INTERLACING_SUPPORTED)
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600617#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
618 encoders, but can cause trouble
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600619 if left undefined */
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600620#endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600621
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500622#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -0600623 !defined(PNG_WRITE_WEIGHTED_FILTER) && \
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500624 defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600625# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500626#endif
627
628#ifndef PNG_NO_WRITE_FLUSH
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600629# define PNG_WRITE_FLUSH_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500630#endif
631
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500632#if !defined(PNG_NO_SAVE_INT_32) || defined(PNG_WRITE_oFFS_SUPPORTED) || \
633 defined(PNG_WRITE_pCAL_SUPPORTED)
634# ifndef PNG_SAVE_INT_32_SUPPORTED
635# define PNG_SAVE_INT_32_SUPPORTED
636# endif
637#endif
638
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600639#endif /* PNG_WRITE_SUPPORTED */
640
Glenn Randers-Pehrson895a9c92008-07-25 08:51:18 -0500641#define PNG_NO_ERROR_NUMBERS
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500642
643#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
644 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
645# ifndef PNG_NO_USER_TRANSFORM_PTR
646# define PNG_USER_TRANSFORM_PTR_SUPPORTED
647# endif
648#endif
649
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500650#if defined(PNG_STDIO_SUPPORTED) && !defined(PNG_TIME_RFC1123_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600651# define PNG_TIME_RFC1123_SUPPORTED
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600652#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500653
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600654/* This adds extra functions in pngget.c for accessing data from the
655 * info pointer (added in version 0.99)
656 * png_get_image_width()
657 * png_get_image_height()
658 * png_get_bit_depth()
659 * png_get_color_type()
660 * png_get_compression_type()
661 * png_get_filter_type()
662 * png_get_interlace_type()
663 * png_get_pixel_aspect_ratio()
664 * png_get_pixels_per_meter()
665 * png_get_x_offset_pixels()
666 * png_get_y_offset_pixels()
667 * png_get_x_offset_microns()
668 * png_get_y_offset_microns()
669 */
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500670#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600671# define PNG_EASY_ACCESS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600672#endif
673
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500674#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
675# define PNG_USER_MEM_SUPPORTED
676#endif
677
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500678/* Added at libpng-1.2.6 */
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500679#ifndef PNG_SET_USER_LIMITS_SUPPORTED
680#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED)
681# define PNG_SET_USER_LIMITS_SUPPORTED
682#endif
683#endif
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500684
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500685/* 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 -0500686 * how large, set these limits to 0x7fffffffL
687 */
688#ifndef PNG_USER_WIDTH_MAX
689# define PNG_USER_WIDTH_MAX 1000000L
690#endif
691#ifndef PNG_USER_HEIGHT_MAX
692# define PNG_USER_HEIGHT_MAX 1000000L
693#endif
694
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500695/* Added at libpng-1.4.0 */
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -0500696#ifndef PNG_USER_CHUNK_CACHE_MAX
697# define PNG_USER_CHUNK_CACHE_MAX 0x7ffffffLL
698#endif
699
700/* Added at libpng-1.4.0 */
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500701#if !defined(PNG_NO_IO_STATE) && !defined(PNG_IO_STATE_SUPPORTED)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500702# define PNG_IO_STATE_SUPPORTED
703#endif
704
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500705#ifndef PNG_LITERAL_SHARP
706# define PNG_LITERAL_SHARP 0x23
707#endif
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500708#ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500709# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500710#endif
711#ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500712# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500713#endif
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500714#ifndef PNG_STRING_NEWLINE
Glenn Randers-Pehrsone0784c72008-08-09 07:11:44 -0500715#define PNG_STRING_NEWLINE "\n"
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500716#endif
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500717
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600718/* These are currently experimental features, define them if you want */
719
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500720/* Very little testing */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600721/*
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600722#ifdef PNG_READ_SUPPORTED
723# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
724# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
725# endif
726#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600727*/
Andreas Dilger47a0c421997-05-16 02:46:07 -0500728
729/* This is only for PowerPC big-endian and 680x0 systems */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600730/* some testing */
731/*
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500732#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
733# define PNG_READ_BIG_ENDIAN_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600734#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600735*/
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500736
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500737#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
738# define PNG_USE_READ_MACROS
739#endif
740
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500741/* Buggy compilers (e.g., gcc 2.7.2.2) need PNG_NO_POINTER_INDEXING */
742
743#if !defined(PNG_NO_POINTER_INDEXING) && \
744 !defined(PNG_POINTER_INDEXING_SUPPORTED)
745# define PNG_POINTER_INDEXING_SUPPORTED
746#endif
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -0500747
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600748
Andreas Dilger47a0c421997-05-16 02:46:07 -0500749/* Any chunks you are not interested in, you can undef here. The
750 * ones that allocate memory may be expecially important (hIST,
751 * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600752 * a bit smaller.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500753 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500754
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500755/* The size of the png_text structure changed in libpng-1.0.6 when
756 * iTXt support was added. iTXt support was turned off by default through
757 * libpng-1.2.x, to support old apps that malloc the png_text structure
758 * instead of calling png_set_text() and letting libpng malloc it. It
759 * was turned on by default in libpng-1.4.0.
760 */
761
762/* PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600763#if defined(PNG_READ_SUPPORTED) && \
764 !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500765 !defined(PNG_NO_READ_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600766# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600767#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600768
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500769/* PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600770#if defined(PNG_WRITE_SUPPORTED) && \
771 !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500772 !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600773# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600774#endif
775
776#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600777
778#ifdef PNG_NO_READ_TEXT
779# define PNG_NO_READ_iTXt
780# define PNG_NO_READ_tEXt
781# define PNG_NO_READ_zTXt
782#endif
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500783
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500784#ifndef PNG_NO_READ_bKGD
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600785# define PNG_READ_bKGD_SUPPORTED
786# define PNG_bKGD_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500787#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500788#ifndef PNG_NO_READ_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600789# define PNG_READ_cHRM_SUPPORTED
790# define PNG_cHRM_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500791#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500792#ifndef PNG_NO_READ_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600793# define PNG_READ_gAMA_SUPPORTED
794# define PNG_gAMA_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500795#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500796#ifndef PNG_NO_READ_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600797# define PNG_READ_hIST_SUPPORTED
798# define PNG_hIST_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600799#endif
800#ifndef PNG_NO_READ_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600801# define PNG_READ_iCCP_SUPPORTED
802# define PNG_iCCP_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600803#endif
804#ifndef PNG_NO_READ_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500805# ifndef PNG_READ_iTXt_SUPPORTED
806# define PNG_READ_iTXt_SUPPORTED
807# endif
808# ifndef PNG_iTXt_SUPPORTED
809# define PNG_iTXt_SUPPORTED
810# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500811#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500812#ifndef PNG_NO_READ_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600813# define PNG_READ_oFFs_SUPPORTED
814# define PNG_oFFs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500815#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500816#ifndef PNG_NO_READ_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600817# define PNG_READ_pCAL_SUPPORTED
818# define PNG_pCAL_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600819#endif
820#ifndef PNG_NO_READ_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600821# define PNG_READ_sCAL_SUPPORTED
822# define PNG_sCAL_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500823#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500824#ifndef PNG_NO_READ_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600825# define PNG_READ_pHYs_SUPPORTED
826# define PNG_pHYs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500827#endif
828#ifndef PNG_NO_READ_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600829# define PNG_READ_sBIT_SUPPORTED
830# define PNG_sBIT_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600831#endif
832#ifndef PNG_NO_READ_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600833# define PNG_READ_sPLT_SUPPORTED
834# define PNG_sPLT_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500835#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500836#ifndef PNG_NO_READ_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600837# define PNG_READ_sRGB_SUPPORTED
838# define PNG_sRGB_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500839#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500840#ifndef PNG_NO_READ_tEXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600841# define PNG_READ_tEXt_SUPPORTED
842# define PNG_tEXt_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500843#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500844#ifndef PNG_NO_READ_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600845# define PNG_READ_tIME_SUPPORTED
846# define PNG_tIME_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500847#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500848#ifndef PNG_NO_READ_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600849# define PNG_READ_tRNS_SUPPORTED
850# define PNG_tRNS_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500851#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500852#ifndef PNG_NO_READ_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600853# define PNG_READ_zTXt_SUPPORTED
854# define PNG_zTXt_SUPPORTED
855#endif
Glenn Randers-Pehrson658ea432009-06-16 16:24:57 -0500856#ifndef PNG_NO_READ_OPT_PLTE
857# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
858#endif /* optional PLTE chunk in RGB and RGBA images */
859#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
860 defined(PNG_READ_zTXt_SUPPORTED)
861# define PNG_READ_TEXT_SUPPORTED
862# define PNG_TEXT_SUPPORTED
863#endif
864
865#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
866
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500867#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
868# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500869# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
870# define PNG_UNKNOWN_CHUNKS_SUPPORTED
871# endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500872#endif
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -0500873#if !defined(PNG_NO_READ_USER_CHUNKS) && \
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500874 defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600875# define PNG_READ_USER_CHUNKS_SUPPORTED
876# define PNG_USER_CHUNKS_SUPPORTED
877# ifdef PNG_NO_READ_UNKNOWN_CHUNKS
878# undef PNG_NO_READ_UNKNOWN_CHUNKS
879# endif
880# ifdef PNG_NO_HANDLE_AS_UNKNOWN
881# undef PNG_NO_HANDLE_AS_UNKNOWN
882# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600883#endif
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500884#ifndef PNG_NO_HANDLE_AS_UNKNOWN
885# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
886# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
887# endif
888#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500889
Glenn Randers-Pehrson3b3e0902009-06-16 17:20:43 -0500890#ifdef PNG_WRITE_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600891#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600892
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600893#ifdef PNG_NO_WRITE_TEXT
894# define PNG_NO_WRITE_iTXt
895# define PNG_NO_WRITE_tEXt
896# define PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600897#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600898#ifndef PNG_NO_WRITE_bKGD
899# define PNG_WRITE_bKGD_SUPPORTED
900# ifndef PNG_bKGD_SUPPORTED
901# define PNG_bKGD_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_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600905# define PNG_WRITE_cHRM_SUPPORTED
906# ifndef PNG_cHRM_SUPPORTED
907# define PNG_cHRM_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_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600911# define PNG_WRITE_gAMA_SUPPORTED
912# ifndef PNG_gAMA_SUPPORTED
913# define PNG_gAMA_SUPPORTED
914# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500915#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500916#ifndef PNG_NO_WRITE_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600917# define PNG_WRITE_hIST_SUPPORTED
918# ifndef PNG_hIST_SUPPORTED
919# define PNG_hIST_SUPPORTED
920# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600921#endif
922#ifndef PNG_NO_WRITE_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600923# define PNG_WRITE_iCCP_SUPPORTED
924# ifndef PNG_iCCP_SUPPORTED
925# define PNG_iCCP_SUPPORTED
926# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600927#endif
928#ifndef PNG_NO_WRITE_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500929# ifndef PNG_WRITE_iTXt_SUPPORTED
930# define PNG_WRITE_iTXt_SUPPORTED
931# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600932# ifndef PNG_iTXt_SUPPORTED
933# define PNG_iTXt_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_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600937# define PNG_WRITE_oFFs_SUPPORTED
938# ifndef PNG_oFFs_SUPPORTED
939# define PNG_oFFs_SUPPORTED
940# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500941#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500942#ifndef PNG_NO_WRITE_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600943# define PNG_WRITE_pCAL_SUPPORTED
944# ifndef PNG_pCAL_SUPPORTED
945# define PNG_pCAL_SUPPORTED
946# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600947#endif
948#ifndef PNG_NO_WRITE_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600949# define PNG_WRITE_sCAL_SUPPORTED
950# ifndef PNG_sCAL_SUPPORTED
951# define PNG_sCAL_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_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600955# define PNG_WRITE_pHYs_SUPPORTED
956# ifndef PNG_pHYs_SUPPORTED
957# define PNG_pHYs_SUPPORTED
958# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500959#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500960#ifndef PNG_NO_WRITE_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600961# define PNG_WRITE_sBIT_SUPPORTED
962# ifndef PNG_sBIT_SUPPORTED
963# define PNG_sBIT_SUPPORTED
964# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600965#endif
966#ifndef PNG_NO_WRITE_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600967# define PNG_WRITE_sPLT_SUPPORTED
968# ifndef PNG_sPLT_SUPPORTED
969# define PNG_sPLT_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_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600973# define PNG_WRITE_sRGB_SUPPORTED
974# ifndef PNG_sRGB_SUPPORTED
975# define PNG_sRGB_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_tEXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600979# define PNG_WRITE_tEXt_SUPPORTED
980# ifndef PNG_tEXt_SUPPORTED
981# define PNG_tEXt_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_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600985# define PNG_WRITE_tIME_SUPPORTED
986# ifndef PNG_tIME_SUPPORTED
987# define PNG_tIME_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_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600991# define PNG_WRITE_tRNS_SUPPORTED
992# ifndef PNG_tRNS_SUPPORTED
993# define PNG_tRNS_SUPPORTED
994# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500995#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500996#ifndef PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600997# define PNG_WRITE_zTXt_SUPPORTED
998# ifndef PNG_zTXt_SUPPORTED
999# define PNG_zTXt_SUPPORTED
1000# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001001#endif
Glenn Randers-Pehrson658ea432009-06-16 16:24:57 -05001002#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
1003 defined(PNG_WRITE_zTXt_SUPPORTED)
1004# define PNG_WRITE_TEXT_SUPPORTED
1005# ifndef PNG_TEXT_SUPPORTED
1006# define PNG_TEXT_SUPPORTED
1007# endif
1008#endif
1009
1010#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
1011
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -05001012#if !defined(PNG_NO_WRITE_FILTER) && !defined(PNG_WRITE_FILTER_SUPPORTED)
1013# define PNG_WRITE_FILTER_SUPPORTED
1014#endif
1015
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001016#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001017# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
1018# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
1019# define PNG_UNKNOWN_CHUNKS_SUPPORTED
1020# endif
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -05001021#endif
1022#ifndef PNG_NO_HANDLE_AS_UNKNOWN
1023# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
1024# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001025# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001026#endif
Glenn Randers-Pehrson3b3e0902009-06-16 17:20:43 -05001027#endif /* PNG_WRITE_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001028
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001029/* Turn this off to disable png_read_png() and
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001030 * png_write_png() and leave the row_pointers member
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001031 * out of the info structure.
1032 */
1033#ifndef PNG_NO_INFO_IMAGE
1034# define PNG_INFO_IMAGE_SUPPORTED
1035#endif
1036
Andreas Dilger47a0c421997-05-16 02:46:07 -05001037/* need the time information for reading tIME chunks */
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001038#if defined(PNG_tIME_SUPPORTED)
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -05001039# if !defined(_WIN32_WCE)
1040 /* "time.h" functions are not supported on WindowsCE */
1041# include <time.h>
1042# endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001043#endif
1044
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001045/* Some typedefs to get us started. These should be safe on most of the
Andreas Dilger47a0c421997-05-16 02:46:07 -05001046 * common platforms. The typedefs should be at least as large as the
1047 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
1048 * don't have to be exactly that size. Some compilers dislike passing
1049 * unsigned shorts as function parameters, so you may be better off using
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001050 * unsigned int for png_uint_16.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001051 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001052
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05001053#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
1054typedef unsigned int png_uint_32;
1055typedef int png_int_32;
1056#else
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001057typedef unsigned long png_uint_32;
1058typedef long png_int_32;
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05001059#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001060typedef unsigned short png_uint_16;
1061typedef short png_int_16;
1062typedef unsigned char png_byte;
1063
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001064#ifdef PNG_NO_SIZE_T
1065 typedef unsigned int png_size_t;
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05001066#else
1067 typedef size_t png_size_t;
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05001068#endif
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001069#define png_sizeof(x) sizeof(x)
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001070
Andreas Dilger47a0c421997-05-16 02:46:07 -05001071/* The following is needed for medium model support. It cannot be in the
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05001072 * pngpriv.h header. Needs modification for other compilers besides
Andreas Dilger47a0c421997-05-16 02:46:07 -05001073 * MSC. Model independent support declares all arrays and pointers to be
1074 * large using the far keyword. The zlib version used must also support
1075 * model independent data. As of version zlib 1.0.4, the necessary changes
1076 * have been made in zlib. The USE_FAR_KEYWORD define triggers other
1077 * changes that are needed. (Tim Wegner)
1078 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001079
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001080/* Separate compiler dependencies (problem here is that zlib.h always
1081 defines FAR. (SJT) */
Guy Schalnat6d764711995-12-19 03:22:19 -06001082#ifdef __BORLANDC__
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001083# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
1084# define LDATA 1
1085# else
1086# define LDATA 0
1087# endif
1088 /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
1089# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
1090# define PNG_MAX_MALLOC_64K
1091# if (LDATA != 1)
1092# ifndef FAR
1093# define FAR __far
1094# endif
1095# define USE_FAR_KEYWORD
1096# endif /* LDATA != 1 */
1097 /* Possibly useful for moving data out of default segment.
1098 * Uncomment it if you want. Could also define FARDATA as
1099 * const if your compiler supports it. (SJT)
1100# define FARDATA FAR
1101 */
1102# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
Guy Schalnatb2e01bd1996-01-26 01:38:47 -06001103#endif /* __BORLANDC__ */
Guy Schalnat6d764711995-12-19 03:22:19 -06001104
1105
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001106/* Suggest testing for specific compiler first before testing for
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001107 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
1108 * making reliance oncertain keywords suspect. (SJT)
1109 */
Guy Schalnat6d764711995-12-19 03:22:19 -06001110
1111/* MSC Medium model */
1112#if defined(FAR)
1113# if defined(M_I86MM)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001114# define USE_FAR_KEYWORD
1115# define FARDATA FAR
1116# include <dos.h>
Guy Schalnat6d764711995-12-19 03:22:19 -06001117# endif
1118#endif
1119
1120/* SJT: default case */
1121#ifndef FAR
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001122# define FAR
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001123#endif
1124
Andreas Dilger47a0c421997-05-16 02:46:07 -05001125/* At this point FAR is always defined */
Guy Schalnat6d764711995-12-19 03:22:19 -06001126#ifndef FARDATA
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001127# define FARDATA
Guy Schalnat6d764711995-12-19 03:22:19 -06001128#endif
1129
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001130/* Typedef for floating-point numbers that are converted
1131 to fixed-point with a multiple of 100,000, e.g., int_gamma */
1132typedef png_int_32 png_fixed_point;
1133
Andreas Dilger47a0c421997-05-16 02:46:07 -05001134/* Add typedefs for pointers */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001135typedef void FAR * png_voidp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001136typedef png_byte FAR * png_bytep;
1137typedef png_uint_32 FAR * png_uint_32p;
1138typedef png_int_32 FAR * png_int_32p;
1139typedef png_uint_16 FAR * png_uint_16p;
1140typedef png_int_16 FAR * png_int_16p;
1141typedef PNG_CONST char FAR * png_const_charp;
1142typedef char FAR * png_charp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001143typedef png_fixed_point FAR * png_fixed_point_p;
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001144
1145#ifndef PNG_NO_STDIO
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -05001146#if defined(_WIN32_WCE)
1147typedef HANDLE png_FILE_p;
1148#else
1149typedef FILE * png_FILE_p;
1150#endif
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001151#endif
1152
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001153#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001154typedef double FAR * png_doublep;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001155#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001156
Andreas Dilger47a0c421997-05-16 02:46:07 -05001157/* Pointers to pointers; i.e. arrays */
Guy Schalnat6d764711995-12-19 03:22:19 -06001158typedef png_byte FAR * FAR * png_bytepp;
1159typedef png_uint_32 FAR * FAR * png_uint_32pp;
1160typedef png_int_32 FAR * FAR * png_int_32pp;
1161typedef png_uint_16 FAR * FAR * png_uint_16pp;
1162typedef png_int_16 FAR * FAR * png_int_16pp;
1163typedef PNG_CONST char FAR * FAR * png_const_charpp;
1164typedef char FAR * FAR * png_charpp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001165typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001166#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001167typedef double FAR * FAR * png_doublepp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001168#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001169
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001170/* Pointers to pointers to pointers; i.e., pointer to array */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001171typedef char FAR * FAR * FAR * png_charppp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001172
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001173/*
1174 * Define PNG_BUILD_DLL if the module being built is a Windows
1175 * LIBPNG DLL.
1176 *
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001177 * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL.
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -06001178 * It is equivalent to Microsoft predefined macro _DLL that is
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001179 * automatically defined when you compile using the share
1180 * version of the CRT (C Run-Time library)
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001181 *
1182 * The cygwin mods make this behavior a little different:
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001183 * Define PNG_BUILD_DLL if you are building a dll for use with cygwin
1184 * Define PNG_STATIC if you are building a static library for use with cygwin,
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001185 * -or- if you are building an application that you want to link to the
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001186 * static library.
1187 * PNG_USE_DLL is defined by default (no user action needed) unless one of
1188 * the other flags is defined.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001189 */
1190
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001191#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001192# define PNG_DLL
1193#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001194/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib.
1195 * When building a static lib, default to no GLOBAL ARRAYS, but allow
1196 * command-line override
1197 */
1198#if defined(__CYGWIN__)
1199# if !defined(PNG_STATIC)
1200# if defined(PNG_USE_GLOBAL_ARRAYS)
1201# undef PNG_USE_GLOBAL_ARRAYS
1202# endif
1203# if !defined(PNG_USE_LOCAL_ARRAYS)
1204# define PNG_USE_LOCAL_ARRAYS
1205# endif
1206# else
1207# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS)
1208# if defined(PNG_USE_GLOBAL_ARRAYS)
1209# undef PNG_USE_GLOBAL_ARRAYS
1210# endif
1211# endif
1212# endif
1213# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
1214# define PNG_USE_LOCAL_ARRAYS
1215# endif
1216#endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001217
Glenn Randers-Pehrsonec61c232000-05-16 06:17:36 -05001218/* Do not use global arrays (helps with building DLL's)
1219 * They are no longer used in libpng itself, since version 1.0.5c,
1220 * but might be required for some pre-1.0.5c applications.
1221 */
1222#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
1223# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL))
1224# define PNG_USE_LOCAL_ARRAYS
1225# else
1226# define PNG_USE_GLOBAL_ARRAYS
1227# endif
1228#endif
1229
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001230#if defined(__CYGWIN__)
1231# undef PNGAPI
1232# define PNGAPI __cdecl
1233# undef PNG_IMPEXP
1234# define PNG_IMPEXP
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -05001235#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001236
Glenn Randers-Pehrson25d82242002-05-01 11:51:26 -05001237/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
1238 * you may get warnings regarding the linkage of png_zalloc and png_zfree.
1239 * Don't ignore those warnings; you must also reset the default calling
1240 * convention in your compiler to match your PNGAPI, and you must build
1241 * zlib and your applications the same way you build libpng.
1242 */
1243
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001244#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001245# ifndef PNG_NO_MODULEDEF
1246# define PNG_NO_MODULEDEF
1247# endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001248#endif
1249
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001250#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001251# define PNG_IMPEXP
1252#endif
1253
1254#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001255 (( defined(_Windows) || defined(_WINDOWS) || \
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -05001256 defined(WIN32) || defined(_WIN32) || defined(__WIN32__) ))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001257
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001258# ifndef PNGAPI
1259# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
1260# define PNGAPI __cdecl
1261# else
1262# define PNGAPI _cdecl
1263# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001264# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001265
1266# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \
1267 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */)
1268# define PNG_IMPEXP
1269# endif
1270
1271# if !defined(PNG_IMPEXP)
1272
1273# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol
1274# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol
1275
1276 /* Borland/Microsoft */
1277# if defined(_MSC_VER) || defined(__BORLANDC__)
1278# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
1279# define PNG_EXPORT PNG_EXPORT_TYPE1
1280# else
1281# define PNG_EXPORT PNG_EXPORT_TYPE2
1282# if defined(PNG_BUILD_DLL)
1283# define PNG_IMPEXP __export
1284# else
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -05001285# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in
1286 VC++ */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001287# endif /* Exists in Borland C++ for
1288 C++ classes (== huge) */
1289# endif
1290# endif
1291
1292# if !defined(PNG_IMPEXP)
1293# if defined(PNG_BUILD_DLL)
1294# define PNG_IMPEXP __declspec(dllexport)
1295# else
1296# define PNG_IMPEXP __declspec(dllimport)
1297# endif
1298# endif
1299# endif /* PNG_IMPEXP */
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001300#else /* !(DLL || non-cygwin WINDOWS) */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001301# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
1302# ifndef PNGAPI
1303# define PNGAPI _System
Glenn Randers-Pehrsonf64a06f2001-04-11 07:38:00 -05001304# endif
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001305# else
1306# if 0 /* ... other platforms, with other meanings */
1307# endif
1308# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001309#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001310
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -06001311#ifndef PNGAPI
1312# define PNGAPI
1313#endif
1314#ifndef PNG_IMPEXP
1315# define PNG_IMPEXP
1316#endif
1317
Glenn Randers-Pehrsonc3dda6d2004-11-27 18:22:29 -06001318#ifdef PNG_BUILDSYMS
1319# ifndef PNG_EXPORT
1320# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END
1321# endif
1322# ifdef PNG_USE_GLOBAL_ARRAYS
1323# ifndef PNG_EXPORT_VAR
1324# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT
1325# endif
1326# endif
1327#endif
1328
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -05001329#ifndef PNG_EXPORT
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001330# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001331#endif
1332
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001333#ifdef PNG_USE_GLOBAL_ARRAYS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001334# ifndef PNG_EXPORT_VAR
1335# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type
1336# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001337#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001338
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001339/* Users may want to use these so they are not private. Any library
1340 * functions that are passed far data must be model-independent.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001341 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001342
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001343#ifdef PNG_SETJMP_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001344# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06001345#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001346# define png_jmpbuf(png_ptr) \
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -05001347 (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001348#endif
1349
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001350/* memory model/platform independent fns */
1351#ifndef PNG_ABORT
1352# ifdef _WINDOWS_
1353# define PNG_ABORT() ExitProcess(0)
1354# else
1355# define PNG_ABORT() abort()
1356# endif
1357#endif
1358
1359#if defined(USE_FAR_KEYWORD)
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001360/* use this to make far-to-near assignments */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001361# define CHECK 1
1362# define NOCHECK 0
1363# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
1364# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001365# define png_strcpy _fstrcpy
1366# define png_strncpy _fstrncpy /* Added to v 1.2.6 */
1367# define png_strlen _fstrlen
1368# define png_memcmp _fmemcmp /* SJT: added */
1369# define png_memcpy _fmemcpy
Glenn Randers-Pehrson8551d592009-08-29 16:25:19 -05001370# define png_memset _fmemset
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001371# define png_sprintf sprintf
1372#else
1373# if defined(_WINDOWS_) /* favor Windows over C runtime fns */
1374# define CVT_PTR(ptr) (ptr)
1375# define CVT_PTR_NOCHECK(ptr) (ptr)
1376# define png_strcpy lstrcpyA
1377# define png_strncpy lstrcpynA
1378# define png_strlen lstrlenA
1379# define png_memcmp memcmp
1380# define png_memcpy CopyMemory
1381# define png_memset memset
1382# define png_sprintf wsprintfA
1383# else
1384# define CVT_PTR(ptr) (ptr)
1385# define CVT_PTR_NOCHECK(ptr) (ptr)
1386# define png_strcpy strcpy
1387# define png_strncpy strncpy /* Added to v 1.2.6 */
1388# define png_strlen strlen
1389# define png_memcmp memcmp /* SJT: added */
1390# define png_memcpy memcpy
1391# define png_memset memset
1392# define png_sprintf sprintf
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001393# ifndef PNG_NO_SNPRINTF
1394# ifdef _MSC_VER
1395# define png_snprintf _snprintf /* Added to v 1.2.19 */
1396# define png_snprintf2 _snprintf
1397# define png_snprintf6 _snprintf
1398# else
1399# define png_snprintf snprintf /* Added to v 1.2.19 */
1400# define png_snprintf2 snprintf
1401# define png_snprintf6 snprintf
1402# endif
1403# else
1404 /* You don't have or don't want to use snprintf(). Caution: Using
1405 * sprintf instead of snprintf exposes your application to accidental
1406 * or malevolent buffer overflows. If you don't have snprintf()
1407 * as a general rule you should provide one (you can get one from
1408 * Portable OpenSSH). */
1409# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1)
1410# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2)
1411# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
1412 sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
1413# endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001414# endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001415#endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001416
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001417/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
1418 * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
1419 * to png_alloc_size_t are not necessary; in fact, it is recommended
1420 * not to use them at all so that the compiler can complain when something
1421 * turns out to be problematic.
1422 * Casts in the other direction (from png_alloc_size_t to png_size_t or
1423 * png_uint_32) should be explicitly applied; however, we do not expect
1424 * to encounter practical situations that require such conversions.
1425 */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001426#if defined(__TURBOC__) && !defined(__FLAT__)
1427# define png_mem_alloc farmalloc
1428# define png_mem_free farfree
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001429 typedef unsigned long png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001430#else
1431# if defined(_MSC_VER) && defined(MAXSEG_64K)
1432# define png_mem_alloc(s) halloc(s, 1)
1433# define png_mem_free hfree
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001434 typedef unsigned long png_alloc_size_t;
1435# else
1436# if defined(_WINDOWS_) && (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001437# define png_mem_alloc(s) HeapAlloc(GetProcessHeap(), 0, s)
1438# define png_mem_free(p) HeapFree(GetProcessHeap(), 0, p)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001439 typedef DWORD png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001440# else
1441# define png_mem_alloc malloc
1442# define png_mem_free free
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001443 typedef png_size_t png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001444# endif
1445# endif
1446#endif
1447/* End of memory model/platform independent support */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001448
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001449/* Just a little check that someone hasn't tried to define something
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001450 * contradictory.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001451 */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001452#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001453# undef PNG_ZBUF_SIZE
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001454# define PNG_ZBUF_SIZE 65536L
Andreas Dilger47a0c421997-05-16 02:46:07 -05001455#endif
1456
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001457
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -06001458/* Added at libpng-1.2.8 */
1459#endif /* PNG_VERSION_INFO_ONLY */
Glenn Randers-Pehrson40936072004-11-20 11:18:40 -06001460
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001461#endif /* PNGCONF_H */