blob: ded6c0dd8a7bfa7f879ca5ce244206dddf41a336 [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-Pehrson5b5dcf82004-07-17 22:45:44 -05004 * libpng version 1.2.6beta3 - July 18, 2004
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06005 * For conditions of distribution and use, see copyright notice in png.h
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05006 * Copyright (c) 1998-2004 Glenn Randers-Pehrson
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05007 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06009 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050010
11/* Any machine specific code is near the front of this file, so if you
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060012 * are configuring libpng for a machine, you may want to read the section
13 * starting here down to where it starts to typedef png_color, png_text,
14 * and png_info.
15 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050016
17#ifndef PNGCONF_H
18#define PNGCONF_H
19
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -050020#ifdef PNG_USER_CONFIG
21#include "pngusr.h"
22#endif
23
Andreas Dilger02ad0ef1997-01-17 01:34:35 -060024/* This is the size of the compression buffer, and thus the size of
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060025 * an IDAT chunk. Make this whatever size you feel is best for your
26 * machine. One of these will be allocated per png_struct. When this
27 * is full, it writes the data to the disk, and does some other
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -060028 * calculations. Making this an extremely small size will slow
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060029 * the library down, but you may want to experiment to determine
30 * where it becomes significant, if you are concerned with memory
31 * usage. Note that zlib allocates at least 32Kb also. For readers,
32 * this describes the size of the buffer available to read the data in.
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060033 * Unless this gets smaller than the size of a row (compressed),
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060034 * it should not make much difference how big this is.
35 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050036
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -060037#ifndef PNG_ZBUF_SIZE
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -060038# define PNG_ZBUF_SIZE 8192
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -060039#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -050040
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -060041/* Enable if you want a write-only libpng */
42
43#ifndef PNG_NO_READ_SUPPORTED
44# define PNG_READ_SUPPORTED
45#endif
46
47/* Enable if you want a read-only libpng */
48
49#ifndef PNG_NO_WRITE_SUPPORTED
50# define PNG_WRITE_SUPPORTED
51#endif
52
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -050053/* Enabled by default in 1.2.0. You can disable this if you don't need to
54 support PNGs that are embedded in MNG datastreams */
Glenn Randers-Pehrson377657d2002-03-08 01:31:27 -060055#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES)
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -060056# ifndef PNG_MNG_FEATURES_SUPPORTED
57# define PNG_MNG_FEATURES_SUPPORTED
58# endif
59#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -060060
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -060061#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -060062# ifndef PNG_FLOATING_POINT_SUPPORTED
63# define PNG_FLOATING_POINT_SUPPORTED
64# endif
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -050065#endif
66
Andreas Dilger47a0c421997-05-16 02:46:07 -050067/* If you are running on a machine where you cannot allocate more
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060068 * than 64K of memory at once, uncomment this. While libpng will not
69 * normally need that much memory in a chunk (unless you load up a very
70 * large file), zlib needs to know how big of a chunk it can use, and
71 * libpng thus makes sure to check any memory allocation to verify it
72 * will fit into memory.
Andreas Dilger47a0c421997-05-16 02:46:07 -050073#define PNG_MAX_MALLOC_64K
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060074 */
Andreas Dilger47a0c421997-05-16 02:46:07 -050075#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -060076# define PNG_MAX_MALLOC_64K
Guy Schalnat51f0eb41995-09-26 05:22:39 -050077#endif
78
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -050079/* Special munging to support doing things the 'cygwin' way:
80 * 'Normal' png-on-win32 defines/defaults:
81 * PNG_BUILD_DLL -- building dll
82 * PNG_USE_DLL -- building an application, linking to dll
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -060083 * (no define) -- building static library, or building an
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -050084 * application and linking to the static lib
85 * 'Cygwin' defines/defaults:
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050086 * PNG_BUILD_DLL -- (ignored) building the dll
87 * (no define) -- (ignored) building an application, linking to the dll
88 * PNG_STATIC -- (ignored) building the static lib, or building an
89 * application that links to the static lib.
90 * ALL_STATIC -- (ignored) building various static libs, or building an
91 * application that links to the static libs.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -050092 * Thus,
93 * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
94 * this bit of #ifdefs will define the 'correct' config variables based on
95 * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but
96 * unnecessary.
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -050097 *
98 * Also, the precedence order is:
99 * ALL_STATIC (since we can't #undef something outside our namespace)
100 * PNG_BUILD_DLL
101 * PNG_STATIC
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500102 * (nothing) == PNG_USE_DLL
103 *
104 * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
105 * of auto-import in binutils, we no longer need to worry about
106 * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore,
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500107 * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
108 * to __declspec() stuff. However, we DO need to worry about
109 * PNG_BUILD_DLL and PNG_STATIC because those change some defaults
110 * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500111 */
112#if defined(__CYGWIN__)
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500113# if defined(ALL_STATIC)
114# if defined(PNG_BUILD_DLL)
115# undef PNG_BUILD_DLL
116# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500117# if defined(PNG_USE_DLL)
118# undef PNG_USE_DLL
119# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500120# if defined(PNG_DLL)
121# undef PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500122# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500123# if !defined(PNG_STATIC)
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -0600124# define PNG_STATIC
125# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500126# else
127# if defined (PNG_BUILD_DLL)
128# if defined(PNG_STATIC)
129# undef PNG_STATIC
130# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500131# if defined(PNG_USE_DLL)
132# undef PNG_USE_DLL
133# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500134# if !defined(PNG_DLL)
135# define PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500136# endif
137# else
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500138# if defined(PNG_STATIC)
139# if defined(PNG_USE_DLL)
140# undef PNG_USE_DLL
141# endif
142# if defined(PNG_DLL)
143# undef PNG_DLL
144# endif
145# else
146# if !defined(PNG_USE_DLL)
147# define PNG_USE_DLL
148# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500149# if !defined(PNG_DLL)
150# define PNG_DLL
151# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500152# endif
153# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500154# endif
155#endif
156
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500157/* This protects us against compilers that run on a windowing system
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600158 * and thus don't have or would rather us not use the stdio types:
159 * stdin, stdout, and stderr. The only one currently used is stderr
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600160 * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will
161 * prevent these from being compiled and used. #defining PNG_NO_STDIO
162 * will also prevent these, plus will prevent the entire set of stdio
163 * macros and functions (FILE *, printf, etc.) from being compiled and used,
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500164 * unless (PNG_DEBUG > 0) has been #defined.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600165 *
166 * #define PNG_NO_CONSOLE_IO
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600167 * #define PNG_NO_STDIO
168 */
Guy Schalnat6d764711995-12-19 03:22:19 -0600169
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500170#if defined(_WIN32_WCE)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600171# include <windows.h>
172 /* Console I/O functions are not supported on WindowsCE */
173# define PNG_NO_CONSOLE_IO
174# ifdef PNG_DEBUG
175# undef PNG_DEBUG
176# endif
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500177#endif
178
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -0500179#ifdef PNG_BUILD_DLL
180# ifndef PNG_CONSOLE_IO_SUPPORTED
181# ifndef PNG_NO_CONSOLE_IO
182# define PNG_NO_CONSOLE_IO
183# endif
184# endif
185#endif
186
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600187# ifdef PNG_NO_STDIO
188# ifndef PNG_NO_CONSOLE_IO
189# define PNG_NO_CONSOLE_IO
190# endif
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500191# ifdef PNG_DEBUG
192# if (PNG_DEBUG > 0)
193# include <stdio.h>
194# endif
195# endif
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600196# else
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500197# if !defined(_WIN32_WCE)
198/* "stdio.h" functions are not supported on WindowsCE */
199# include <stdio.h>
200# endif
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600201# endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600202
203/* This macro protects us against machines that don't have function
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600204 * prototypes (ie K&R style headers). If your compiler does not handle
205 * function prototypes, define this macro and use the included ansi2knr.
206 * I've always been able to use _NO_PROTO as the indicator, but you may
207 * need to drag the empty declaration out in front of here, or change the
208 * ifdef to suit your own needs.
209 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500210#ifndef PNGARG
211
Andreas Dilger47a0c421997-05-16 02:46:07 -0500212#ifdef OF /* zlib prototype munger */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600213# define PNGARG(arglist) OF(arglist)
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500214#else
215
216#ifdef _NO_PROTO
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600217# define PNGARG(arglist) ()
Glenn Randers-Pehrson5cded0b2001-11-07 07:10:08 -0600218# ifndef PNG_TYPECAST_NULL
219# define PNG_TYPECAST_NULL
220# endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500221#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600222# define PNGARG(arglist) arglist
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500223#endif /* _NO_PROTO */
224
225#endif /* OF */
226
227#endif /* PNGARG */
228
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600229/* Try to determine if we are compiling on a Mac. Note that testing for
230 * just __MWERKS__ is not good enough, because the Codewarrior is now used
231 * on non-Mac platforms.
232 */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600233#ifndef MACOS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600234# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
235 defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
236# define MACOS
237# endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600238#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600239
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500240/* enough people need this for various reasons to include it here */
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500241#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600242# include <sys/types.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500243#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600244
Glenn Randers-Pehrsonb1828932001-06-23 08:03:17 -0500245#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600246# define PNG_SETJMP_SUPPORTED
247#endif
248
249#ifdef PNG_SETJMP_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -0500250/* This is an attempt to force a single setjmp behaviour on Linux. If
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600251 * the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
252 */
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500253
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600254# ifdef __linux__
255# ifdef _BSD_SOURCE
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500256# define PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600257# undef _BSD_SOURCE
258# endif
259# ifdef _SETJMP_H
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500260 __png.h__ already includes setjmp.h;
261 __dont__ include it again.;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600262# endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600263# endif /* __linux__ */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500264
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600265 /* include setjmp.h for error handling */
266# include <setjmp.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500267
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600268# ifdef __linux__
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500269# ifdef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600270# define _BSD_SOURCE
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -0500271# undef PNG_SAVE_BSD_SOURCE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600272# endif
273# endif /* __linux__ */
274#endif /* PNG_SETJMP_SUPPORTED */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600275
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500276#ifdef BSD
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600277# include <strings.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500278#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600279# include <string.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500280#endif
281
Andreas Dilger47a0c421997-05-16 02:46:07 -0500282/* Other defines for things like memory and the like can go here. */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500283#ifdef PNG_INTERNAL
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600284
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500285#include <stdlib.h>
Andreas Dilger47a0c421997-05-16 02:46:07 -0500286
287/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which
288 * aren't usually used outside the library (as far as I know), so it is
289 * debatable if they should be exported at all. In the future, when it is
290 * possible to have run-time registry of chunk-handling functions, some of
291 * these will be made available again.
292#define PNG_EXTERN extern
293 */
294#define PNG_EXTERN
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500295
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600296/* Other defines specific to compilers can go here. Try to keep
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600297 * them inside an appropriate ifdef/endif pair for portability.
298 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500299
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500300#if defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600301# if defined(MACOS)
302 /* We need to check that <math.h> hasn't already been included earlier
303 * as it seems it doesn't agree with <fp.h>, yet we should really use
304 * <fp.h> if possible.
305 */
306# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
307# include <fp.h>
308# endif
309# else
310# include <math.h>
311# endif
312# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
313 /* Amiga SAS/C: We must include builtin FPU functions when compiling using
314 * MATH=68881
315 */
316# include <m68881.h>
317# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600318#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600319
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600320/* Codewarrior on NT has linking problems without this. */
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500321#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600322# define PNG_ALWAYS_EXTERN
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600323#endif
324
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -0500325/* This provides the non-ANSI (far) memory allocation routines. */
326#if defined(__TURBOC__) && defined(__MSDOS__)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600327# include <mem.h>
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -0500328# include <alloc.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500329#endif
330
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -0500331/* I have no idea why is this necessary... */
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500332#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \
333 defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__))
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600334# include <malloc.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500335#endif
336
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600337/* This controls how fine the dithering gets. As this allocates
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600338 * a largish chunk of memory (32K), those who are not as concerned
339 * with dithering quality can decrease some or all of these.
340 */
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600341#ifndef PNG_DITHER_RED_BITS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600342# define PNG_DITHER_RED_BITS 5
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600343#endif
344#ifndef PNG_DITHER_GREEN_BITS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600345# define PNG_DITHER_GREEN_BITS 5
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600346#endif
347#ifndef PNG_DITHER_BLUE_BITS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600348# define PNG_DITHER_BLUE_BITS 5
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600349#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500350
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600351/* This controls how fine the gamma correction becomes when you
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600352 * are only interested in 8 bits anyway. Increasing this value
353 * results in more memory being used, and more pow() functions
354 * being called to fill in the gamma tables. Don't set this value
355 * less then 8, and even that may not work (I haven't tested it).
356 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500357
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600358#ifndef PNG_MAX_GAMMA_8
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600359# define PNG_MAX_GAMMA_8 11
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600360#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500361
Andreas Dilger47a0c421997-05-16 02:46:07 -0500362/* This controls how much a difference in gamma we can tolerate before
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600363 * we actually start doing gamma conversion.
364 */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600365#ifndef PNG_GAMMA_THRESHOLD
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600366# define PNG_GAMMA_THRESHOLD 0.05
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600367#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500368
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500369#endif /* PNG_INTERNAL */
370
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600371/* The following uses const char * instead of char * for error
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600372 * and warning message functions, so some compilers won't complain.
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600373 * If you do not want to use const, define PNG_NO_CONST here.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600374 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600375
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600376#ifndef PNG_NO_CONST
Guy Schalnat6d764711995-12-19 03:22:19 -0600377# define PNG_CONST const
378#else
379# define PNG_CONST
380#endif
381
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600382/* The following defines give you the ability to remove code from the
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600383 * library that you will not be using. I wish I could figure out how to
384 * automate this, but I can't do that without making it seriously hard
385 * on the users. So if you are not using an ability, change the #define
386 * to and #undef, and that part of the library will not be compiled. If
387 * your linker can't find a function, you may want to make sure the
388 * ability is defined here. Some of these depend upon some others being
389 * defined. I haven't figured out all the interactions here, so you may
390 * have to experiment awhile to get everything to compile. If you are
391 * creating or using a shared library, you probably shouldn't touch this,
392 * as it will affect the size of the structures, and this will cause bad
393 * things to happen if the library and/or application ever change.
394 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500395
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500396/* Any features you will not be using can be undef'ed here */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600397
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600398/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500399 * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS
400 * on the compile line, then pick and choose which ones to define without
401 * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED
402 * if you only want to have a png-compliant reader/writer but don't need
403 * any of the extra transformations. This saves about 80 kbytes in a
404 * typical installation of the library. (PNG_NO_* form added in version
405 * 1.0.1c, for consistency)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600406 */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600407
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500408/* The size of the png_text structure changed in libpng-1.0.6 when
409 * iTXt is supported. It is turned off by default, to support old apps
410 * that malloc the png_text structure instead of calling png_set_text()
411 * and letting libpng malloc it. It will be turned on by default in
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600412 * libpng-1.3.0.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500413 */
414
415#ifndef PNG_iTXt_SUPPORTED
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500416# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500417# define PNG_NO_READ_iTXt
418# endif
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500419# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500420# define PNG_NO_WRITE_iTXt
421# endif
422#endif
423
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500424/* The following support, added after version 1.0.0, can be turned off here en
425 * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility
426 * with old applications that require the length of png_struct and png_info
427 * to remain unchanged.
428 */
429
430#ifdef PNG_LEGACY_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600431# define PNG_NO_FREE_ME
432# define PNG_NO_READ_UNKNOWN_CHUNKS
433# define PNG_NO_WRITE_UNKNOWN_CHUNKS
434# define PNG_NO_READ_USER_CHUNKS
435# define PNG_NO_READ_iCCP
436# define PNG_NO_WRITE_iCCP
437# define PNG_NO_READ_iTXt
438# define PNG_NO_WRITE_iTXt
439# define PNG_NO_READ_sCAL
440# define PNG_NO_WRITE_sCAL
441# define PNG_NO_READ_sPLT
442# define PNG_NO_WRITE_sPLT
443# define PNG_NO_INFO_IMAGE
444# define PNG_NO_READ_RGB_TO_GRAY
445# define PNG_NO_READ_USER_TRANSFORM
446# define PNG_NO_WRITE_USER_TRANSFORM
447# define PNG_NO_USER_MEM
448# define PNG_NO_READ_EMPTY_PLTE
449# define PNG_NO_MNG_FEATURES
450# define PNG_NO_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500451#endif
452
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500453/* Ignore attempt to turn off both floating and fixed point support */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500454#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600455 !defined(PNG_NO_FIXED_POINT_SUPPORTED)
456# define PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500457#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600458
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500459#ifndef PNG_NO_FREE_ME
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600460# define PNG_FREE_ME_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500461#endif
462
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600463#if defined(PNG_READ_SUPPORTED)
464
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500465#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600466 !defined(PNG_NO_READ_TRANSFORMS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600467# define PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600468#endif
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600469
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600470#ifdef PNG_READ_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600471# ifndef PNG_NO_READ_EXPAND
472# define PNG_READ_EXPAND_SUPPORTED
473# endif
474# ifndef PNG_NO_READ_SHIFT
475# define PNG_READ_SHIFT_SUPPORTED
476# endif
477# ifndef PNG_NO_READ_PACK
478# define PNG_READ_PACK_SUPPORTED
479# endif
480# ifndef PNG_NO_READ_BGR
481# define PNG_READ_BGR_SUPPORTED
482# endif
483# ifndef PNG_NO_READ_SWAP
484# define PNG_READ_SWAP_SUPPORTED
485# endif
486# ifndef PNG_NO_READ_PACKSWAP
487# define PNG_READ_PACKSWAP_SUPPORTED
488# endif
489# ifndef PNG_NO_READ_INVERT
490# define PNG_READ_INVERT_SUPPORTED
491# endif
492# ifndef PNG_NO_READ_DITHER
493# define PNG_READ_DITHER_SUPPORTED
494# endif
495# ifndef PNG_NO_READ_BACKGROUND
496# define PNG_READ_BACKGROUND_SUPPORTED
497# endif
498# ifndef PNG_NO_READ_16_TO_8
499# define PNG_READ_16_TO_8_SUPPORTED
500# endif
501# ifndef PNG_NO_READ_FILLER
502# define PNG_READ_FILLER_SUPPORTED
503# endif
504# ifndef PNG_NO_READ_GAMMA
505# define PNG_READ_GAMMA_SUPPORTED
506# endif
507# ifndef PNG_NO_READ_GRAY_TO_RGB
508# define PNG_READ_GRAY_TO_RGB_SUPPORTED
509# endif
510# ifndef PNG_NO_READ_SWAP_ALPHA
511# define PNG_READ_SWAP_ALPHA_SUPPORTED
512# endif
513# ifndef PNG_NO_READ_INVERT_ALPHA
514# define PNG_READ_INVERT_ALPHA_SUPPORTED
515# endif
516# ifndef PNG_NO_READ_STRIP_ALPHA
517# define PNG_READ_STRIP_ALPHA_SUPPORTED
518# endif
519# ifndef PNG_NO_READ_USER_TRANSFORM
520# define PNG_READ_USER_TRANSFORM_SUPPORTED
521# endif
522# ifndef PNG_NO_READ_RGB_TO_GRAY
523# define PNG_READ_RGB_TO_GRAY_SUPPORTED
524# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600525#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600526
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500527#if !defined(PNG_NO_PROGRESSIVE_READ) && \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600528 !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
529# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600530#endif /* about interlacing capability! You'll */
531 /* still have interlacing unless you change the following line: */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600532
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600533#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500534
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500535#ifndef PNG_NO_READ_COMPOSITE_NODIV
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600536# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
537# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
538# endif
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500539#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500540
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600541/* Deprecated, will be removed from version 2.0.0.
542 Use PNG_MNG_FEATURES_SUPPORTED instead. */
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500543#ifndef PNG_NO_READ_EMPTY_PLTE
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600544# define PNG_READ_EMPTY_PLTE_SUPPORTED
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500545#endif
546
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600547#endif /* PNG_READ_SUPPORTED */
548
549#if defined(PNG_WRITE_SUPPORTED)
550
551# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
552 !defined(PNG_NO_WRITE_TRANSFORMS)
553# define PNG_WRITE_TRANSFORMS_SUPPORTED
554#endif
555
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600556#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600557# ifndef PNG_NO_WRITE_SHIFT
558# define PNG_WRITE_SHIFT_SUPPORTED
559# endif
560# ifndef PNG_NO_WRITE_PACK
561# define PNG_WRITE_PACK_SUPPORTED
562# endif
563# ifndef PNG_NO_WRITE_BGR
564# define PNG_WRITE_BGR_SUPPORTED
565# endif
566# ifndef PNG_NO_WRITE_SWAP
567# define PNG_WRITE_SWAP_SUPPORTED
568# endif
569# ifndef PNG_NO_WRITE_PACKSWAP
570# define PNG_WRITE_PACKSWAP_SUPPORTED
571# endif
572# ifndef PNG_NO_WRITE_INVERT
573# define PNG_WRITE_INVERT_SUPPORTED
574# endif
575# ifndef PNG_NO_WRITE_FILLER
576# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */
577# endif
578# ifndef PNG_NO_WRITE_SWAP_ALPHA
579# define PNG_WRITE_SWAP_ALPHA_SUPPORTED
580# endif
581# ifndef PNG_NO_WRITE_INVERT_ALPHA
582# define PNG_WRITE_INVERT_ALPHA_SUPPORTED
583# endif
584# ifndef PNG_NO_WRITE_USER_TRANSFORM
585# define PNG_WRITE_USER_TRANSFORM_SUPPORTED
586# endif
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600587#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600588
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500589#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600590 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
591# ifndef PNG_NO_USER_TRANSFORM_PTR
592# define PNG_USER_TRANSFORM_PTR_SUPPORTED
593# endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500594#endif
595
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600596#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
597 encoders, but can cause trouble
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600598 if left undefined */
599
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500600#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
601 defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600602# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500603#endif
604
Glenn Randers-Pehrson73d57cb2002-03-25 18:49:08 -0600605#ifndef PNG_1_0_X
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500606#ifndef PNG_NO_ERROR_NUMBERS
607#define PNG_ERROR_NUMBERS_SUPPORTED
608#endif
Glenn Randers-Pehrson73d57cb2002-03-25 18:49:08 -0600609#endif /* PNG_1_0_X */
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500610
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500611#ifndef PNG_NO_WRITE_FLUSH
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600612# define PNG_WRITE_FLUSH_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500613#endif
614
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -0600615/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500616#ifndef PNG_NO_WRITE_EMPTY_PLTE
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600617# define PNG_WRITE_EMPTY_PLTE_SUPPORTED
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500618#endif
619
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600620#endif /* PNG_WRITE_SUPPORTED */
621
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500622#ifndef PNG_NO_STDIO
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600623# define PNG_TIME_RFC1123_SUPPORTED
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600624#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500625
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600626/* This adds extra functions in pngget.c for accessing data from the
627 * info pointer (added in version 0.99)
628 * png_get_image_width()
629 * png_get_image_height()
630 * png_get_bit_depth()
631 * png_get_color_type()
632 * png_get_compression_type()
633 * png_get_filter_type()
634 * png_get_interlace_type()
635 * png_get_pixel_aspect_ratio()
636 * png_get_pixels_per_meter()
637 * png_get_x_offset_pixels()
638 * png_get_y_offset_pixels()
639 * png_get_x_offset_microns()
640 * png_get_y_offset_microns()
641 */
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500642#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600643# define PNG_EASY_ACCESS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600644#endif
645
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500646/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
Glenn Randers-Pehrsoncdf140b2001-01-15 12:22:32 -0600647 even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500648#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
649# ifndef PNG_ASSEMBLER_CODE_SUPPORTED
650# define PNG_ASSEMBLER_CODE_SUPPORTED
651# endif
652# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
653# define PNG_MMX_CODE_SUPPORTED
654# endif
655#endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500656
Glenn Randers-Pehrson1ea0ff32001-08-07 22:25:59 -0500657/* If you are sure that you don't need thread safety and you are compiling
658 with PNG_USE_PNGCCRD for an MMX application, you can define this for
659 faster execution. See pnggccrd.c.
660#define PNG_THREAD_UNSAFE_OK
661*/
662
Glenn Randers-Pehrson377657d2002-03-08 01:31:27 -0600663#if !defined(PNG_1_0_X)
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500664#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
665# define PNG_USER_MEM_SUPPORTED
666#endif
Glenn Randers-Pehrson377657d2002-03-08 01:31:27 -0600667#endif /* PNG_1_0_X */
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500668
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600669/* These are currently experimental features, define them if you want */
670
671/* very little testing */
672/*
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600673#ifdef PNG_READ_SUPPORTED
674# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
675# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
676# endif
677#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600678*/
Andreas Dilger47a0c421997-05-16 02:46:07 -0500679
680/* This is only for PowerPC big-endian and 680x0 systems */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600681/* some testing */
682/*
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600683#ifdef PNG_READ_SUPPORTED
684# ifndef PNG_PNG_READ_BIG_ENDIAN_SUPPORTED
685# define PNG_READ_BIG_ENDIAN_SUPPORTED
686# endif
687#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600688*/
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500689
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -0500690/* Buggy compilers (e.g., gcc 2.7.2.2) need this */
691/*
692#define PNG_NO_POINTER_INDEXING
693*/
694
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600695/* These functions are turned off by default, as they will be phased out. */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600696/*
697#define PNG_USELESS_TESTS_SUPPORTED
698#define PNG_CORRECT_PALETTE_SUPPORTED
699*/
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600700
Andreas Dilger47a0c421997-05-16 02:46:07 -0500701/* Any chunks you are not interested in, you can undef here. The
702 * ones that allocate memory may be expecially important (hIST,
703 * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600704 * a bit smaller.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500705 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500706
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600707#if defined(PNG_READ_SUPPORTED) && \
708 !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500709 !defined(PNG_NO_READ_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600710# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600711#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600712
713#if defined(PNG_WRITE_SUPPORTED) && \
714 !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500715 !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600716# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600717#endif
718
719#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600720
721#ifdef PNG_NO_READ_TEXT
722# define PNG_NO_READ_iTXt
723# define PNG_NO_READ_tEXt
724# define PNG_NO_READ_zTXt
725#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500726#ifndef PNG_NO_READ_bKGD
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600727# define PNG_READ_bKGD_SUPPORTED
728# define PNG_bKGD_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500729#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500730#ifndef PNG_NO_READ_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600731# define PNG_READ_cHRM_SUPPORTED
732# define PNG_cHRM_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500733#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500734#ifndef PNG_NO_READ_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600735# define PNG_READ_gAMA_SUPPORTED
736# define PNG_gAMA_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500737#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500738#ifndef PNG_NO_READ_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600739# define PNG_READ_hIST_SUPPORTED
740# define PNG_hIST_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600741#endif
742#ifndef PNG_NO_READ_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600743# define PNG_READ_iCCP_SUPPORTED
744# define PNG_iCCP_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600745#endif
746#ifndef PNG_NO_READ_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500747# ifndef PNG_READ_iTXt_SUPPORTED
748# define PNG_READ_iTXt_SUPPORTED
749# endif
750# ifndef PNG_iTXt_SUPPORTED
751# define PNG_iTXt_SUPPORTED
752# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500753#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500754#ifndef PNG_NO_READ_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600755# define PNG_READ_oFFs_SUPPORTED
756# define PNG_oFFs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500757#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500758#ifndef PNG_NO_READ_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600759# define PNG_READ_pCAL_SUPPORTED
760# define PNG_pCAL_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600761#endif
762#ifndef PNG_NO_READ_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600763# define PNG_READ_sCAL_SUPPORTED
764# define PNG_sCAL_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500765#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500766#ifndef PNG_NO_READ_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600767# define PNG_READ_pHYs_SUPPORTED
768# define PNG_pHYs_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500769#endif
770#ifndef PNG_NO_READ_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600771# define PNG_READ_sBIT_SUPPORTED
772# define PNG_sBIT_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600773#endif
774#ifndef PNG_NO_READ_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600775# define PNG_READ_sPLT_SUPPORTED
776# define PNG_sPLT_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500777#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500778#ifndef PNG_NO_READ_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600779# define PNG_READ_sRGB_SUPPORTED
780# define PNG_sRGB_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500781#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500782#ifndef PNG_NO_READ_tEXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600783# define PNG_READ_tEXt_SUPPORTED
784# define PNG_tEXt_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500785#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500786#ifndef PNG_NO_READ_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600787# define PNG_READ_tIME_SUPPORTED
788# define PNG_tIME_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500789#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500790#ifndef PNG_NO_READ_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600791# define PNG_READ_tRNS_SUPPORTED
792# define PNG_tRNS_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500793#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500794#ifndef PNG_NO_READ_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600795# define PNG_READ_zTXt_SUPPORTED
796# define PNG_zTXt_SUPPORTED
797#endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500798#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
799# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500800# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
801# define PNG_UNKNOWN_CHUNKS_SUPPORTED
802# endif
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500803# ifndef PNG_NO_HANDLE_AS_UNKNOWN
804# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
805# endif
806#endif
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -0500807#if !defined(PNG_NO_READ_USER_CHUNKS) && \
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500808 defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600809# define PNG_READ_USER_CHUNKS_SUPPORTED
810# define PNG_USER_CHUNKS_SUPPORTED
811# ifdef PNG_NO_READ_UNKNOWN_CHUNKS
812# undef PNG_NO_READ_UNKNOWN_CHUNKS
813# endif
814# ifdef PNG_NO_HANDLE_AS_UNKNOWN
815# undef PNG_NO_HANDLE_AS_UNKNOWN
816# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600817#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500818#ifndef PNG_NO_READ_OPT_PLTE
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600819# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
820#endif /* optional PLTE chunk in RGB and RGBA images */
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600821#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600822 defined(PNG_READ_zTXt_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600823# define PNG_READ_TEXT_SUPPORTED
824# define PNG_TEXT_SUPPORTED
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600825#endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600826
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600827#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500828
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600829#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600830
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600831#ifdef PNG_NO_WRITE_TEXT
832# define PNG_NO_WRITE_iTXt
833# define PNG_NO_WRITE_tEXt
834# define PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600835#endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600836#ifndef PNG_NO_WRITE_bKGD
837# define PNG_WRITE_bKGD_SUPPORTED
838# ifndef PNG_bKGD_SUPPORTED
839# define PNG_bKGD_SUPPORTED
840# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500841#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500842#ifndef PNG_NO_WRITE_cHRM
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600843# define PNG_WRITE_cHRM_SUPPORTED
844# ifndef PNG_cHRM_SUPPORTED
845# define PNG_cHRM_SUPPORTED
846# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500847#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500848#ifndef PNG_NO_WRITE_gAMA
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600849# define PNG_WRITE_gAMA_SUPPORTED
850# ifndef PNG_gAMA_SUPPORTED
851# define PNG_gAMA_SUPPORTED
852# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500853#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500854#ifndef PNG_NO_WRITE_hIST
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600855# define PNG_WRITE_hIST_SUPPORTED
856# ifndef PNG_hIST_SUPPORTED
857# define PNG_hIST_SUPPORTED
858# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600859#endif
860#ifndef PNG_NO_WRITE_iCCP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600861# define PNG_WRITE_iCCP_SUPPORTED
862# ifndef PNG_iCCP_SUPPORTED
863# define PNG_iCCP_SUPPORTED
864# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600865#endif
866#ifndef PNG_NO_WRITE_iTXt
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500867# ifndef PNG_WRITE_iTXt_SUPPORTED
868# define PNG_WRITE_iTXt_SUPPORTED
869# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600870# ifndef PNG_iTXt_SUPPORTED
871# define PNG_iTXt_SUPPORTED
872# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500873#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500874#ifndef PNG_NO_WRITE_oFFs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600875# define PNG_WRITE_oFFs_SUPPORTED
876# ifndef PNG_oFFs_SUPPORTED
877# define PNG_oFFs_SUPPORTED
878# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500879#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500880#ifndef PNG_NO_WRITE_pCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600881# define PNG_WRITE_pCAL_SUPPORTED
882# ifndef PNG_pCAL_SUPPORTED
883# define PNG_pCAL_SUPPORTED
884# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600885#endif
886#ifndef PNG_NO_WRITE_sCAL
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600887# define PNG_WRITE_sCAL_SUPPORTED
888# ifndef PNG_sCAL_SUPPORTED
889# define PNG_sCAL_SUPPORTED
890# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500891#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500892#ifndef PNG_NO_WRITE_pHYs
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600893# define PNG_WRITE_pHYs_SUPPORTED
894# ifndef PNG_pHYs_SUPPORTED
895# define PNG_pHYs_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_sBIT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600899# define PNG_WRITE_sBIT_SUPPORTED
900# ifndef PNG_sBIT_SUPPORTED
901# define PNG_sBIT_SUPPORTED
902# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600903#endif
904#ifndef PNG_NO_WRITE_sPLT
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600905# define PNG_WRITE_sPLT_SUPPORTED
906# ifndef PNG_sPLT_SUPPORTED
907# define PNG_sPLT_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_sRGB
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600911# define PNG_WRITE_sRGB_SUPPORTED
912# ifndef PNG_sRGB_SUPPORTED
913# define PNG_sRGB_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_tEXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600917# define PNG_WRITE_tEXt_SUPPORTED
918# ifndef PNG_tEXt_SUPPORTED
919# define PNG_tEXt_SUPPORTED
920# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500921#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500922#ifndef PNG_NO_WRITE_tIME
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600923# define PNG_WRITE_tIME_SUPPORTED
924# ifndef PNG_tIME_SUPPORTED
925# define PNG_tIME_SUPPORTED
926# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500927#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500928#ifndef PNG_NO_WRITE_tRNS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600929# define PNG_WRITE_tRNS_SUPPORTED
930# ifndef PNG_tRNS_SUPPORTED
931# define PNG_tRNS_SUPPORTED
932# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500933#endif
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500934#ifndef PNG_NO_WRITE_zTXt
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600935# define PNG_WRITE_zTXt_SUPPORTED
936# ifndef PNG_zTXt_SUPPORTED
937# define PNG_zTXt_SUPPORTED
938# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600939#endif
940#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600941# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
942# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
943# define PNG_UNKNOWN_CHUNKS_SUPPORTED
944# endif
945# ifndef PNG_NO_HANDLE_AS_UNKNOWN
946# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
947# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
948# endif
949# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600950#endif
951#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600952 defined(PNG_WRITE_zTXt_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600953# define PNG_WRITE_TEXT_SUPPORTED
954# ifndef PNG_TEXT_SUPPORTED
955# define PNG_TEXT_SUPPORTED
956# endif
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500957#endif
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600958
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600959#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500960
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600961/* Turn this off to disable png_read_png() and
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600962 * png_write_png() and leave the row_pointers member
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600963 * out of the info structure.
964 */
965#ifndef PNG_NO_INFO_IMAGE
966# define PNG_INFO_IMAGE_SUPPORTED
967#endif
968
Andreas Dilger47a0c421997-05-16 02:46:07 -0500969/* need the time information for reading tIME chunks */
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600970#if defined(PNG_tIME_SUPPORTED)
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500971# if !defined(_WIN32_WCE)
972 /* "time.h" functions are not supported on WindowsCE */
973# include <time.h>
974# endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500975#endif
976
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600977/* Some typedefs to get us started. These should be safe on most of the
Andreas Dilger47a0c421997-05-16 02:46:07 -0500978 * common platforms. The typedefs should be at least as large as the
979 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
980 * don't have to be exactly that size. Some compilers dislike passing
981 * unsigned shorts as function parameters, so you may be better off using
982 * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may
983 * want to have unsigned int for png_uint_32 instead of unsigned long.
984 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500985
986typedef unsigned long png_uint_32;
987typedef long png_int_32;
988typedef unsigned short png_uint_16;
989typedef short png_int_16;
990typedef unsigned char png_byte;
991
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600992/* This is usually size_t. It is typedef'ed just in case you need it to
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500993 change (I'm not sure if you will or not, so I thought I'd be safe) */
994typedef size_t png_size_t;
995
Andreas Dilger47a0c421997-05-16 02:46:07 -0500996/* The following is needed for medium model support. It cannot be in the
997 * PNG_INTERNAL section. Needs modification for other compilers besides
998 * MSC. Model independent support declares all arrays and pointers to be
999 * large using the far keyword. The zlib version used must also support
1000 * model independent data. As of version zlib 1.0.4, the necessary changes
1001 * have been made in zlib. The USE_FAR_KEYWORD define triggers other
1002 * changes that are needed. (Tim Wegner)
1003 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001004
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001005/* Separate compiler dependencies (problem here is that zlib.h always
1006 defines FAR. (SJT) */
Guy Schalnat6d764711995-12-19 03:22:19 -06001007#ifdef __BORLANDC__
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001008# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
1009# define LDATA 1
1010# else
1011# define LDATA 0
1012# endif
1013 /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
1014# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
1015# define PNG_MAX_MALLOC_64K
1016# if (LDATA != 1)
1017# ifndef FAR
1018# define FAR __far
1019# endif
1020# define USE_FAR_KEYWORD
1021# endif /* LDATA != 1 */
1022 /* Possibly useful for moving data out of default segment.
1023 * Uncomment it if you want. Could also define FARDATA as
1024 * const if your compiler supports it. (SJT)
1025# define FARDATA FAR
1026 */
1027# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
Guy Schalnatb2e01bd1996-01-26 01:38:47 -06001028#endif /* __BORLANDC__ */
Guy Schalnat6d764711995-12-19 03:22:19 -06001029
1030
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001031/* Suggest testing for specific compiler first before testing for
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001032 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
1033 * making reliance oncertain keywords suspect. (SJT)
1034 */
Guy Schalnat6d764711995-12-19 03:22:19 -06001035
1036/* MSC Medium model */
1037#if defined(FAR)
1038# if defined(M_I86MM)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001039# define USE_FAR_KEYWORD
1040# define FARDATA FAR
1041# include <dos.h>
Guy Schalnat6d764711995-12-19 03:22:19 -06001042# endif
1043#endif
1044
1045/* SJT: default case */
1046#ifndef FAR
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001047# define FAR
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001048#endif
1049
Andreas Dilger47a0c421997-05-16 02:46:07 -05001050/* At this point FAR is always defined */
Guy Schalnat6d764711995-12-19 03:22:19 -06001051#ifndef FARDATA
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001052# define FARDATA
Guy Schalnat6d764711995-12-19 03:22:19 -06001053#endif
1054
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001055/* Typedef for floating-point numbers that are converted
1056 to fixed-point with a multiple of 100,000, e.g., int_gamma */
1057typedef png_int_32 png_fixed_point;
1058
Andreas Dilger47a0c421997-05-16 02:46:07 -05001059/* Add typedefs for pointers */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001060typedef void FAR * png_voidp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001061typedef png_byte FAR * png_bytep;
1062typedef png_uint_32 FAR * png_uint_32p;
1063typedef png_int_32 FAR * png_int_32p;
1064typedef png_uint_16 FAR * png_uint_16p;
1065typedef png_int_16 FAR * png_int_16p;
1066typedef PNG_CONST char FAR * png_const_charp;
1067typedef char FAR * png_charp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001068typedef png_fixed_point FAR * png_fixed_point_p;
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001069
1070#ifndef PNG_NO_STDIO
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -05001071#if defined(_WIN32_WCE)
1072typedef HANDLE png_FILE_p;
1073#else
1074typedef FILE * png_FILE_p;
1075#endif
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001076#endif
1077
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001078#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001079typedef double FAR * png_doublep;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001080#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001081
Andreas Dilger47a0c421997-05-16 02:46:07 -05001082/* Pointers to pointers; i.e. arrays */
Guy Schalnat6d764711995-12-19 03:22:19 -06001083typedef png_byte FAR * FAR * png_bytepp;
1084typedef png_uint_32 FAR * FAR * png_uint_32pp;
1085typedef png_int_32 FAR * FAR * png_int_32pp;
1086typedef png_uint_16 FAR * FAR * png_uint_16pp;
1087typedef png_int_16 FAR * FAR * png_int_16pp;
1088typedef PNG_CONST char FAR * FAR * png_const_charpp;
1089typedef char FAR * FAR * png_charpp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001090typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001091#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001092typedef double FAR * FAR * png_doublepp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001093#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001094
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001095/* Pointers to pointers to pointers; i.e., pointer to array */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001096typedef char FAR * FAR * FAR * png_charppp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001097
Andreas Dilger47a0c421997-05-16 02:46:07 -05001098/* libpng typedefs for types in zlib. If zlib changes
1099 * or another compression library is used, then change these.
1100 * Eliminates need to change all the source files.
1101 */
Guy Schalnat6d764711995-12-19 03:22:19 -06001102typedef charf * png_zcharp;
1103typedef charf * FAR * png_zcharpp;
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001104typedef z_stream FAR * png_zstreamp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001105
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001106/*
1107 * Define PNG_BUILD_DLL if the module being built is a Windows
1108 * LIBPNG DLL.
1109 *
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001110 * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL.
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -06001111 * It is equivalent to Microsoft predefined macro _DLL that is
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001112 * automatically defined when you compile using the share
1113 * version of the CRT (C Run-Time library)
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001114 *
1115 * The cygwin mods make this behavior a little different:
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001116 * Define PNG_BUILD_DLL if you are building a dll for use with cygwin
1117 * Define PNG_STATIC if you are building a static library for use with cygwin,
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001118 * -or- if you are building an application that you want to link to the
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001119 * static library.
1120 * PNG_USE_DLL is defined by default (no user action needed) unless one of
1121 * the other flags is defined.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001122 */
1123
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001124#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001125# define PNG_DLL
1126#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001127/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib.
1128 * When building a static lib, default to no GLOBAL ARRAYS, but allow
1129 * command-line override
1130 */
1131#if defined(__CYGWIN__)
1132# if !defined(PNG_STATIC)
1133# if defined(PNG_USE_GLOBAL_ARRAYS)
1134# undef PNG_USE_GLOBAL_ARRAYS
1135# endif
1136# if !defined(PNG_USE_LOCAL_ARRAYS)
1137# define PNG_USE_LOCAL_ARRAYS
1138# endif
1139# else
1140# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS)
1141# if defined(PNG_USE_GLOBAL_ARRAYS)
1142# undef PNG_USE_GLOBAL_ARRAYS
1143# endif
1144# endif
1145# endif
1146# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
1147# define PNG_USE_LOCAL_ARRAYS
1148# endif
1149#endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001150
Glenn Randers-Pehrsonec61c232000-05-16 06:17:36 -05001151/* Do not use global arrays (helps with building DLL's)
1152 * They are no longer used in libpng itself, since version 1.0.5c,
1153 * but might be required for some pre-1.0.5c applications.
1154 */
1155#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
1156# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL))
1157# define PNG_USE_LOCAL_ARRAYS
1158# else
1159# define PNG_USE_GLOBAL_ARRAYS
1160# endif
1161#endif
1162
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001163#if defined(__CYGWIN__)
1164# undef PNGAPI
1165# define PNGAPI __cdecl
1166# undef PNG_IMPEXP
1167# define PNG_IMPEXP
1168#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001169
Glenn Randers-Pehrson25d82242002-05-01 11:51:26 -05001170/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
1171 * you may get warnings regarding the linkage of png_zalloc and png_zfree.
1172 * Don't ignore those warnings; you must also reset the default calling
1173 * convention in your compiler to match your PNGAPI, and you must build
1174 * zlib and your applications the same way you build libpng.
1175 */
1176
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001177#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001178# ifndef PNG_NO_MODULEDEF
1179# define PNG_NO_MODULEDEF
1180# endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001181#endif
1182
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001183#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001184# define PNG_IMPEXP
1185#endif
1186
1187#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001188 (( defined(_Windows) || defined(_WINDOWS) || \
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -05001189 defined(WIN32) || defined(_WIN32) || defined(__WIN32__) ))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001190
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001191# ifndef PNGAPI
1192# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
1193# define PNGAPI __cdecl
1194# else
1195# define PNGAPI _cdecl
1196# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001197# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001198
1199# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \
1200 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */)
1201# define PNG_IMPEXP
1202# endif
1203
1204# if !defined(PNG_IMPEXP)
1205
1206# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol
1207# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol
1208
1209 /* Borland/Microsoft */
1210# if defined(_MSC_VER) || defined(__BORLANDC__)
1211# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
1212# define PNG_EXPORT PNG_EXPORT_TYPE1
1213# else
1214# define PNG_EXPORT PNG_EXPORT_TYPE2
1215# if defined(PNG_BUILD_DLL)
1216# define PNG_IMPEXP __export
1217# else
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -05001218# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in
1219 VC++ */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001220# endif /* Exists in Borland C++ for
1221 C++ classes (== huge) */
1222# endif
1223# endif
1224
1225# if !defined(PNG_IMPEXP)
1226# if defined(PNG_BUILD_DLL)
1227# define PNG_IMPEXP __declspec(dllexport)
1228# else
1229# define PNG_IMPEXP __declspec(dllimport)
1230# endif
1231# endif
1232# endif /* PNG_IMPEXP */
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001233#else /* !(DLL || non-cygwin WINDOWS) */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001234# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
1235# ifndef PNGAPI
1236# define PNGAPI _System
Glenn Randers-Pehrsonf64a06f2001-04-11 07:38:00 -05001237# endif
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001238# else
1239# if 0 /* ... other platforms, with other meanings */
1240# endif
1241# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001242#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001243
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -06001244#ifndef PNGAPI
1245# define PNGAPI
1246#endif
1247#ifndef PNG_IMPEXP
1248# define PNG_IMPEXP
1249#endif
1250
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -05001251#ifndef PNG_EXPORT
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001252# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001253#endif
1254
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001255#ifdef PNG_USE_GLOBAL_ARRAYS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001256# ifndef PNG_EXPORT_VAR
1257# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type
1258# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001259#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001260
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001261/* User may want to use these so they are not in PNG_INTERNAL. Any library
1262 * functions that are passed far data must be model independent.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001263 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001264
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001265#ifndef PNG_ABORT
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001266# define PNG_ABORT() abort()
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001267#endif
1268
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001269#ifdef PNG_SETJMP_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001270# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06001271#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001272# define png_jmpbuf(png_ptr) \
1273 (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED)
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001274#endif
1275
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001276#if defined(USE_FAR_KEYWORD) /* memory model independent fns */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001277/* use this to make far-to-near assignments */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001278# define CHECK 1
1279# define NOCHECK 0
1280# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
1281# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001282# define png_strcpy _fstrcpy
1283# define png_strncpy _fstrncpy /* Added to v 1.2.6 */
1284# define png_strlen _fstrlen
1285# define png_memcmp _fmemcmp /* SJT: added */
1286# define png_memcpy _fmemcpy
1287# define png_memset _fmemset
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001288#else /* use the usual functions */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001289# define CVT_PTR(ptr) (ptr)
1290# define CVT_PTR_NOCHECK(ptr) (ptr)
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001291# define png_strcpy strcpy
1292# define png_strncpy strncpy /* Added to v 1.2.6 */
1293# define png_strlen strlen
1294# define png_memcmp memcmp /* SJT: added */
1295# define png_memcpy memcpy
1296# define png_memset memset
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001297#endif
1298/* End of memory model independent support */
1299
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001300/* Just a little check that someone hasn't tried to define something
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001301 * contradictory.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001302 */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001303#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001304# undef PNG_ZBUF_SIZE
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001305# define PNG_ZBUF_SIZE 65536L
Andreas Dilger47a0c421997-05-16 02:46:07 -05001306#endif
1307
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06001308#ifdef PNG_READ_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001309/* Prior to libpng-1.0.9, this block was in pngasmrd.h */
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06001310#if defined(PNG_INTERNAL)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001311
1312/* These are the default thresholds before the MMX code kicks in; if either
1313 * rowbytes or bitdepth is below the threshold, plain C code is used. These
1314 * can be overridden at runtime via the png_set_mmx_thresholds() call in
Glenn Randers-Pehrsoncdf140b2001-01-15 12:22:32 -06001315 * libpng 1.2.0 and later. The values below were chosen by Intel.
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001316 */
1317
1318#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT
1319# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */
1320#endif
1321#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT
1322# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */
1323#endif
1324
1325/* Set this in the makefile for VC++ on Pentium, not here. */
1326/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c .
1327 * MMX will be detected at run time and used if present.
1328 */
1329#ifdef PNG_USE_PNGVCRD
1330# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
1331# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
1332# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
1333#endif
1334
1335/* Set this in the makefile for gcc/as on Pentium, not here. */
1336/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c .
1337 * MMX will be detected at run time and used if present.
1338 */
1339#ifdef PNG_USE_PNGGCCRD
1340# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
1341# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
1342# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
1343#endif
1344/* - see pnggccrd.c for info about what is currently enabled */
1345
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06001346#endif /* PNG_INTERNAL */
1347#endif /* PNG_READ_SUPPORTED */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001348
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001349#endif /* PNGCONF_H */
1350