2 /* pngconf.h - machine configurable file for libpng
4 * libpng 1.0.3 - January 14, 1999
5 * For conditions of distribution and use, see copyright notice in png.h
6 * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
7 * Copyright (c) 1996, 1997 Andreas Dilger
8 * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
11 /* Any machine specific code is near the front of this file, so if you
12 * 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,
21 /* This is the size of the compression buffer, and thus the size of
22 * an IDAT chunk. Make this whatever size you feel is best for your
23 * machine. One of these will be allocated per png_struct. When this
24 * is full, it writes the data to the disk, and does some other
25 * calculations. Making this an extremely small size will slow
26 * the library down, but you may want to experiment to determine
27 * where it becomes significant, if you are concerned with memory
28 * usage. Note that zlib allocates at least 32Kb also. For readers,
29 * this describes the size of the buffer available to read the data in.
30 * Unless this gets smaller than the size of a row (compressed),
31 * it should not make much difference how big this is.
35 #define PNG_ZBUF_SIZE 8192
38 /* If you are running on a machine where you cannot allocate more
39 * than 64K of memory at once, uncomment this. While libpng will not
40 * normally need that much memory in a chunk (unless you load up a very
41 * large file), zlib needs to know how big of a chunk it can use, and
42 * libpng thus makes sure to check any memory allocation to verify it
43 * will fit into memory.
44 #define PNG_MAX_MALLOC_64K
46 #if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
47 #define PNG_MAX_MALLOC_64K
50 /* This protects us against compilers that run on a windowing system
51 * and thus don't have or would rather us not use the stdio types:
52 * stdin, stdout, and stderr. The only one currently used is stderr
53 * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will
54 * prevent these from being compiled and used. #defining PNG_NO_STDIO
55 * will also prevent these, plus will prevent the entire set of stdio
56 * macros and functions (FILE *, printf, etc.) from being compiled and used,
57 * unless PNG_DEBUG has been #defined.
59 * #define PNG_NO_CONSOLE_IO
60 * #define PNG_NO_STDIO
69 # ifndef PNG_NO_CONSOLE_IO
70 # define PNG_NO_CONSOLE_IO
77 /* This macro protects us against machines that don't have function
78 * prototypes (ie K&R style headers). If your compiler does not handle
79 * function prototypes, define this macro and use the included ansi2knr.
80 * I've always been able to use _NO_PROTO as the indicator, but you may
81 * need to drag the empty declaration out in front of here, or change the
82 * ifdef to suit your own needs.
86 #ifdef OF /* zlib prototype munger */
87 #define PNGARG(arglist) OF(arglist)
91 #define PNGARG(arglist) ()
93 #define PNGARG(arglist) arglist
94 #endif /* _NO_PROTO */
100 /* Try to determine if we are compiling on a Mac. Note that testing for
101 * just __MWERKS__ is not good enough, because the Codewarrior is now used
102 * on non-Mac platforms.
105 #if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
106 defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
111 /* enough people need this for various reasons to include it here */
112 #if !defined(MACOS) && !defined(RISCOS)
113 #include <sys/types.h>
116 /* This is an attempt to force a single setjmp behaviour on Linux. If
117 * the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
121 #define _PNG_SAVE_BSD_SOURCE
125 __png
.h__ already includes setjmp
.h
126 __dont__ include it again
128 #endif /* __linux__ */
130 /* include setjmp.h for error handling */
134 #ifdef _PNG_SAVE_BSD_SOURCE
136 #undef _PNG_SAVE_BSD_SOURCE
138 #endif /* __linux__ */
146 /* Other defines for things like memory and the like can go here. */
150 /* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which
151 * aren't usually used outside the library (as far as I know), so it is
152 * debatable if they should be exported at all. In the future, when it is
153 * possible to have run-time registry of chunk-handling functions, some of
154 * these will be made available again.
155 #define PNG_EXTERN extern
159 /* Other defines specific to compilers can go here. Try to keep
160 * them inside an appropriate ifdef/endif pair for portability.
164 /* We need to check that <math.h> hasn't already been included earlier
165 * as it seems it doesn't agree with <fp.h>, yet we should really use
166 * <fp.h> if possible.
168 #if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
175 /* Codewarrior on NT has linking problems without this. */
176 #if defined(__MWERKS__) && defined(WIN32)
177 #define PNG_ALWAYS_EXTERN
180 /* For some reason, Borland C++ defines memcmp, etc. in mem.h, not
181 * stdlib.h like it should (I think). Or perhaps this is a C++
193 /* This controls how fine the dithering gets. As this allocates
194 * a largish chunk of memory (32K), those who are not as concerned
195 * with dithering quality can decrease some or all of these.
197 #ifndef PNG_DITHER_RED_BITS
198 #define PNG_DITHER_RED_BITS 5
200 #ifndef PNG_DITHER_GREEN_BITS
201 #define PNG_DITHER_GREEN_BITS 5
203 #ifndef PNG_DITHER_BLUE_BITS
204 #define PNG_DITHER_BLUE_BITS 5
207 /* This controls how fine the gamma correction becomes when you
208 * are only interested in 8 bits anyway. Increasing this value
209 * results in more memory being used, and more pow() functions
210 * being called to fill in the gamma tables. Don't set this value
211 * less then 8, and even that may not work (I haven't tested it).
214 #ifndef PNG_MAX_GAMMA_8
215 #define PNG_MAX_GAMMA_8 11
218 /* This controls how much a difference in gamma we can tolerate before
219 * we actually start doing gamma conversion.
221 #ifndef PNG_GAMMA_THRESHOLD
222 #define PNG_GAMMA_THRESHOLD 0.05
225 #endif /* PNG_INTERNAL */
227 /* The following uses const char * instead of char * for error
228 * and warning message functions, so some compilers won't complain.
229 * If you do not want to use const, define PNG_NO_CONST here.
233 # define PNG_CONST const
238 /* The following defines give you the ability to remove code from the
239 * library that you will not be using. I wish I could figure out how to
240 * automate this, but I can't do that without making it seriously hard
241 * on the users. So if you are not using an ability, change the #define
242 * to and #undef, and that part of the library will not be compiled. If
243 * your linker can't find a function, you may want to make sure the
244 * ability is defined here. Some of these depend upon some others being
245 * defined. I haven't figured out all the interactions here, so you may
246 * have to experiment awhile to get everything to compile. If you are
247 * creating or using a shared library, you probably shouldn't touch this,
248 * as it will affect the size of the structures, and this will cause bad
249 * things to happen if the library and/or application ever change.
252 /* Any transformations you will not be using can be undef'ed here */
254 /* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
255 to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS
256 on the compile line, then pick and choose which ones to define without
257 having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED
258 if you only want to have a png-compliant reader/writer but don't need
259 any of the extra transformations. This saves about 80 kbytes in a
260 typical installation of the library. (PNG_NO_* form added in version
261 1.0.1c, for consistency)
265 #if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
266 !defined(PNG_NO_READ_TRANSFORMS)
267 #define PNG_READ_TRANSFORMS_SUPPORTED
269 #if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
270 !defined(PNG_NO_WRITE_TRANSFORMS)
271 #define PNG_WRITE_TRANSFORMS_SUPPORTED
274 #ifdef PNG_READ_TRANSFORMS_SUPPORTED
275 #ifndef PNG_NO_READ_EXPAND
276 #define PNG_READ_EXPAND_SUPPORTED
278 #ifndef PNG_NO_READ_SHIFT
279 #define PNG_READ_SHIFT_SUPPORTED
281 #ifndef PNG_NO_READ_PACK
282 #define PNG_READ_PACK_SUPPORTED
284 #ifndef PNG_NO_READ_BGR
285 #define PNG_READ_BGR_SUPPORTED
287 #ifndef PNG_NO_READ_SWAP
288 #define PNG_READ_SWAP_SUPPORTED
290 #ifndef PNG_NO_READ_PACKSWAP
291 #define PNG_READ_PACKSWAP_SUPPORTED
293 #ifndef PNG_NO_READ_INVERT
294 #define PNG_READ_INVERT_SUPPORTED
296 #ifndef PNG_NO_READ_DITHER
297 #define PNG_READ_DITHER_SUPPORTED
299 #ifndef PNG_NO_READ_BACKGROUND
300 #define PNG_READ_BACKGROUND_SUPPORTED
302 #ifndef PNG_NO_READ_16_TO_8
303 #define PNG_READ_16_TO_8_SUPPORTED
305 #ifndef PNG_NO_READ_FILLER
306 #define PNG_READ_FILLER_SUPPORTED
308 #ifndef PNG_NO_READ_GAMMA
309 #define PNG_READ_GAMMA_SUPPORTED
311 #ifndef PNG_NO_READ_GRAY_TO_RGB
312 #define PNG_READ_GRAY_TO_RGB_SUPPORTED
314 #ifndef PNG_NO_READ_SWAP_ALPHA
315 #define PNG_READ_SWAP_ALPHA_SUPPORTED
317 #ifndef PNG_NO_READ_INVERT_ALPHA
318 #define PNG_READ_INVERT_ALPHA_SUPPORTED
320 #ifndef PNG_NO_READ_STRIP_ALPHA
321 #define PNG_READ_STRIP_ALPHA_SUPPORTED
323 #ifndef PNG_NO_READ_USER_TRANSFORM
324 #define PNG_READ_USER_TRANSFORM_SUPPORTED
326 #ifndef PNG_NO_READ_RGB_TO_GRAY
327 #define PNG_READ_RGB_TO_GRAY_SUPPORTED
329 #endif /* PNG_READ_TRANSFORMS_SUPPORTED */
331 #if !defined(PNG_NO_PROGRESSIVE_READ) && \
332 !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
333 #define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
334 #endif /* about interlacing capability! You'll */
335 /* still have interlacing unless you change the following line: */
336 #define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
338 #ifndef PNG_NO_READ_COMPOSITED_NODIV
339 #define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel and SGI */
342 #ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
343 #ifndef PNG_NO_WRITE_SHIFT
344 #define PNG_WRITE_SHIFT_SUPPORTED
346 #ifndef PNG_NO_WRITE_PACK
347 #define PNG_WRITE_PACK_SUPPORTED
349 #ifndef PNG_NO_WRITE_BGR
350 #define PNG_WRITE_BGR_SUPPORTED
352 #ifndef PNG_NO_WRITE_SWAP
353 #define PNG_WRITE_SWAP_SUPPORTED
355 #ifndef PNG_NO_WRITE_PACKSWAP
356 #define PNG_WRITE_PACKSWAP_SUPPORTED
358 #ifndef PNG_NO_WRITE_INVERT
359 #define PNG_WRITE_INVERT_SUPPORTED
361 #ifndef PNG_NO_WRITE_FILLER
362 #define PNG_WRITE_FILLER_SUPPORTED /* This is the same as WRITE_STRIP_ALPHA */
364 #ifndef PNG_NO_WRITE_SWAP_ALPHA
365 #define PNG_WRITE_SWAP_ALPHA_SUPPORTED
367 #ifndef PNG_NO_WRITE_INVERT_ALPHA
368 #define PNG_WRITE_INVERT_ALPHA_SUPPORTED
370 #ifndef PNG_NO_WRITE_USER_TRANSFORM
371 #define PNG_WRITE_USER_TRANSFORM_SUPPORTED
373 #endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
375 #define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
376 encoders, but can cause trouble
379 #ifndef PNG_NO_WRITE_WEIGHTED_FILTER
380 #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
383 #ifndef PNG_NO_WRITE_FLUSH
384 #define PNG_WRITE_FLUSH_SUPPORTED
388 #define PNG_TIME_RFC1123_SUPPORTED
391 /* This adds extra functions in pngget.c for accessing data from the
392 * info pointer (added in version 0.99)
393 * png_get_image_width()
394 * png_get_image_height()
395 * png_get_bit_depth()
396 * png_get_color_type()
397 * png_get_compression_type()
398 * png_get_filter_type()
399 * png_get_interlace_type()
400 * png_get_pixel_aspect_ratio()
401 * png_get_pixels_per_meter()
402 * png_get_x_offset_pixels()
403 * png_get_y_offset_pixels()
404 * png_get_x_offset_microns()
405 * png_get_y_offset_microns()
407 #ifndef PNG_NO_EASY_ACCESS
408 #define PNG_EASY_ACCESS_SUPPORTED
411 /* These are currently experimental features, define them if you want */
413 /* very little testing */
415 #define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
416 #define PNG_USER_MEM_SUPPORTED
419 /* This is only for PowerPC big-endian and 680x0 systems */
422 #define PNG_READ_BIG_ENDIAN_SUPPORTED
425 /* These functions are turned off by default, as they will be phased out. */
427 #define PNG_USELESS_TESTS_SUPPORTED
428 #define PNG_CORRECT_PALETTE_SUPPORTED
431 /* Any chunks you are not interested in, you can undef here. The
432 * ones that allocate memory may be expecially important (hIST,
433 * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
437 #if !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
438 !defined(PNG_NO_READ_ANCILLARY_CHUNKS)
439 #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
441 #if !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
442 !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
443 #define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
446 #ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
447 #ifndef PNG_NO_READ_bKGD
448 #define PNG_READ_bKGD_SUPPORTED
450 #ifndef PNG_NO_READ_cHRM
451 #define PNG_READ_cHRM_SUPPORTED
453 #ifndef PNG_NO_READ_gAMA
454 #define PNG_READ_gAMA_SUPPORTED
456 #ifndef PNG_NO_READ_hIST
457 #define PNG_READ_hIST_SUPPORTED
459 #ifndef PNG_NO_READ_oFFs
460 #define PNG_READ_oFFs_SUPPORTED
462 #ifndef PNG_NO_READ_pCAL
463 #define PNG_READ_pCAL_SUPPORTED
465 #ifndef PNG_NO_READ_pHYs
466 #define PNG_READ_pHYs_SUPPORTED
468 #ifndef PNG_NO_READ_sBIT
469 #define PNG_READ_sBIT_SUPPORTED
471 #ifndef PNG_NO_READ_sRGB
472 #define PNG_READ_sRGB_SUPPORTED
474 #ifndef PNG_NO_READ_tEXt
475 #define PNG_READ_tEXt_SUPPORTED
477 #ifndef PNG_NO_READ_tIME
478 #define PNG_READ_tIME_SUPPORTED
480 #ifndef PNG_NO_READ_tRNS
481 #define PNG_READ_tRNS_SUPPORTED
483 #ifndef PNG_NO_READ_zTXt
484 #define PNG_READ_zTXt_SUPPORTED
486 #ifndef PNG_NO_READ_OPT_PLTE
487 #define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the optional */
488 #endif /* PLTE chunk in RGB and RGBA images */
489 #endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
491 #ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
492 #ifndef PNG_NO_WRITE_bKGD
493 #define PNG_WRITE_bKGD_SUPPORTED
495 #ifndef PNG_NO_WRITE_cHRM
496 #define PNG_WRITE_cHRM_SUPPORTED
498 #ifndef PNG_NO_WRITE_gAMA
499 #define PNG_WRITE_gAMA_SUPPORTED
501 #ifndef PNG_NO_WRITE_hIST
502 #define PNG_WRITE_hIST_SUPPORTED
504 #ifndef PNG_NO_WRITE_oFFs
505 #define PNG_WRITE_oFFs_SUPPORTED
507 #ifndef PNG_NO_WRITE_pCAL
508 #define PNG_WRITE_pCAL_SUPPORTED
510 #ifndef PNG_NO_WRITE_pHYs
511 #define PNG_WRITE_pHYs_SUPPORTED
513 #ifndef PNG_NO_WRITE_sBIT
514 #define PNG_WRITE_sBIT_SUPPORTED
516 #ifndef PNG_NO_WRITE_sRGB
517 #define PNG_WRITE_sRGB_SUPPORTED
519 #ifndef PNG_NO_WRITE_tEXt
520 #define PNG_WRITE_tEXt_SUPPORTED
522 #ifndef PNG_NO_WRITE_tIME
523 #define PNG_WRITE_tIME_SUPPORTED
525 #ifndef PNG_NO_WRITE_tRNS
526 #define PNG_WRITE_tRNS_SUPPORTED
528 #ifndef PNG_NO_WRITE_zTXt
529 #define PNG_WRITE_zTXt_SUPPORTED
531 #endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
533 /* need the time information for reading tIME chunks */
534 #if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
538 /* Some typedefs to get us started. These should be safe on most of the
539 * common platforms. The typedefs should be at least as large as the
540 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
541 * don't have to be exactly that size. Some compilers dislike passing
542 * unsigned shorts as function parameters, so you may be better off using
543 * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may
544 * want to have unsigned int for png_uint_32 instead of unsigned long.
547 typedef unsigned long png_uint_32
;
548 typedef long png_int_32
;
549 typedef unsigned short png_uint_16
;
550 typedef short png_int_16
;
551 typedef unsigned char png_byte
;
553 /* This is usually size_t. It is typedef'ed just in case you need it to
554 change (I'm not sure if you will or not, so I thought I'd be safe) */
555 typedef size_t png_size_t
;
557 /* The following is needed for medium model support. It cannot be in the
558 * PNG_INTERNAL section. Needs modification for other compilers besides
559 * MSC. Model independent support declares all arrays and pointers to be
560 * large using the far keyword. The zlib version used must also support
561 * model independent data. As of version zlib 1.0.4, the necessary changes
562 * have been made in zlib. The USE_FAR_KEYWORD define triggers other
563 * changes that are needed. (Tim Wegner)
566 /* Separate compiler dependencies (problem here is that zlib.h always
567 defines FAR. (SJT) */
569 #if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
575 #if !defined(__WIN32__) && !defined(__FLAT__)
576 #define PNG_MAX_MALLOC_64K
581 #define USE_FAR_KEYWORD
582 #endif /* LDATA != 1 */
584 /* Possibly useful for moving data out of default segment.
585 * Uncomment it if you want. Could also define FARDATA as
586 * const if your compiler supports it. (SJT)
589 #endif /* __WIN32__, __FLAT__ */
591 #endif /* __BORLANDC__ */
594 /* Suggest testing for specific compiler first before testing for
595 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
596 * making reliance oncertain keywords suspect. (SJT)
599 /* MSC Medium model */
601 # if defined(M_I86MM)
602 # define USE_FAR_KEYWORD
608 /* SJT: default case */
613 /* At this point FAR is always defined */
618 /* Add typedefs for pointers */
619 typedef void FAR
* png_voidp
;
620 typedef png_byte FAR
* png_bytep
;
621 typedef png_uint_32 FAR
* png_uint_32p
;
622 typedef png_int_32 FAR
* png_int_32p
;
623 typedef png_uint_16 FAR
* png_uint_16p
;
624 typedef png_int_16 FAR
* png_int_16p
;
625 typedef PNG_CONST
char FAR
* png_const_charp
;
626 typedef char FAR
* png_charp
;
627 typedef double FAR
* png_doublep
;
629 /* Pointers to pointers; i.e. arrays */
630 typedef png_byte FAR
* FAR
* png_bytepp
;
631 typedef png_uint_32 FAR
* FAR
* png_uint_32pp
;
632 typedef png_int_32 FAR
* FAR
* png_int_32pp
;
633 typedef png_uint_16 FAR
* FAR
* png_uint_16pp
;
634 typedef png_int_16 FAR
* FAR
* png_int_16pp
;
635 typedef PNG_CONST
char FAR
* FAR
* png_const_charpp
;
636 typedef char FAR
* FAR
* png_charpp
;
637 typedef double FAR
* FAR
* png_doublepp
;
639 /* Pointers to pointers to pointers; i.e. pointer to array */
640 typedef char FAR
* FAR
* FAR
* png_charppp
;
642 /* libpng typedefs for types in zlib. If zlib changes
643 * or another compression library is used, then change these.
644 * Eliminates need to change all the source files.
646 typedef charf
* png_zcharp
;
647 typedef charf
* FAR
* png_zcharpp
;
648 typedef z_stream FAR
* png_zstreamp
;
650 /* allow for compilation as dll under MS Windows */
652 #define PNG_EXPORT(type,symbol) __declspec(dllexport) type symbol
655 /* allow for compilation as dll with BORLAND C++ 5.0 */
656 #if defined(__BORLANDC__) && defined(_Windows) && defined(__DLL__)
657 # define PNG_EXPORT(type,symbol) type _export symbol
660 /* allow for compilation as shared lib under BeOS */
662 #define PNG_EXPORT(type,symbol) __declspec(export) type symbol
666 #define PNG_EXPORT(type,symbol) type symbol
670 /* User may want to use these so not in PNG_INTERNAL. Any library functions
671 * that are passed far data must be model independent.
674 #if defined(USE_FAR_KEYWORD) /* memory model independent fns */
675 /* use this to make far-to-near assignments */
678 # define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
679 # define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
680 # define png_strcpy _fstrcpy
681 # define png_strlen _fstrlen
682 # define png_memcmp _fmemcmp /* SJT: added */
683 # define png_memcpy _fmemcpy
684 # define png_memset _fmemset
685 #else /* use the usual functions */
686 # define CVT_PTR(ptr) (ptr)
687 # define CVT_PTR_NOCHECK(ptr) (ptr)
688 # define png_strcpy strcpy
689 # define png_strlen strlen
690 # define png_memcmp memcmp /* SJT: added */
691 # define png_memcpy memcpy
692 # define png_memset memset
694 /* End of memory model independent support */
696 /* Just a double check that someone hasn't tried to define something
699 #if (PNG_ZBUF_SIZE > 65536) && defined(PNG_MAX_MALLOC_64K)
701 #define PNG_ZBUF_SIZE 65536
704 #endif /* PNGCONF_H */