Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4758 right-hear 1
 
2
 *
3
 * libpng version 1.4.4 - September 23, 2010
4
 * For conditions of distribution and use, see copyright notice in png.h
5
 * Copyright (c) 1998-2010 Glenn Randers-Pehrson
6
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
7
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
8
 *
9
 * This code is released under the libpng license.
10
 * For conditions of distribution and use, see the disclaimer
11
 * and license in png.h
12
 *
13
 */
14
15
 
16
 * are configuring libpng for a machine, you may want to read the section
17
 * starting here down to where it starts to typedef png_color, png_text,
18
 * and png_info.
19
 */
20
21
 
22
#define PNGCONF_H
23
24
 
25
#  include 
26
#endif
27
28
 
29
30
 
31
 * script.
32
 */
33
#ifdef PNG_CONFIGURE_LIBPNG
34
#  ifdef HAVE_CONFIG_H
35
#    include "config.h"
36
#  endif
37
#endif
38
39
 
40
 * Added at libpng-1.2.8
41
 *
42
 * PNG_USER_CONFIG has to be defined on the compiler command line. This
43
 * includes the resource compiler for Windows DLL configurations.
44
 */
45
#ifdef PNG_USER_CONFIG
46
#  include "pngusr.h"
47
#  ifndef PNG_USER_PRIVATEBUILD
48
#    define PNG_USER_PRIVATEBUILD
49
#  endif
50
#endif
51
52
 
53
 * If you create a private DLL you should define in "pngusr.h" the following:
54
 * #define PNG_USER_PRIVATEBUILD 
55
 *        the DLL was built>
56
 *  e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
57
 * #define PNG_USER_DLLFNAME_POSTFIX 
58
 *        distinguish your DLL from those of the official release. These
59
 *        correspond to the trailing letters that come after the version
60
 *        number and must match your private DLL name>
61
 *  e.g. // private DLL "libpng14gx.dll"
62
 *       #define PNG_USER_DLLFNAME_POSTFIX "gx"
63
 *
64
 * The following macros are also at your disposal if you want to complete the
65
 * DLL VERSIONINFO structure.
66
 * - PNG_USER_VERSIONINFO_COMMENTS
67
 * - PNG_USER_VERSIONINFO_COMPANYNAME
68
 * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS
69
 */
70
71
 
72
#  ifdef SPECIALBUILD
73
#    pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\
74
     are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.")
75
#  endif
76
77
 
78
#    pragma message("PRIVATEBUILD is deprecated.\
79
     Use PNG_USER_PRIVATEBUILD instead.")
80
#    define PNG_USER_PRIVATEBUILD PRIVATEBUILD
81
#  endif
82
#endif /* __STDC__ */
83
84
 
85
86
 
87
88
 
89
 * an IDAT chunk.  Make this whatever size you feel is best for your
90
 * machine.  One of these will be allocated per png_struct.  When this
91
 * is full, it writes the data to the disk, and does some other
92
 * calculations.  Making this an extremely small size will slow
93
 * the library down, but you may want to experiment to determine
94
 * where it becomes significant, if you are concerned with memory
95
 * usage.  Note that zlib allocates at least 32Kb also.  For readers,
96
 * this describes the size of the buffer available to read the data in.
97
 * Unless this gets smaller than the size of a row (compressed),
98
 * it should not make much difference how big this is.
99
 */
100
101
 
102
#  define PNG_ZBUF_SIZE 8192
103
#endif
104
105
 
106
107
 
108
#  define PNG_READ_SUPPORTED
109
#endif
110
111
 
112
113
 
114
#  define PNG_WRITE_SUPPORTED
115
#endif
116
117
 
118
#ifdef PNG_ALLOW_BENIGN_ERRORS
119
#  define png_benign_error png_warning
120
#  define png_chunk_benign_error png_chunk_warning
121
#else
122
#  ifndef PNG_BENIGN_ERRORS_SUPPORTED
123
#    define png_benign_error png_error
124
#    define png_chunk_benign_error png_chunk_error
125
#  endif
126
#endif
127
128
 
129
#if !defined(PNG_NO_WARNINGS) && !defined(PNG_WARNINGS_SUPPORTED)
130
#  define PNG_WARNINGS_SUPPORTED
131
#endif
132
133
 
134
#if !defined(PNG_NO_ERROR_TEXT) && !defined(PNG_ERROR_TEXT_SUPPORTED)
135
#  define PNG_ERROR_TEXT_SUPPORTED
136
#endif
137
138
 
139
#if !defined(PNG_NO_CHECK_cHRM) && !defined(PNG_CHECK_cHRM_SUPPORTED)
140
#  define PNG_CHECK_cHRM_SUPPORTED
141
#endif
142
143
 
144
#if !defined(PNG_NO_ALIGNED_MEMORY) && !defined(PNG_ALIGNED_MEMORY_SUPPORTED)
145
#  define PNG_ALIGNED_MEMORY_SUPPORTED
146
#endif
147
148
 
149
   support PNGs that are embedded in MNG datastreams */
150
#ifndef PNG_NO_MNG_FEATURES
151
#  ifndef PNG_MNG_FEATURES_SUPPORTED
152
#    define PNG_MNG_FEATURES_SUPPORTED
153
#  endif
154
#endif
155
156
 
157
#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
158
#  ifndef PNG_FLOATING_POINT_SUPPORTED
159
#    define PNG_FLOATING_POINT_SUPPORTED
160
#  endif
161
#endif
162
163
 
164
   in libpng and png_calloc() is always present)
165
 */
166
#define PNG_CALLOC_SUPPORTED
167
168
 
169
 * than 64K of memory at once, uncomment this.  While libpng will not
170
 * normally need that much memory in a chunk (unless you load up a very
171
 * large file), zlib needs to know how big of a chunk it can use, and
172
 * libpng thus makes sure to check any memory allocation to verify it
173
 * will fit into memory.
174
#define PNG_MAX_MALLOC_64K
175
 */
176
#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
177
#  define PNG_MAX_MALLOC_64K
178
#endif
179
180
 
181
 * 'Normal' png-on-win32 defines/defaults:
182
 *   PNG_BUILD_DLL -- building dll
183
 *   PNG_USE_DLL   -- building an application, linking to dll
184
 *   (no define)   -- building static library, or building an
185
 *                    application and linking to the static lib
186
 * 'Cygwin' defines/defaults:
187
 *   PNG_BUILD_DLL -- (ignored) building the dll
188
 *   (no define)   -- (ignored) building an application, linking to the dll
189
 *   PNG_STATIC    -- (ignored) building the static lib, or building an
190
 *                    application that links to the static lib.
191
 *   ALL_STATIC    -- (ignored) building various static libs, or building an
192
 *                    application that links to the static libs.
193
 * Thus,
194
 * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
195
 * this bit of #ifdefs will define the 'correct' config variables based on
196
 * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but
197
 * unnecessary.
198
 *
199
 * Also, the precedence order is:
200
 *   ALL_STATIC (since we can't #undef something outside our namespace)
201
 *   PNG_BUILD_DLL
202
 *   PNG_STATIC
203
 *   (nothing) == PNG_USE_DLL
204
 *
205
 * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
206
 *   of auto-import in binutils, we no longer need to worry about
207
 *   __declspec(dllexport) / __declspec(dllimport) and friends.  Therefore,
208
 *   we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
209
 *   to __declspec() stuff.  However, we DO need to worry about
210
 *   PNG_BUILD_DLL and PNG_STATIC because those change some defaults
211
 *   such as CONSOLE_IO.
212
 */
213
#ifdef __CYGWIN__
214
#  ifdef ALL_STATIC
215
#    ifdef PNG_BUILD_DLL
216
#      undef PNG_BUILD_DLL
217
#    endif
218
#    ifdef PNG_USE_DLL
219
#      undef PNG_USE_DLL
220
#    endif
221
#    ifdef PNG_DLL
222
#      undef PNG_DLL
223
#    endif
224
#    ifndef PNG_STATIC
225
#      define PNG_STATIC
226
#    endif
227
#  else
228
#    ifdef PNG_BUILD_DLL
229
#      ifdef PNG_STATIC
230
#        undef PNG_STATIC
231
#      endif
232
#      ifdef PNG_USE_DLL
233
#        undef PNG_USE_DLL
234
#      endif
235
#      ifndef PNG_DLL
236
#        define PNG_DLL
237
#      endif
238
#    else
239
#      ifdef PNG_STATIC
240
#        ifdef PNG_USE_DLL
241
#          undef PNG_USE_DLL
242
#        endif
243
#        ifdef PNG_DLL
244
#          undef PNG_DLL
245
#        endif
246
#      else
247
#        ifndef PNG_USE_DLL
248
#          define PNG_USE_DLL
249
#        endif
250
#        ifndef PNG_DLL
251
#          define PNG_DLL
252
#        endif
253
#      endif
254
#    endif
255
#  endif
256
#endif
257
258
 
259
 * and thus don't have or would rather us not use the stdio types:
260
 * stdin, stdout, and stderr.  The only one currently used is stderr
261
 * in png_error() and png_warning().  #defining PNG_NO_CONSOLE_IO will
262
 * prevent these from being compiled and used. #defining PNG_NO_STDIO
263
 * will also prevent these, plus will prevent the entire set of stdio
264
 * macros and functions (FILE *, printf, etc.) from being compiled and used,
265
 * unless (PNG_DEBUG > 0) has been #defined.
266
 *
267
 * #define PNG_NO_CONSOLE_IO
268
 * #define PNG_NO_STDIO
269
 */
270
271
 
272
#  define PNG_NO_CONSOLE_IO
273
#  define PNG_NO_STDIO
274
#  define PNG_NO_TIME_RFC1123
275
#  ifdef PNG_DEBUG
276
#    undef PNG_DEBUG
277
#  endif
278
#endif
279
280
 
281
#  define PNG_STDIO_SUPPORTED
282
#endif
283
284
 
285
#  if !defined(PNG_CONSOLE_IO_SUPPORTED) && !defined(PNG_NO_CONSOLE_IO)
286
#    define PNG_NO_CONSOLE_IO
287
#  endif
288
#endif
289
290
 
291
#    ifndef PNG_NO_CONSOLE_IO
292
#      define PNG_NO_CONSOLE_IO
293
#    endif
294
#    ifdef PNG_DEBUG
295
#      if (PNG_DEBUG > 0)
296
#        include 
297
#      endif
298
#    endif
299
#  else
300
#    include 
301
#  endif
302
303
 
304
#  define PNG_CONSOLE_IO_SUPPORTED
305
#endif
306
307
 
308
 * prototypes (ie K&R style headers).  If your compiler does not handle
309
 * function prototypes, define this macro and use the included ansi2knr.
310
 * I've always been able to use _NO_PROTO as the indicator, but you may
311
 * need to drag the empty declaration out in front of here, or change the
312
 * ifdef to suit your own needs.
313
 */
314
#ifndef PNGARG
315
316
 
317
#  define PNGARG(arglist) OF(arglist)
318
#else
319
320
 
321
#  define PNGARG(arglist) ()
322
#else
323
#  define PNGARG(arglist) arglist
324
#endif /* _NO_PROTO */
325
326
 
327
328
 
329
330
 
331
 * just __MWERKS__ is not good enough, because the Codewarrior is now used
332
 * on non-Mac platforms.
333
 */
334
#ifndef MACOS
335
#  if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
336
      defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
337
#    define MACOS
338
#  endif
339
#endif
340
341
 
342
#if !defined(MACOS) && !defined(RISCOS)
343
#  include 
344
#endif
345
346
 
347
#if !defined(PNG_NO_SETJMP) && \
348
    !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED)
349
#  define PNG_SETJMP_SUPPORTED
350
#endif
351
352
 
353
/* This is an attempt to force a single setjmp behaviour on Linux.  If
354
 * the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
355
 *
356
 * You can bypass this test if you know that your application uses exactly
357
 * the same setjmp.h that was included when libpng was built.  Only define
358
 * PNG_SKIP_SETJMP_CHECK while building your application, prior to the
359
 * application's '#include "png.h"'. Don't define PNG_SKIP_SETJMP_CHECK
360
 * while building a separate libpng library for general use.
361
 */
362
363
 
364
#    ifdef __linux__
365
#      ifdef _BSD_SOURCE
366
#        define PNG_SAVE_BSD_SOURCE
367
#        undef _BSD_SOURCE
368
#      endif
369
#      ifdef _SETJMP_H
370
       /* If you encounter a compiler error here, see the explanation
371
        * near the end of INSTALL.
372
        */
373
           __pngconf.h__ in libpng already includes setjmp.h;
374
           __dont__ include it again.;
375
#      endif
376
#    endif /* __linux__ */
377
#  endif /* PNG_SKIP_SETJMP_CHECK */
378
379
 
380
#  include 
381
382
 
383
#    ifdef PNG_SAVE_BSD_SOURCE
384
#      ifdef _BSD_SOURCE
385
#        undef _BSD_SOURCE
386
#      endif
387
#      define _BSD_SOURCE
388
#      undef PNG_SAVE_BSD_SOURCE
389
#    endif
390
#  endif /* __linux__ */
391
#endif /* PNG_SETJMP_SUPPORTED */
392
393
 
394
#  include 
395
#else
396
#  include 
397
#endif
398
399
 
400
401
 
402
 * a largish chunk of memory (32K), those who are not as concerned
403
 * with quantizing quality can decrease some or all of these.
404
 */
405
406
 
407
 * These migration aids will be removed from libpng-1.5.0.
408
 */
409
#ifdef PNG_DITHER_RED_BITS
410
#  define PNG_QUANTIZE_RED_BITS PNG_DITHER_RED_BITS
411
#endif
412
#ifdef PNG_DITHER_GREEN_BITS
413
#  define PNG_QUANTIZE_GREEN_BITS PNG_DITHER_GREEN_BITS
414
#endif
415
#ifdef PNG_DITHER_BLUE_BITS
416
#  define PNG_QUANTIZE_BLUE_BITS PNG_DITHER_BLUE_BITS
417
#endif
418
419
 
420
#  define PNG_QUANTIZE_RED_BITS 5
421
#endif
422
#ifndef PNG_QUANTIZE_GREEN_BITS
423
#  define PNG_QUANTIZE_GREEN_BITS 5
424
#endif
425
#ifndef PNG_QUANTIZE_BLUE_BITS
426
#  define PNG_QUANTIZE_BLUE_BITS 5
427
#endif
428
429
 
430
 * are only interested in 8 bits anyway.  Increasing this value
431
 * results in more memory being used, and more pow() functions
432
 * being called to fill in the gamma tables.  Don't set this value
433
 * less then 8, and even that may not work (I haven't tested it).
434
 */
435
436
 
437
#  define PNG_MAX_GAMMA_8 11
438
#endif
439
440
 
441
 * we actually start doing gamma conversion.
442
 */
443
#ifndef PNG_GAMMA_THRESHOLD
444
#  define PNG_GAMMA_THRESHOLD 0.05
445
#endif
446
447
 
448
 * and warning message functions, so some compilers won't complain.
449
 * If you do not want to use const, define PNG_NO_CONST.
450
 */
451
452
 
453
#  ifndef PNG_NO_CONST
454
#    define PNG_CONST const
455
#  else
456
#    define PNG_CONST
457
#  endif
458
#endif
459
460
 
461
 * library that you will not be using.  I wish I could figure out how to
462
 * automate this, but I can't do that without making it seriously hard
463
 * on the users.  So if you are not using an ability, change the #define
464
 * to an #undef, or pass in PNG_NO_feature and that part of the library
465
 * will not be compiled.
466
467
 
468
 * ability is defined here.  Some of these depend upon some others being
469
 * defined.  I haven't figured out all the interactions here, so you may
470
 * have to experiment awhile to get everything to compile.  If you are
471
 * creating or using a shared library, you probably shouldn't touch this,
472
 * as it will affect the size of the structures, and this will cause bad
473
 * things to happen if the library and/or application ever change.
474
 */
475
476
 
477
478
 
479
 * to turn it off with PNG_NO_READ|WRITE_TRANSFORMS on the compile line,
480
 * then pick and choose which ones to define without having to edit this
481
 * file. It is safe to use the PNG_NO_READ|WRITE_TRANSFORMS
482
 * if you only want to have a png-compliant reader/writer but don't need
483
 * any of the extra transformations.  This saves about 80 kbytes in a
484
 * typical installation of the library. (PNG_NO_* form added in version
485
 * 1.0.1c, for consistency; PNG_*_TRANSFORMS_NOT_SUPPORTED deprecated in
486
 * 1.4.0)
487
 */
488
489
 
490
#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \
491
    !defined(PNG_NO_FIXED_POINT_SUPPORTED)
492
#  define PNG_FIXED_POINT_SUPPORTED
493
#endif
494
495
 
496
497
 
498
#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
499
      !defined(PNG_NO_READ_TRANSFORMS)
500
#  define PNG_READ_TRANSFORMS_SUPPORTED
501
#endif
502
503
 
504
#  ifndef PNG_NO_READ_EXPAND
505
#    define PNG_READ_EXPAND_SUPPORTED
506
#  endif
507
#  ifndef PNG_NO_READ_SHIFT
508
#    define PNG_READ_SHIFT_SUPPORTED
509
#  endif
510
#  ifndef PNG_NO_READ_PACK
511
#    define PNG_READ_PACK_SUPPORTED
512
#  endif
513
#  ifndef PNG_NO_READ_BGR
514
#    define PNG_READ_BGR_SUPPORTED
515
#  endif
516
#  ifndef PNG_NO_READ_SWAP
517
#    define PNG_READ_SWAP_SUPPORTED
518
#  endif
519
#  ifndef PNG_NO_READ_PACKSWAP
520
#    define PNG_READ_PACKSWAP_SUPPORTED
521
#  endif
522
#  ifndef PNG_NO_READ_INVERT
523
#    define PNG_READ_INVERT_SUPPORTED
524
#  endif
525
#  ifndef PNG_NO_READ_QUANTIZE
526
     /* Prior to libpng-1.4.0 this was PNG_READ_DITHER_SUPPORTED */
527
#    ifndef PNG_NO_READ_DITHER  /* This migration aid will be removed */
528
#      define PNG_READ_QUANTIZE_SUPPORTED
529
#    endif
530
#  endif
531
#  ifndef PNG_NO_READ_BACKGROUND
532
#    define PNG_READ_BACKGROUND_SUPPORTED
533
#  endif
534
#  ifndef PNG_NO_READ_16_TO_8
535
#    define PNG_READ_16_TO_8_SUPPORTED
536
#  endif
537
#  ifndef PNG_NO_READ_FILLER
538
#    define PNG_READ_FILLER_SUPPORTED
539
#  endif
540
#  ifndef PNG_NO_READ_GAMMA
541
#    define PNG_READ_GAMMA_SUPPORTED
542
#  endif
543
#  ifndef PNG_NO_READ_GRAY_TO_RGB
544
#    define PNG_READ_GRAY_TO_RGB_SUPPORTED
545
#  endif
546
#  ifndef PNG_NO_READ_SWAP_ALPHA
547
#    define PNG_READ_SWAP_ALPHA_SUPPORTED
548
#  endif
549
#  ifndef PNG_NO_READ_INVERT_ALPHA
550
#    define PNG_READ_INVERT_ALPHA_SUPPORTED
551
#  endif
552
#  ifndef PNG_NO_READ_STRIP_ALPHA
553
#    define PNG_READ_STRIP_ALPHA_SUPPORTED
554
#  endif
555
#  ifndef PNG_NO_READ_USER_TRANSFORM
556
#    define PNG_READ_USER_TRANSFORM_SUPPORTED
557
#  endif
558
#  ifndef PNG_NO_READ_RGB_TO_GRAY
559
#    define PNG_READ_RGB_TO_GRAY_SUPPORTED
560
#  endif
561
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
562
563
 
564
#if !defined(PNG_NO_PROGRESSIVE_READ) && \
565
 !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED)  /* if you don't do progressive */
566
#  define PNG_PROGRESSIVE_READ_SUPPORTED     /* reading.  This is not talking */
567
#endif                               /* about interlacing capability!  You'll */
568
            /* still have interlacing unless you change the following define: */
569
570
 
571
572
 
573
#if !defined(PNG_NO_SEQUENTIAL_READ) && \
574
    !defined(PNG_SEQUENTIAL_READ_SUPPORTED) && \
575
    !defined(PNG_NO_SEQUENTIAL_READ_SUPPORTED)
576
#  define PNG_SEQUENTIAL_READ_SUPPORTED
577
#endif
578
579
 
580
#  ifndef PNG_NO_READ_COMPOSITED_NODIV  /* libpng-1.0.x misspelling */
581
#    define PNG_READ_COMPOSITE_NODIV_SUPPORTED   /* well tested on Intel, SGI */
582
#  endif
583
#endif
584
585
 
586
    defined(PNG_READ_pCAL_SUPPORTED)
587
#  ifndef PNG_GET_INT_32_SUPPORTED
588
#    define PNG_GET_INT_32_SUPPORTED
589
#  endif
590
#endif
591
592
 
593
594
 
595
596
 
597
#if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
598
    !defined(PNG_NO_WRITE_TRANSFORMS)
599
#  define PNG_WRITE_TRANSFORMS_SUPPORTED
600
#endif
601
602
 
603
#  ifndef PNG_NO_WRITE_SHIFT
604
#    define PNG_WRITE_SHIFT_SUPPORTED
605
#  endif
606
#  ifndef PNG_NO_WRITE_PACK
607
#    define PNG_WRITE_PACK_SUPPORTED
608
#  endif
609
#  ifndef PNG_NO_WRITE_BGR
610
#    define PNG_WRITE_BGR_SUPPORTED
611
#  endif
612
#  ifndef PNG_NO_WRITE_SWAP
613
#    define PNG_WRITE_SWAP_SUPPORTED
614
#  endif
615
#  ifndef PNG_NO_WRITE_PACKSWAP
616
#    define PNG_WRITE_PACKSWAP_SUPPORTED
617
#  endif
618
#  ifndef PNG_NO_WRITE_INVERT
619
#    define PNG_WRITE_INVERT_SUPPORTED
620
#  endif
621
#  ifndef PNG_NO_WRITE_FILLER
622
#    define PNG_WRITE_FILLER_SUPPORTED   /* same as WRITE_STRIP_ALPHA */
623
#  endif
624
#  ifndef PNG_NO_WRITE_SWAP_ALPHA
625
#    define PNG_WRITE_SWAP_ALPHA_SUPPORTED
626
#  endif
627
#  ifndef PNG_NO_WRITE_INVERT_ALPHA
628
#    define PNG_WRITE_INVERT_ALPHA_SUPPORTED
629
#  endif
630
#  ifndef PNG_NO_WRITE_USER_TRANSFORM
631
#    define PNG_WRITE_USER_TRANSFORM_SUPPORTED
632
#  endif
633
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
634
635
 
636
    !defined(PNG_WRITE_INTERLACING_SUPPORTED)
637
    /* This is not required for PNG-compliant encoders, but can cause
638
     * trouble if left undefined
639
    */
640
#  define PNG_WRITE_INTERLACING_SUPPORTED
641
#endif
642
643
 
644
    !defined(PNG_WRITE_WEIGHTED_FILTER) && \
645
     defined(PNG_FLOATING_POINT_SUPPORTED)
646
#  define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
647
#endif
648
649
 
650
#  define PNG_WRITE_FLUSH_SUPPORTED
651
#endif
652
653
 
654
    defined(PNG_WRITE_pCAL_SUPPORTED)
655
#  ifndef PNG_SAVE_INT_32_SUPPORTED
656
#    define PNG_SAVE_INT_32_SUPPORTED
657
#  endif
658
#endif
659
660
 
661
662
 
663
664
 
665
    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
666
#  ifndef PNG_NO_USER_TRANSFORM_PTR
667
#    define PNG_USER_TRANSFORM_PTR_SUPPORTED
668
#  endif
669
#endif
670
671
 
672
#  define PNG_TIME_RFC1123_SUPPORTED
673
#endif
674
675
 
676
 * info pointer (added in version 0.99)
677
 * png_get_image_width()
678
 * png_get_image_height()
679
 * png_get_bit_depth()
680
 * png_get_color_type()
681
 * png_get_compression_type()
682
 * png_get_filter_type()
683
 * png_get_interlace_type()
684
 * png_get_pixel_aspect_ratio()
685
 * png_get_pixels_per_meter()
686
 * png_get_x_offset_pixels()
687
 * png_get_y_offset_pixels()
688
 * png_get_x_offset_microns()
689
 * png_get_y_offset_microns()
690
 */
691
#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED)
692
#  define PNG_EASY_ACCESS_SUPPORTED
693
#endif
694
695
 
696
#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
697
#  define PNG_USER_MEM_SUPPORTED
698
#endif
699
700
 
701
#ifndef PNG_NO_SET_USER_LIMITS
702
#  ifndef PNG_SET_USER_LIMITS_SUPPORTED
703
#    define PNG_SET_USER_LIMITS_SUPPORTED
704
#  endif
705
  /* Feature added at libpng-1.4.0, this flag added at 1.4.1 */
706
#  ifndef PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
707
#    define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
708
#  endif
709
  /* Feature added at libpng-1.4.1, this flag added at 1.4.1 */
710
#  ifndef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
711
#    define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
712
#  endif
713
#endif
714
715
 
716
#ifndef PNG_USER_LIMITS_SUPPORTED
717
#  ifndef PNG_NO_USER_LIMITS
718
#    define PNG_USER_LIMITS_SUPPORTED
719
#  endif
720
#endif
721
722
 
723
 * how large, set these two limits to 0x7fffffffL
724
 */
725
#ifndef PNG_USER_WIDTH_MAX
726
#  define PNG_USER_WIDTH_MAX 1000000L
727
#endif
728
#ifndef PNG_USER_HEIGHT_MAX
729
#  define PNG_USER_HEIGHT_MAX 1000000L
730
#endif
731
732
 
733
 * how large, set these two limits to 0.
734
 */
735
#ifndef PNG_USER_CHUNK_CACHE_MAX
736
#  define PNG_USER_CHUNK_CACHE_MAX 0
737
#endif
738
739
 
740
#ifndef PNG_USER_CHUNK_MALLOC_MAX
741
#  define PNG_USER_CHUNK_MALLOC_MAX 0
742
#endif
743
744
 
745
#if !defined(PNG_NO_IO_STATE) && !defined(PNG_IO_STATE_SUPPORTED)
746
#  define PNG_IO_STATE_SUPPORTED
747
#endif
748
749
 
750
#  define PNG_LITERAL_SHARP 0x23
751
#endif
752
#ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
753
#  define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
754
#endif
755
#ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET
756
#  define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d
757
#endif
758
#ifndef PNG_STRING_NEWLINE
759
#define PNG_STRING_NEWLINE "\n"
760
#endif
761
762
 
763
764
 
765
/*
766
#ifdef PNG_READ_SUPPORTED
767
#  ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
768
#    define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
769
#  endif
770
#endif
771
*/
772
773
 
774
/* some testing */
775
/*
776
#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
777
#  define PNG_READ_BIG_ENDIAN_SUPPORTED
778
#endif
779
*/
780
781
 
782
#  define PNG_USE_READ_MACROS
783
#endif
784
785
 
786
787
 
788
    !defined(PNG_POINTER_INDEXING_SUPPORTED)
789
#  define PNG_POINTER_INDEXING_SUPPORTED
790
#endif
791
792
 
793
 
794
 * ones that allocate memory may be expecially important (hIST,
795
 * tEXt, zTXt, tRNS, pCAL).  Others will just save time and make png_info
796
 * a bit smaller.
797
 */
798
799
 
800
 * iTXt support was added.  iTXt support was turned off by default through
801
 * libpng-1.2.x, to support old apps that malloc the png_text structure
802
 * instead of calling png_set_text() and letting libpng malloc it.  It
803
 * was turned on by default in libpng-1.4.0.
804
 */
805
806
 
807
#if defined(PNG_READ_SUPPORTED) && \
808
    !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
809
    !defined(PNG_NO_READ_ANCILLARY_CHUNKS)
810
#  define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
811
#endif
812
813
 
814
#if defined(PNG_WRITE_SUPPORTED) && \
815
    !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
816
    !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
817
#  define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
818
#endif
819
820
 
821
822
 
823
#  define PNG_NO_READ_iTXt
824
#  define PNG_NO_READ_tEXt
825
#  define PNG_NO_READ_zTXt
826
#endif
827
828
 
829
#  define PNG_READ_bKGD_SUPPORTED
830
#  define PNG_bKGD_SUPPORTED
831
#endif
832
#ifndef PNG_NO_READ_cHRM
833
#  define PNG_READ_cHRM_SUPPORTED
834
#  define PNG_cHRM_SUPPORTED
835
#endif
836
#ifndef PNG_NO_READ_gAMA
837
#  define PNG_READ_gAMA_SUPPORTED
838
#  define PNG_gAMA_SUPPORTED
839
#endif
840
#ifndef PNG_NO_READ_hIST
841
#  define PNG_READ_hIST_SUPPORTED
842
#  define PNG_hIST_SUPPORTED
843
#endif
844
#ifndef PNG_NO_READ_iCCP
845
#  define PNG_READ_iCCP_SUPPORTED
846
#  define PNG_iCCP_SUPPORTED
847
#endif
848
#ifndef PNG_NO_READ_iTXt
849
#  ifndef PNG_READ_iTXt_SUPPORTED
850
#    define PNG_READ_iTXt_SUPPORTED
851
#  endif
852
#  ifndef PNG_iTXt_SUPPORTED
853
#    define PNG_iTXt_SUPPORTED
854
#  endif
855
#endif
856
#ifndef PNG_NO_READ_oFFs
857
#  define PNG_READ_oFFs_SUPPORTED
858
#  define PNG_oFFs_SUPPORTED
859
#endif
860
#ifndef PNG_NO_READ_pCAL
861
#  define PNG_READ_pCAL_SUPPORTED
862
#  define PNG_pCAL_SUPPORTED
863
#endif
864
#ifndef PNG_NO_READ_sCAL
865
#  define PNG_READ_sCAL_SUPPORTED
866
#  define PNG_sCAL_SUPPORTED
867
#endif
868
#ifndef PNG_NO_READ_pHYs
869
#  define PNG_READ_pHYs_SUPPORTED
870
#  define PNG_pHYs_SUPPORTED
871
#endif
872
#ifndef PNG_NO_READ_sBIT
873
#  define PNG_READ_sBIT_SUPPORTED
874
#  define PNG_sBIT_SUPPORTED
875
#endif
876
#ifndef PNG_NO_READ_sPLT
877
#  define PNG_READ_sPLT_SUPPORTED
878
#  define PNG_sPLT_SUPPORTED
879
#endif
880
#ifndef PNG_NO_READ_sRGB
881
#  define PNG_READ_sRGB_SUPPORTED
882
#  define PNG_sRGB_SUPPORTED
883
#endif
884
#ifndef PNG_NO_READ_tEXt
885
#  define PNG_READ_tEXt_SUPPORTED
886
#  define PNG_tEXt_SUPPORTED
887
#endif
888
#ifndef PNG_NO_READ_tIME
889
#  define PNG_READ_tIME_SUPPORTED
890
#  define PNG_tIME_SUPPORTED
891
#endif
892
#ifndef PNG_NO_READ_tRNS
893
#  define PNG_READ_tRNS_SUPPORTED
894
#  define PNG_tRNS_SUPPORTED
895
#endif
896
#ifndef PNG_NO_READ_zTXt
897
#  define PNG_READ_zTXt_SUPPORTED
898
#  define PNG_zTXt_SUPPORTED
899
#endif
900
#ifndef PNG_NO_READ_OPT_PLTE
901
#  define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
902
#endif                      /* optional PLTE chunk in RGB and RGBA images */
903
#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
904
    defined(PNG_READ_zTXt_SUPPORTED)
905
#  define PNG_READ_TEXT_SUPPORTED
906
#  define PNG_TEXT_SUPPORTED
907
#endif
908
909
 
910
911
 
912
#  ifndef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
913
#    define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
914
#  endif
915
#  ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
916
#    define PNG_UNKNOWN_CHUNKS_SUPPORTED
917
#  endif
918
#  ifndef PNG_READ_USER_CHUNKS_SUPPORTED
919
#    define PNG_READ_USER_CHUNKS_SUPPORTED
920
#  endif
921
#endif
922
#ifndef PNG_NO_READ_USER_CHUNKS
923
#  ifndef PNG_READ_USER_CHUNKS_SUPPORTED
924
#    define PNG_READ_USER_CHUNKS_SUPPORTED
925
#  endif
926
#  ifndef PNG_USER_CHUNKS_SUPPORTED
927
#    define PNG_USER_CHUNKS_SUPPORTED
928
#  endif
929
#endif
930
#ifndef PNG_NO_HANDLE_AS_UNKNOWN
931
#  ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
932
#    define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
933
#  endif
934
#endif
935
936
 
937
#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
938
939
 
940
#  define PNG_NO_WRITE_iTXt
941
#  define PNG_NO_WRITE_tEXt
942
#  define PNG_NO_WRITE_zTXt
943
#endif
944
#ifndef PNG_NO_WRITE_bKGD
945
#  define PNG_WRITE_bKGD_SUPPORTED
946
#  ifndef PNG_bKGD_SUPPORTED
947
#    define PNG_bKGD_SUPPORTED
948
#  endif
949
#endif
950
#ifndef PNG_NO_WRITE_cHRM
951
#  define PNG_WRITE_cHRM_SUPPORTED
952
#  ifndef PNG_cHRM_SUPPORTED
953
#    define PNG_cHRM_SUPPORTED
954
#  endif
955
#endif
956
#ifndef PNG_NO_WRITE_gAMA
957
#  define PNG_WRITE_gAMA_SUPPORTED
958
#  ifndef PNG_gAMA_SUPPORTED
959
#    define PNG_gAMA_SUPPORTED
960
#  endif
961
#endif
962
#ifndef PNG_NO_WRITE_hIST
963
#  define PNG_WRITE_hIST_SUPPORTED
964
#  ifndef PNG_hIST_SUPPORTED
965
#    define PNG_hIST_SUPPORTED
966
#  endif
967
#endif
968
#ifndef PNG_NO_WRITE_iCCP
969
#  define PNG_WRITE_iCCP_SUPPORTED
970
#  ifndef PNG_iCCP_SUPPORTED
971
#    define PNG_iCCP_SUPPORTED
972
#  endif
973
#endif
974
#ifndef PNG_NO_WRITE_iTXt
975
#  ifndef PNG_WRITE_iTXt_SUPPORTED
976
#    define PNG_WRITE_iTXt_SUPPORTED
977
#  endif
978
#  ifndef PNG_iTXt_SUPPORTED
979
#    define PNG_iTXt_SUPPORTED
980
#  endif
981
#endif
982
#ifndef PNG_NO_WRITE_oFFs
983
#  define PNG_WRITE_oFFs_SUPPORTED
984
#  ifndef PNG_oFFs_SUPPORTED
985
#    define PNG_oFFs_SUPPORTED
986
#  endif
987
#endif
988
#ifndef PNG_NO_WRITE_pCAL
989
#  define PNG_WRITE_pCAL_SUPPORTED
990
#  ifndef PNG_pCAL_SUPPORTED
991
#    define PNG_pCAL_SUPPORTED
992
#  endif
993
#endif
994
#ifndef PNG_NO_WRITE_sCAL
995
#  define PNG_WRITE_sCAL_SUPPORTED
996
#  ifndef PNG_sCAL_SUPPORTED
997
#    define PNG_sCAL_SUPPORTED
998
#  endif
999
#endif
1000
#ifndef PNG_NO_WRITE_pHYs
1001
#  define PNG_WRITE_pHYs_SUPPORTED
1002
#  ifndef PNG_pHYs_SUPPORTED
1003
#    define PNG_pHYs_SUPPORTED
1004
#  endif
1005
#endif
1006
#ifndef PNG_NO_WRITE_sBIT
1007
#  define PNG_WRITE_sBIT_SUPPORTED
1008
#  ifndef PNG_sBIT_SUPPORTED
1009
#    define PNG_sBIT_SUPPORTED
1010
#  endif
1011
#endif
1012
#ifndef PNG_NO_WRITE_sPLT
1013
#  define PNG_WRITE_sPLT_SUPPORTED
1014
#  ifndef PNG_sPLT_SUPPORTED
1015
#    define PNG_sPLT_SUPPORTED
1016
#  endif
1017
#endif
1018
#ifndef PNG_NO_WRITE_sRGB
1019
#  define PNG_WRITE_sRGB_SUPPORTED
1020
#  ifndef PNG_sRGB_SUPPORTED
1021
#    define PNG_sRGB_SUPPORTED
1022
#  endif
1023
#endif
1024
#ifndef PNG_NO_WRITE_tEXt
1025
#  define PNG_WRITE_tEXt_SUPPORTED
1026
#  ifndef PNG_tEXt_SUPPORTED
1027
#    define PNG_tEXt_SUPPORTED
1028
#  endif
1029
#endif
1030
#ifndef PNG_NO_WRITE_tIME
1031
#  define PNG_WRITE_tIME_SUPPORTED
1032
#  ifndef PNG_tIME_SUPPORTED
1033
#    define PNG_tIME_SUPPORTED
1034
#  endif
1035
#endif
1036
#ifndef PNG_NO_WRITE_tRNS
1037
#  define PNG_WRITE_tRNS_SUPPORTED
1038
#  ifndef PNG_tRNS_SUPPORTED
1039
#    define PNG_tRNS_SUPPORTED
1040
#  endif
1041
#endif
1042
#ifndef PNG_NO_WRITE_zTXt
1043
#  define PNG_WRITE_zTXt_SUPPORTED
1044
#  ifndef PNG_zTXt_SUPPORTED
1045
#    define PNG_zTXt_SUPPORTED
1046
#  endif
1047
#endif
1048
#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
1049
    defined(PNG_WRITE_zTXt_SUPPORTED)
1050
#  define PNG_WRITE_TEXT_SUPPORTED
1051
#  ifndef PNG_TEXT_SUPPORTED
1052
#    define PNG_TEXT_SUPPORTED
1053
#  endif
1054
#endif
1055
1056
 
1057
#  ifndef PNG_NO_CONVERT_tIME
1058
#    ifndef _WIN32_WCE
1059
/*   The "tm" structure is not supported on WindowsCE */
1060
#      ifndef PNG_CONVERT_tIME_SUPPORTED
1061
#        define PNG_CONVERT_tIME_SUPPORTED
1062
#      endif
1063
#   endif
1064
#  endif
1065
#endif
1066
1067
 
1068
1069
 
1070
#  ifndef PNG_WRITE_FILTER_SUPPORTED
1071
#    define PNG_WRITE_FILTER_SUPPORTED
1072
#  endif
1073
#endif
1074
1075
 
1076
#  define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
1077
#  ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
1078
#    define PNG_UNKNOWN_CHUNKS_SUPPORTED
1079
#  endif
1080
#endif
1081
#ifndef PNG_NO_HANDLE_AS_UNKNOWN
1082
#  ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
1083
#    define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
1084
#  endif
1085
#endif
1086
#endif /* PNG_WRITE_SUPPORTED */
1087
1088
 
1089
 * png_write_png() and leave the row_pointers member
1090
 * out of the info structure.
1091
 */
1092
#ifndef PNG_NO_INFO_IMAGE
1093
#  define PNG_INFO_IMAGE_SUPPORTED
1094
#endif
1095
1096
 
1097
#ifdef PNG_CONVERT_tIME_SUPPORTED
1098
     /* "time.h" functions are not supported on WindowsCE */
1099
#    include 
1100
#endif
1101
1102
 
1103
 * common platforms.  The typedefs should be at least as large as the
1104
 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
1105
 * don't have to be exactly that size.  Some compilers dislike passing
1106
 * unsigned shorts as function parameters, so you may be better off using
1107
 * unsigned int for png_uint_16.
1108
 */
1109
1110
 
1111
typedef unsigned int png_uint_32;
1112
typedef int png_int_32;
1113
#else
1114
typedef unsigned long png_uint_32;
1115
typedef long png_int_32;
1116
#endif
1117
typedef unsigned short png_uint_16;
1118
typedef short png_int_16;
1119
typedef unsigned char png_byte;
1120
1121
 
1122
   typedef unsigned int png_size_t;
1123
#else
1124
   typedef size_t png_size_t;
1125
#endif
1126
#define png_sizeof(x) (sizeof (x))
1127
1128
 
1129
 * pngpriv.h header.  Needs modification for other compilers besides
1130
 * MSC.  Model independent support declares all arrays and pointers to be
1131
 * large using the far keyword.  The zlib version used must also support
1132
 * model independent data.  As of version zlib 1.0.4, the necessary changes
1133
 * have been made in zlib.  The USE_FAR_KEYWORD define triggers other
1134
 * changes that are needed. (Tim Wegner)
1135
 */
1136
1137
 
1138
 * defines FAR. (SJT)
1139
 */
1140
#ifdef __BORLANDC__
1141
#  if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
1142
#    define LDATA 1
1143
#  else
1144
#    define LDATA 0
1145
#  endif
1146
   /* GRR:  why is Cygwin in here?  Cygwin is not Borland C... */
1147
#  if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
1148
#    define PNG_MAX_MALLOC_64K
1149
#    if (LDATA != 1)
1150
#      ifndef FAR
1151
#        define FAR __far
1152
#      endif
1153
#      define USE_FAR_KEYWORD
1154
#    endif   /* LDATA != 1 */
1155
     /* Possibly useful for moving data out of default segment.
1156
      * Uncomment it if you want. Could also define FARDATA as
1157
      * const if your compiler supports it. (SJT)
1158
#    define FARDATA FAR
1159
      */
1160
#  endif  /* __WIN32__, __FLAT__, __CYGWIN__ */
1161
#endif   /* __BORLANDC__ */
1162
1163
 
1164
 
1165
 * FAR.  The Watcom compiler defines both __MEDIUM__ and M_I86MM,
1166
 * making reliance oncertain keywords suspect. (SJT)
1167
 */
1168
1169
 
1170
#ifdef FAR
1171
#  ifdef M_I86MM
1172
#    define USE_FAR_KEYWORD
1173
#    define FARDATA FAR
1174
#    include 
1175
#  endif
1176
#endif
1177
1178
 
1179
#ifndef FAR
1180
#  define FAR
1181
#endif
1182
1183
 
1184
#ifndef FARDATA
1185
#  define FARDATA
1186
#endif
1187
1188
 
1189
   to fixed-point with a multiple of 100,000, e.g., int_gamma */
1190
typedef png_int_32 png_fixed_point;
1191
1192
 
1193
typedef void            FAR * png_voidp;
1194
typedef png_byte        FAR * png_bytep;
1195
typedef png_uint_32     FAR * png_uint_32p;
1196
typedef png_int_32      FAR * png_int_32p;
1197
typedef png_uint_16     FAR * png_uint_16p;
1198
typedef png_int_16      FAR * png_int_16p;
1199
typedef PNG_CONST char  FAR * png_const_charp;
1200
typedef char            FAR * png_charp;
1201
typedef png_fixed_point FAR * png_fixed_point_p;
1202
1203
 
1204
typedef FILE                * png_FILE_p;
1205
#endif
1206
1207
 
1208
typedef double          FAR * png_doublep;
1209
#endif
1210
1211
 
1212
typedef png_byte        FAR * FAR * png_bytepp;
1213
typedef png_uint_32     FAR * FAR * png_uint_32pp;
1214
typedef png_int_32      FAR * FAR * png_int_32pp;
1215
typedef png_uint_16     FAR * FAR * png_uint_16pp;
1216
typedef png_int_16      FAR * FAR * png_int_16pp;
1217
typedef PNG_CONST char  FAR * FAR * png_const_charpp;
1218
typedef char            FAR * FAR * png_charpp;
1219
typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
1220
#ifdef PNG_FLOATING_POINT_SUPPORTED
1221
typedef double          FAR * FAR * png_doublepp;
1222
#endif
1223
1224
 
1225
typedef char            FAR * FAR * FAR * png_charppp;
1226
1227
 
1228
 * LIBPNG DLL.
1229
 *
1230
 * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL.
1231
 * It is equivalent to Microsoft predefined macro _DLL that is
1232
 * automatically defined when you compile using the share
1233
 * version of the CRT (C Run-Time library)
1234
 *
1235
 * The cygwin mods make this behavior a little different:
1236
 * Define PNG_BUILD_DLL if you are building a dll for use with cygwin
1237
 * Define PNG_STATIC if you are building a static library for use with cygwin,
1238
 *   -or- if you are building an application that you want to link to the
1239
 *   static library.
1240
 * PNG_USE_DLL is defined by default (no user action needed) unless one of
1241
 *   the other flags is defined.
1242
 */
1243
1244
 
1245
#  define PNG_DLL
1246
#endif
1247
1248
 
1249
 * you may get warnings regarding the linkage of png_zalloc and png_zfree.
1250
 * Don't ignore those warnings; you must also reset the default calling
1251
 * convention in your compiler to match your PNGAPI, and you must build
1252
 * zlib and your applications the same way you build libpng.
1253
 */
1254
1255
 
1256
#  undef PNGAPI
1257
#  define PNGAPI __cdecl
1258
#  undef PNG_IMPEXP
1259
#  define PNG_IMPEXP
1260
#endif
1261
1262
 
1263
#  ifndef PNGAPI
1264
#    define PNGAPI
1265
#  endif
1266
#endif
1267
1268
 
1269
#  ifndef PNG_NO_MODULEDEF
1270
#    define PNG_NO_MODULEDEF
1271
#  endif
1272
#endif
1273
1274
 
1275
#  define PNG_IMPEXP
1276
#endif
1277
1278
 
1279
    (( defined(_Windows) || defined(_WINDOWS) || \
1280
       defined(WIN32) || defined(_WIN32) || defined(__WIN32__) ))
1281
1282
 
1283
#     if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
1284
#        define PNGAPI __cdecl
1285
#     else
1286
#        define PNGAPI _cdecl
1287
#     endif
1288
#  endif
1289
1290
 
1291
       0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */)
1292
 
1293
#  endif
1294
1295
 
1296
1297
 
1298
#    define PNG_EXPORT_TYPE2(type,symbol)  type PNG_IMPEXP PNGAPI symbol
1299
1300
 
1301
#    if defined(_MSC_VER) || defined(__BORLANDC__)
1302
#      if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
1303
#         define PNG_EXPORT PNG_EXPORT_TYPE1
1304
#      else
1305
#         define PNG_EXPORT PNG_EXPORT_TYPE2
1306
#         ifdef PNG_BUILD_DLL
1307
#            define PNG_IMPEXP __export
1308
#         else
1309
#            define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in VC++ */
1310
#         endif                              /* Exists in Borland C++ for
1311
                                                C++ classes (== huge) */
1312
#      endif
1313
#    endif
1314
1315
 
1316
#      ifdef PNG_BUILD_DLL
1317
#        define PNG_IMPEXP __declspec(dllexport)
1318
#      else
1319
#        define PNG_IMPEXP __declspec(dllimport)
1320
#      endif
1321
#    endif
1322
#  endif  /* PNG_IMPEXP */
1323
#else /* !(DLL || non-cygwin WINDOWS) */
1324
#   if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
1325
#     ifndef PNGAPI
1326
#       define PNGAPI _System
1327
#     endif
1328
#   else
1329
#     if 0 /* ... other platforms, with other meanings */
1330
#     endif
1331
#   endif
1332
#endif
1333
1334
 
1335
#  define PNGAPI
1336
#endif
1337
#ifndef PNG_IMPEXP
1338
#  define PNG_IMPEXP
1339
#endif
1340
1341
 
1342
#  ifndef PNG_EXPORT
1343
#    define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END
1344
#  endif
1345
#endif
1346
1347
 
1348
#  define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
1349
#endif
1350
1351
 
1352
1353
 
1354
 * so that where compiler support is available incorrect use of API
1355
 * functions in png.h will generate compiler warnings.
1356
 *
1357
 * Added at libpng-1.2.41.
1358
 */
1359
1360
 
1361
#  ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
1362
#    define PNG_PEDANTIC_WARNINGS_SUPPORTED
1363
#  endif
1364
#endif
1365
1366
 
1367
/* Support for compiler specific function attributes.  These are used
1368
 * so that where compiler support is available incorrect use of API
1369
 * functions in png.h will generate compiler warnings.  Added at libpng
1370
 * version 1.2.41.
1371
 */
1372
#  ifdef __GNUC__
1373
#    ifndef PNG_USE_RESULT
1374
#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))
1375
#    endif
1376
#    ifndef PNG_NORETURN
1377
#      define PNG_NORETURN   __attribute__((__noreturn__))
1378
#    endif
1379
#    ifndef PNG_ALLOCATED
1380
#      define PNG_ALLOCATED  __attribute__((__malloc__))
1381
#    endif
1382
1383
 
1384
     * accessed from within the library, therefore should be empty during
1385
     * a library build.
1386
     */
1387
#    ifndef PNG_DEPRECATED
1388
#      define PNG_DEPRECATED __attribute__((__deprecated__))
1389
#    endif
1390
#    ifndef PNG_DEPSTRUCT
1391
#      define PNG_DEPSTRUCT  __attribute__((__deprecated__))
1392
#    endif
1393
#    ifndef PNG_PRIVATE
1394
#      if 0 /* Doesn't work so we use deprecated instead*/
1395
#        define PNG_PRIVATE \
1396
          __attribute__((warning("This function is not exported by libpng.")))
1397
#      else
1398
#        define PNG_PRIVATE \
1399
          __attribute__((__deprecated__))
1400
#      endif
1401
#    endif /* PNG_PRIVATE */
1402
#  endif /* __GNUC__ */
1403
#endif /* PNG_PEDANTIC_WARNINGS */
1404
1405
 
1406
#  define PNG_DEPRECATED  /* Use of this function is deprecated */
1407
#endif
1408
#ifndef PNG_USE_RESULT
1409
#  define PNG_USE_RESULT  /* The result of this function must be checked */
1410
#endif
1411
#ifndef PNG_NORETURN
1412
#  define PNG_NORETURN    /* This function does not return */
1413
#endif
1414
#ifndef PNG_ALLOCATED
1415
#  define PNG_ALLOCATED   /* The result of the function is new memory */
1416
#endif
1417
#ifndef PNG_DEPSTRUCT
1418
#  define PNG_DEPSTRUCT   /* Access to this struct member is deprecated */
1419
#endif
1420
#ifndef PNG_PRIVATE
1421
#  define PNG_PRIVATE     /* This is a private libpng function */
1422
#endif
1423
1424
 
1425
 * functions that are passed far data must be model-independent.
1426
 */
1427
1428
 
1429
#ifndef PNG_ABORT
1430
#  if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_))
1431
#     define PNG_ABORT() ExitProcess(0)
1432
#  else
1433
#     define PNG_ABORT() abort()
1434
#  endif
1435
#endif
1436
1437
 
1438
/* Use this to make far-to-near assignments */
1439
#  define CHECK   1
1440
#  define NOCHECK 0
1441
#  define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
1442
#  define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
1443
#  define png_strcpy  _fstrcpy
1444
#  define png_strncpy _fstrncpy   /* Added to v 1.2.6 */
1445
#  define png_strlen  _fstrlen
1446
#  define png_memcmp  _fmemcmp    /* SJT: added */
1447
#  define png_memcpy  _fmemcpy
1448
#  define png_memset  _fmemset
1449
#  define png_sprintf sprintf
1450
#else
1451
#  if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_))
1452
#    /* Favor Windows over C runtime fns */
1453
#    define CVT_PTR(ptr)         (ptr)
1454
#    define CVT_PTR_NOCHECK(ptr) (ptr)
1455
#    define png_strcpy  lstrcpyA
1456
#    define png_strncpy lstrcpynA
1457
#    define png_strlen  lstrlenA
1458
#    define png_memcmp  memcmp
1459
#    define png_memcpy  CopyMemory
1460
#    define png_memset  memset
1461
#    define png_sprintf wsprintfA
1462
#  else
1463
#    define CVT_PTR(ptr)         (ptr)
1464
#    define CVT_PTR_NOCHECK(ptr) (ptr)
1465
#    define png_strcpy  strcpy
1466
#    define png_strncpy strncpy     /* Added to v 1.2.6 */
1467
#    define png_strlen  strlen
1468
#    define png_memcmp  memcmp      /* SJT: added */
1469
#    define png_memcpy  memcpy
1470
#    define png_memset  memset
1471
#    define png_sprintf sprintf
1472
#  endif
1473
#endif
1474
1475
 
1476
#  ifdef _MSC_VER
1477
#    define png_snprintf _snprintf   /* Added to v 1.2.19 */
1478
#    define png_snprintf2 _snprintf
1479
#    define png_snprintf6 _snprintf
1480
#  else
1481
#    define png_snprintf snprintf   /* Added to v 1.2.19 */
1482
#    define png_snprintf2 snprintf
1483
#    define png_snprintf6 snprintf
1484
#  endif
1485
#else
1486
   /* You don't have or don't want to use snprintf().  Caution: Using
1487
    * sprintf instead of snprintf exposes your application to accidental
1488
    * or malevolent buffer overflows.  If you don't have snprintf()
1489
    * as a general rule you should provide one (you can get one from
1490
    * Portable OpenSSH).
1491
    */
1492
#  define png_snprintf(s1,n,fmt,x1) png_sprintf(s1,fmt,x1)
1493
#  define png_snprintf2(s1,n,fmt,x1,x2) png_sprintf(s1,fmt,x1,x2)
1494
#  define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
1495
      png_sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
1496
#endif
1497
1498
 
1499
 * and no smaller than png_uint_32.  Casts from png_size_t or png_uint_32
1500
 * to png_alloc_size_t are not necessary; in fact, it is recommended
1501
 * not to use them at all so that the compiler can complain when something
1502
 * turns out to be problematic.
1503
 * Casts in the other direction (from png_alloc_size_t to png_size_t or
1504
 * png_uint_32) should be explicitly applied; however, we do not expect
1505
 * to encounter practical situations that require such conversions.
1506
 */
1507
#if defined(__TURBOC__) && !defined(__FLAT__)
1508
   typedef unsigned long png_alloc_size_t;
1509
#else
1510
#  if defined(_MSC_VER) && defined(MAXSEG_64K)
1511
     typedef unsigned long    png_alloc_size_t;
1512
#  else
1513
     /* This is an attempt to detect an old Windows system where (int) is
1514
      * actually 16 bits, in that case png_malloc must have an argument with a
1515
      * bigger size to accomodate the requirements of the library.
1516
      */
1517
#    if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
1518
        (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
1519
       typedef DWORD         png_alloc_size_t;
1520
#    else
1521
       typedef png_size_t    png_alloc_size_t;
1522
#    endif
1523
#  endif
1524
#endif
1525
/* End of memory model/platform independent support */
1526
1527
 
1528
 * contradictory.
1529
 */
1530
#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
1531
#  undef PNG_ZBUF_SIZE
1532
#  define PNG_ZBUF_SIZE 65536L
1533
#endif
1534
1535
 
1536
 
1537
#endif /* PNG_VERSION_INFO_ONLY */
1538
1539
 
1540