home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / POV-Ray 3.0.2 / src / SOURCE / LIBPNG / PNGCONF.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-16  |  12.6 KB  |  391 lines  |  [TEXT/CWIE]

  1.  
  2. /* pngconf.c - machine configurable file for libpng
  3.  
  4.    libpng 1.0 beta 4 - version 0.90
  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.    December 3, 1996
  8.    */
  9.  
  10. /* Any machine specific code is near the front of this file, so if you
  11.    are configuring libpng for a machine, you may want to read the section
  12.    starting here down to where it starts to typedef png_color, png_text,
  13.    and png_info */
  14.  
  15. #ifndef PNGCONF_H
  16. #define PNGCONF_H
  17.  
  18. /* This is the size of the compression buffer, and thus the size of
  19.    an IDAT chunk.  Make this whatever size you feel is best for your
  20.    machine.  One of these will be allocated per png_struct.  When this
  21.    is full, it writes the data to the disk, and does some other
  22.    calculations.  Making this an extreamly small size will slow
  23.    the library down, but you may want to experiment to determine
  24.    where it becomes significant, if you are concerned with memory
  25.    usage.  Note that zlib allocates at least 32Kb also.  For readers,
  26.    this describes the size of the buffer available to read the data in.
  27.    Unless this gets smaller then the size of a row (compressed),
  28.    it should not make much difference how big this is.  */
  29.  
  30. #define PNG_ZBUF_SIZE 8192
  31.  
  32. /* If you are running on a machine where you cannot allocate more then
  33.    64K of memory, uncomment this.  While libpng will not normally need
  34.    that much memory in a chunk (unless you load up a very large file),
  35.    zlib needs to know how big of a chunk it can use, and libpng thus
  36.    makes sure to check any memory allocation to verify it will fit
  37.    into memory.
  38. #define PNG_MAX_ALLOC_64K
  39. */
  40. #ifdef MAXSEG_64K
  41. #define PNG_MAX_ALLOC_64K
  42. #endif
  43.  
  44. /* This protects us against compilers which run on a windowing system
  45.    and thus don't have or would rather us not use the stdio types:
  46.    stdin, stdout, and stderr.  The only one currently used is stderr
  47.    in png_error() and png_warning().  #defining PNG_NO_STDIO will
  48.    prevent these from being compiled and used. */
  49.  
  50. /* #define PNG_NO_STDIO */
  51.  
  52. /* for FILE.  If you are not using standard io, you don't need this */
  53. #ifndef PNG_NO_STDIO
  54. #include <stdio.h>
  55. #endif
  56.  
  57. /* This macro protects us against machines that don't have function
  58.    prototypes (ie K&R style headers).  If your compiler does not handle
  59.    function prototypes, define this macro.  I've always been able to use
  60.    _NO_PROTO as the indicator, but you may need to drag the empty declaration
  61.    out in front of here, or change the ifdef to suit your own needs. */
  62. #ifndef PNGARG
  63.  
  64. #ifdef OF /* Zlib prototype munger */
  65. #define PNGARG(arglist) OF(arglist)
  66. #else
  67.  
  68. #ifdef _NO_PROTO
  69. #define PNGARG(arglist) ()
  70. #else
  71. #define PNGARG(arglist) arglist
  72. #endif /* _NO_PROTO */
  73.  
  74. #endif /* OF */
  75.  
  76. #endif /* PNGARG */
  77.  
  78. /* Try to determine if we are compiling on a Mac */
  79. #if defined(__MWERKS__) ||defined(applec) ||defined(THINK_C) ||defined(__SC__)
  80. #define MACOS
  81. #endif
  82.  
  83. /* enough people need this for various reasons to include it here */
  84. #if !defined(MACOS) && !defined(RISCOS)
  85. #include <sys/types.h>
  86. #endif
  87.  
  88. /* need the time information for reading tIME chunks */
  89. #include <time.h>
  90.  
  91. /* This is an attempt to force a single setjmp behaviour on Linux */
  92. #ifdef linux
  93. #ifdef _BSD_SOURCE
  94. #define _PNG_SAVE_BSD_SOURCE
  95. #undef _BSD_SOURCE
  96. #endif
  97. #ifdef _SETJMP_H
  98. error: png.h already includes setjmp.h
  99. #endif
  100. #endif /* linux */
  101.  
  102. /* include setjmp.h for error handling */
  103. #include <setjmp.h>
  104.  
  105. #ifdef linux
  106. #ifdef _PNG_SAVE_BSD_SOURCE
  107. #define _BSD_SOURCE
  108. #undef _PNG_SAVE_BSD_SOURCE
  109. #endif
  110. #endif /* linux */
  111.  
  112. #ifdef BSD
  113. #include <strings.h>
  114. #else
  115. #include <string.h>
  116. #endif
  117.  
  118. /* Other defines for things like memory and the like can go here.  These
  119.    are the only files included in libpng, so if you need to change them,
  120.    change them here.  They are only included if PNG_INTERNAL is defined. */
  121. #ifdef PNG_INTERNAL
  122. #include <stdlib.h>
  123. #include <ctype.h>
  124.  
  125. /* Other defines specific to compilers can go here.  Try to keep
  126.    them inside an appropriate ifdef/endif pair for portability */
  127.  
  128. #ifdef MACOS
  129. #include <fp.h>
  130. #else
  131. #include <math.h>
  132. #endif
  133.  
  134. /* For some reason, Borland C++ defines memcmp, etc. in mem.h, not
  135.    stdlib.h like it should (I think).  Or perhaps this is a C++
  136.    feature? */
  137. #ifdef __TURBOC__
  138. #include <mem.h>
  139. #include "alloc.h"
  140. #endif
  141.  
  142. #ifdef _MSC_VER
  143. #include <malloc.h>
  144. #endif
  145.  
  146. /* This controls how fine the dithering gets.  As this allocates
  147.    a largish chunk of memory (32K), those who are not as concerned
  148.    with dithering quality can decrease some or all of these. */
  149. #define PNG_DITHER_RED_BITS 5
  150. #define PNG_DITHER_GREEN_BITS 5
  151. #define PNG_DITHER_BLUE_BITS 5
  152.  
  153. /* This controls how fine the gamma correction becomes when you
  154.    are only interested in 8 bits anyway.  Increasing this value
  155.    results in more memory being used, and more pow() functions
  156.    being called to fill in the gamma tables.  Don't set this
  157.    value less then 8, and even that may not work (I haven't tested
  158.    it). */
  159.  
  160. #define PNG_MAX_GAMMA_8 11
  161.  
  162. #endif /* PNG_INTERNAL */
  163.  
  164. /* The following uses const char * instead of char * for error
  165.    and warning message functions, so some compilers won't complain.
  166.    If you want to use const, define PNG_USE_CONST here.  It is not
  167.    normally defined to make configuration easier, as it is not a
  168.    critical part of the code.
  169.    */
  170.  
  171. #define PNG_USE_CONST
  172.  
  173. #ifdef PNG_USE_CONST
  174. #  define PNG_CONST const
  175. #else
  176. #  define PNG_CONST
  177. #endif
  178.  
  179. /* The following defines give you the ability to remove code from the
  180.    library that you will not be using.  I wish I could figure out how to
  181.    automate this, but I can't do that without making it seriously hard
  182.    on the users.  So if you are not using an ability, change the #define
  183.    to and #undef, and that part of the library will not be compiled.  If
  184.    your linker can't find a function, you may want to make sure the
  185.    ability is defined here.  Some of these depend upon some others being
  186.    defined.  I haven't figured out all the interactions here, so you may
  187.    have to experiment awhile to get everything to compile.  If you are
  188.    creating or using a shared library, you probably shouldn't touch this,
  189.    as it will affect the size of the structures, and this will cause bad
  190.    things to happen if the library and/or application ever change. */
  191.  
  192. /* Any transformations you will not be using can be undef'ed here */
  193. #define PNG_PROGRESSIVE_READ_SUPPORTED
  194. #define PNG_READ_INTERLACING_SUPPORTED
  195. #define PNG_READ_EXPAND_SUPPORTED
  196. #define PNG_READ_SHIFT_SUPPORTED
  197. #define PNG_READ_PACK_SUPPORTED
  198. #define PNG_READ_BGR_SUPPORTED
  199. #define PNG_READ_SWAP_SUPPORTED
  200. #define PNG_READ_INVERT_SUPPORTED
  201. #define PNG_READ_DITHER_SUPPORTED
  202. #define PNG_READ_BACKGROUND_SUPPORTED
  203. #define PNG_READ_16_TO_8_SUPPORTED
  204. #define PNG_READ_FILLER_SUPPORTED
  205. #define PNG_READ_GAMMA_SUPPORTED
  206. #define PNG_READ_GRAY_TO_RGB_SUPPORTED
  207.  
  208. #define PNG_WRITE_INTERLACING_SUPPORTED
  209. #define PNG_WRITE_SHIFT_SUPPORTED
  210. #define PNG_WRITE_PACK_SUPPORTED
  211. #define PNG_WRITE_BGR_SUPPORTED
  212. #define PNG_WRITE_SWAP_SUPPORTED
  213. #define PNG_WRITE_INVERT_SUPPORTED
  214. #define PNG_WRITE_FILLER_SUPPORTED
  215. #define PNG_WRITE_FLUSH_SUPPORTED
  216.  
  217. /* These functions are turned off by default, as they will be phased out. */
  218. #undef  PNG_USE_OWN_CRC
  219. #undef  PNG_CORRECT_PALETTE_SUPPORTED
  220.  
  221. /* any chunks you are not interested in, you can undef here.  The
  222.    ones that allocate memory may be expecially important (hIST,
  223.    tEXt, zTXt, tRNS) Others will just save time and make png_info
  224.    smaller.  OPT_PLTE only disables the optional palette in RGB
  225.    and RGB Alpha images. */
  226.  
  227. #define PNG_READ_gAMA_SUPPORTED
  228. #define PNG_READ_sBIT_SUPPORTED
  229. #define PNG_READ_cHRM_SUPPORTED
  230. #define PNG_READ_tRNS_SUPPORTED
  231. #define PNG_READ_bKGD_SUPPORTED
  232. #define PNG_READ_hIST_SUPPORTED
  233. #define PNG_READ_pHYs_SUPPORTED
  234. #define PNG_READ_oFFs_SUPPORTED
  235. #define PNG_READ_tIME_SUPPORTED
  236. #define PNG_READ_tEXt_SUPPORTED
  237. #define PNG_READ_zTXt_SUPPORTED
  238. #define PNG_READ_OPT_PLTE_SUPPORTED
  239.  
  240. #define PNG_WRITE_gAMA_SUPPORTED
  241. #define PNG_WRITE_sBIT_SUPPORTED
  242. #define PNG_WRITE_cHRM_SUPPORTED
  243. #define PNG_WRITE_tRNS_SUPPORTED
  244. #define PNG_WRITE_bKGD_SUPPORTED
  245. #define PNG_WRITE_hIST_SUPPORTED
  246. #define PNG_WRITE_pHYs_SUPPORTED
  247. #define PNG_WRITE_oFFs_SUPPORTED
  248. #define PNG_WRITE_tIME_SUPPORTED
  249. #define PNG_WRITE_tEXt_SUPPORTED
  250. #define PNG_WRITE_zTXt_SUPPORTED
  251.  
  252. /* Some typedefs to get us started.  These should be safe on most of the
  253.    common platforms.  The typedefs should be at least as large as the
  254.    numbers suggest (a png_uint_32 must be at least 32 bits long), but they
  255.    don't have to be exactly that size. */
  256.  
  257. typedef unsigned long png_uint_32;
  258. typedef long png_int_32;
  259. typedef unsigned short png_uint_16;
  260. typedef short png_int_16;
  261. typedef unsigned char png_byte;
  262.  
  263. /* This is usually size_t.  It is typedef'ed just in case you need it to
  264.    change (I'm not sure if you will or not, so I thought I'd be safe) */
  265. typedef size_t png_size_t;
  266.  
  267. /* The following is needed for medium model support. It cannot be in the
  268.    PNG_INTERNAL section. Needs modification for other compilers besides
  269.    MSC. Model independent support declares all arrays that might be very
  270.    large using the far keyword. The Zlib version used must also support
  271.    model independent data. As of version Zlib .95, the necessary changes
  272.    have been made in Zlib. The USE_FAR_KEYWORD define triggers other
  273.    changes that are needed. Most of the far keyword changes are hidden
  274.    inside typedefs with suffix "f". (Tim Wegner) */
  275.  
  276. /* Separate compiler dependencies (problem here is that zlib.h always
  277.    defines FAR. (SJT) */
  278. #ifdef __BORLANDC__
  279. #if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
  280. #define LDATA 1
  281. #else
  282. #define LDATA 0
  283. #endif
  284.  
  285. #if !defined(__WIN32__) && !defined(__FLAT__)
  286. #define PNG_MAX_MALLOC_64K
  287. #if (LDATA != 1)
  288. #ifndef FAR
  289. #define FAR __far
  290. #endif
  291. #define USE_FAR_KEYWORD
  292. #endif   /* LDATA != 1 */
  293.  
  294. /* Possibly useful for moving data out of default segment.
  295.    Uncomment it if you want. Could also define FARDATA as
  296.    const if your compiler supports it. (SJT)
  297. #  define FARDATA FAR
  298. */
  299. #endif  /* __WIN32__, __FLAT__ */
  300.  
  301. #endif   /* __BORLANDC__ */
  302.  
  303.  
  304. /* Suggest testing for specific compiler first before testing for
  305.    FAR.  The Watcom compiler defines both __MEDIUM__ and M_I86MM,
  306.    making reliance oncertain keywords suspect. (SJT) */
  307.  
  308. /* MSC Medium model */
  309. #if defined(FAR)
  310. #  if defined(M_I86MM)
  311. #     define USE_FAR_KEYWORD
  312. #     define FARDATA FAR
  313. #     include <dos.h>
  314. #  endif
  315. #endif
  316.  
  317. /* SJT: default case */
  318. #ifndef FAR
  319. #   define FAR
  320. #endif
  321.  
  322. /* SJT: At this point FAR is always defined */
  323.  
  324. /* SJT: */
  325. #ifndef FARDATA
  326. #define FARDATA
  327. #endif
  328.  
  329. /* Not used anymore (as of 0.88), but kept for compatability (for now). */
  330. typedef unsigned char FAR png_bytef;
  331.  
  332. /* SJT: Add typedefs for pointers */
  333. typedef void            FAR * png_voidp;
  334. typedef png_byte        FAR * png_bytep;
  335. typedef png_uint_32     FAR * png_uint_32p;
  336. typedef png_int_32      FAR * png_int_32p;
  337. typedef png_uint_16     FAR * png_uint_16p;
  338. typedef png_int_16      FAR * png_int_16p;
  339. typedef PNG_CONST char  FAR * png_const_charp;
  340. typedef char            FAR * png_charp;
  341.  
  342. /*  SJT: Pointers to pointers; i.e. arrays */
  343. typedef png_byte        FAR * FAR * png_bytepp;
  344. typedef png_uint_32     FAR * FAR * png_uint_32pp;
  345. typedef png_int_32      FAR * FAR * png_int_32pp;
  346. typedef png_uint_16     FAR * FAR * png_uint_16pp;
  347. typedef png_int_16      FAR * FAR * png_int_16pp;
  348. typedef PNG_CONST char  FAR * FAR * png_const_charpp;
  349. typedef char            FAR * FAR * png_charpp;
  350.  
  351.  
  352. /* SJT: libpng typedefs for types in zlib. If Zlib changes
  353.    or another compression library is used, then change these.
  354.    Eliminates need to change all the source files.
  355. */
  356. typedef charf *         png_zcharp;
  357. typedef charf * FAR *   png_zcharpp;
  358. typedef z_stream FAR *  png_zstreamp; 
  359.  
  360. /* User may want to use these so not in PNG_INTERNAL. Any library functions
  361.    that are passed far data must be model independent. */
  362.  
  363. #if defined(USE_FAR_KEYWORD)  /* memory model independent fns */
  364. /* use this to make far-to-near assignments */
  365. #   define CHECK   1
  366. #   define NOCHECK 0
  367. #   define CVT_PTR(ptr) (far_to_near(png_ptr,ptr,CHECK))
  368. #   define CVT_PTR_NOCHECK(ptr) (far_to_near(png_ptr,ptr,NOCHECK))
  369. #   define png_strcpy _fstrcpy
  370. #   define png_strcat _fstrcat
  371. #   define png_strlen _fstrlen
  372. #   define png_strcmp _fstrcmp
  373. #   define png_memcmp _fmemcmp      /* SJT: added */
  374. #   define png_memcpy _fmemcpy
  375. #   define png_memset _fmemset
  376. #else /* use the usual functions */
  377. #   define CVT_PTR(ptr)         (ptr)
  378. #   define CVT_PTR_NOCHECK(ptr) (ptr)
  379. #   define png_strcpy strcpy
  380. #   define png_strcat strcat
  381. #   define png_strlen strlen
  382. #   define png_strcmp strcmp
  383. #   define png_memcmp memcmp     /* SJT: added */
  384. #   define png_memcpy memcpy
  385. #   define png_memset memset
  386. #endif
  387. /* End of memory model independent support */
  388.  
  389. #endif /* PNGCONF_H */
  390.  
  391.