Subversion Repositories Kolibri OS

Rev

Rev 8341 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8341 dunkaist 1
 
2
3
 
4
5
 
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
 
10
11
 
12
;   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
13
;   libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
14
;   libpng versions 0.97, January 1998, through 1.6.25, September 1, 2016:
15
;     Glenn Randers-Pehrson.
16
;   See also "Contributing Authors", below.
17
18
 
19
 
20
 
21
22
 
23
; this sentence.
24
25
 
26
27
 
28
; files that are distributed with libpng have other copyright owners and
29
; are released under other open source licenses.
30
31
 
32
; Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
33
; derived from libpng-1.0.6, and are distributed according to the same
34
; disclaimer and license as libpng-1.0.6 with the following individuals
35
; added to the list of Contributing Authors:
36
37
 
38
;    Eric S. Raymond
39
;    Mans Rullgard
40
;    Cosmin Truta
41
;    Gilles Vollant
42
;    James Yu
43
;    Mandar Sahastrabuddhe
44
45
 
46
47
 
48
;    library or against infringement.  There is no warranty that our
49
;    efforts or the library will fulfill any of your particular purposes
50
;    or needs.  This library is provided with all faults, and the entire
51
;    risk of satisfactory quality, performance, accuracy, and effort is with
52
;    the user.
53
54
 
55
; are released under other open source licenses.
56
57
 
58
 
59
; Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
60
; libpng-0.96, and are distributed according to the same disclaimer and
61
; license as libpng-0.96, with the following individuals added to the list
62
; of Contributing Authors:
63
64
 
65
;    Glenn Randers-Pehrson
66
;    Willem van Schaik
67
68
 
69
; but are also released under this license.
70
71
 
72
; Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
73
; and are distributed according to the same disclaimer and license as
74
; libpng-0.88, with the following individuals added to the list of
75
; Contributing Authors:
76
77
 
78
;    Kevin Bracey
79
;    Sam Bushell
80
;    Magnus Holmgren
81
;    Greg Roelofs
82
;    Tom Tanner
83
84
 
85
; but are released under this license.
86
87
 
88
; Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
89
90
 
91
; is defined as the following set of individuals:
92
93
 
94
;    Dave Martindale
95
;    Guy Eric Schalnat
96
;    Paul Schmidt
97
;    Tim Wegner
98
99
 
100
; and Group 42, Inc. disclaim all warranties, expressed or implied,
101
; including, without limitation, the warranties of merchantability and of
102
; fitness for any purpose.  The Contributing Authors and Group 42, Inc.
103
; assume no liability for direct, indirect, incidental, special, exemplary,
104
; or consequential damages, which may result from the use of the PNG
105
; Reference Library, even if advised of the possibility of such damage.
106
107
 
108
; source code, or portions hereof, for any purpose, without fee, subject
109
; to the following restrictions:
110
111
 
112
113
 
114
;      be misrepresented as being the original source.
115
116
 
117
;      source or altered source distribution.
118
119
 
120
; fee, and encourage the use of this source code as a component to
121
; supporting the PNG file format in commercial products.  If you use this
122
; source code in a product, acknowledgment is not required but would be
123
; appreciated.
124
125
 
126
127
 
128
129
 
130
; as a trademark in any jurisdiction.  However, because libpng has
131
; been distributed and maintained world-wide, continually since 1995,
132
; the Copyright owner claims "common-law trademark protection" in any
133
; jurisdiction where common-law trademark is recognized.
134
135
 
136
137
 
138
; a certification mark of the Open Source Initiative. OSI has not addressed
139
; the additional disclaimers inserted at version 1.0.7.
140
141
 
142
143
 
144
; Number (ECCN) for libpng is EAR99, which means not subject to export
145
; controls or International Traffic in Arms Regulations (ITAR) because
146
; it is open source, publicly available software, that does not contain
147
; any encryption software.  See the EAR, paragraphs 734.3(b)(3) and
148
; 734.7(b).
149
150
 
151
 
152
 
153
; boxes and the like:
154
155
 
156
157
 
158
; files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
159
160
 
161
 
162
 
163
; with testing, bug fixes, and patience.  This wouldn't have been
164
; possible without all of you.
165
166
 
167
168
 
169
; Note about libpng version numbers:
170
;
171
;    Due to various miscommunications, unforeseen code incompatibilities
172
;    and occasional factors outside the authors' control, version numbering
173
;    on the library has not always been consistent and straightforward.
174
;    The following table summarizes matters since version 0.89c, which was
175
;    the first widely used release:
176
;
177
;    source                 png.h  png.h  shared-lib
178
;    version                string   int  version
179
;    -------                ------ -----  ----------
180
;    ...
181
;    1.2.56                  13    10256  12.so.0.56[.0]
182
;    ...
183
;    1.5.27                  15    10527  15.so.15.27[.0]
184
;    ...
185
;    1.6.25                  16    10625  16.so.16.25[.0]
186
187
 
188
;    and minor numbers; the shared-library major version number will be
189
;    used for changes in backward compatibility, as it is intended.  The
190
;    PNG_LIBPNG_VER macro, which is not used within libpng but is available
191
;    for applications, is an unsigned integer of the form xyyzz corresponding
192
;    to the source version x.y.z (leading zeros in y and z).  Beta versions
193
;    were given the previous public release number plus a letter, until
194
;    version 1.0.6j; from then on they were given the upcoming public
195
;    release number plus "betaNN" or "rcNN".
196
197
 
198
;    to the info_ptr or png_ptr members through png.h, and the compiled
199
;    application is loaded with a different version of the library.
200
201
 
202
;    in binary compatibility (e.g., when a new feature is added).
203
204
 
205
; is available as a W3C Recommendation and as an ISO Specification,
206
; 
207
208
 
209
 
210
 
211
; =========================
212
213
 
214
215
 
216
;    an official declaration.
217
218
 
219
;    upward through 1.6.25 are Y2K compliant.  It is my belief that
220
;    earlier versions were also Y2K compliant.
221
222
 
223
;    that will hold years up to 65535.  The other, which is deprecated,
224
;    holds the date in text format, and will hold years up to 9999.
225
226
 
227
;        "uint_16 year" in png_time_struct.
228
229
 
230
;        "char time_buffer[29]" in png_struct.  This is no longer used
231
;    in libpng-1.6.x and will be removed from libpng-1.7.0.
232
233
 
234
;        png.asm: png_convert_to_rfc_1123_buffer() in png.asm
235
;          (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and
236
;          png_convert_to_rfc_1152() in error prior to libpng-0.98)
237
;        png_convert_from_struct_tm() in pngwrite.asm, called in pngwrite.asm
238
;        png_convert_from_time_t() in pngwrite.asm
239
;        png_get_tIME() in pngget.asm
240
;        png_handle_tIME() in pngrutil.asm, called in pngread.asm
241
;        png_set_tIME() in pngset.asm
242
;        png_write_tIME() in pngwutil.asm, called in pngwrite.asm
243
244
 
245
;    png_convert_from_time_t() function calls gmtime() to convert from system
246
;    clock time, which returns (year - 1900), which we properly convert to
247
;    the full 4-digit year.  There is a possibility that libpng applications
248
;    are not passing 4-digit years into the png_convert_to_rfc_1123_buffer()
249
;    function, or that they are incorrectly passing only a 2-digit year
250
;    instead of "year - 1900" into the png_convert_from_struct_tm() function,
251
;    but this is not under our control.  The libpng documentation has always
252
;    stated that it works with 4-digit years, and the APIs have been
253
;    documented as such.
254
255
 
256
;    integer to hold the year, and can hold years as large as 65535.
257
258
 
259
;    no date-related code.
260
261
 
262
;       libpng maintainer
263
;       PNG Development Group
264
265
 
266
 
267
; describes how to use libpng, and the file example.c summarizes it
268
; with some code on which to build.  This file is useful for looking
269
; at the actual function definitions and structure components.  If that
270
; file has been stripped from your copy of libpng, you can find it at
271
; 
272
273
 
274
; skip to the end of this file and read the section entitled 'simplified API'.
275
276
 
277
 
278
PNG_LIBPNG_VER_STRING db '1.6.25',0
279
PNG_HEADER_VERSION_STRING db ' libpng version 1.6.25 - September 1, 2016',13,10,0
280
281
 
282
PNG_LIBPNG_VER_DLLNUM equ 16
283
284
 
285
PNG_LIBPNG_VER_MAJOR  equ 1
286
PNG_LIBPNG_VER_MINOR  equ 6
287
PNG_LIBPNG_VER_RELEASE equ 25
288
289
 
290
; PNG_LIBPNG_VER_STRING, omitting any leading zero:
291
292
 
293
 
294
295
 
296
PNG_LIBPNG_BUILD_ALPHA   equ 1
297
PNG_LIBPNG_BUILD_BETA    equ 2
298
PNG_LIBPNG_BUILD_RC      equ 3
299
PNG_LIBPNG_BUILD_STABLE  equ 4
300
PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK equ 7
301
302
 
303
PNG_LIBPNG_BUILD_PATCH   equ  8 ;Can be OR'ed with PNG_LIBPNG_BUILD_STABLE only
304
PNG_LIBPNG_BUILD_PRIVATE equ 16 ;Cannot be OR'ed with PNG_LIBPNG_BUILD_SPECIAL
305
PNG_LIBPNG_BUILD_SPECIAL equ 32 ;Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE
306
307
 
308
309
 
310
; We must not include leading zeros.
311
; Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
312
; version 1.0.0 was mis-numbered 100 instead of 10000).  From
313
; version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
314
315
 
316
317
 
318
; the library has been built.
319
320
 
321
 
322
323
 
324
; VS_FF_PRIVATEBUILD File *was not* built using standard release
325
; procedures. If this value is given, the StringFileInfo block must
326
; contain a PrivateBuild string.
327
328
 
329
; standard release procedures but is a variation of the standard
330
; file of the same version number. If this value is given, the
331
; StringFileInfo block must contain a SpecialBuild string.
332
333
 
334
;#  define PNG_LIBPNG_BUILD_TYPE \
335
;       (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)
336
;#else
337
;#  ifdef PNG_LIBPNG_SPECIALBUILD
338
;#    define PNG_LIBPNG_BUILD_TYPE \
339
;         (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)
340
;#  else
341
;#    define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)
342
;#  endif
343
;end if
344
345
 
346
347
 
348
; the version above.
349
350
 
351
352
 
353
354
 
355
; 2. Any configuration options that can be specified by for the application
356
;    code when it is built.  (Build time configuration is in pnglibconf.h)
357
; 3. Type definitions (base types are defined in pngconf.h), structure
358
;    definitions.
359
; 4. Exported library functions.
360
; 5. Simplified API.
361
; 6. Implementation options.
362
363
 
364
; allow configuration of the library.
365
366
 
367
 
368
369
 
370
; See pnglibconf.h for build time configuration
371
372
 
373
; implementations of certain arithmetic APIs.  The default is set
374
; at build time and recorded in pnglibconf.h, but it is safe to
375
; override these (and only these) settings.  Note that this won't
376
; change what the library does, only application code, and the
377
; settings can (and probably should) be made on a per-file basis
378
; by setting the #defines before including png.h
379
380
 
381
; functions?
382
;   PNG_USE_READ_MACROS: use the macros (see below)  Note that
383
;     the macros evaluate their argument multiple times.
384
;   PNG_NO_USE_READ_MACROS: call the relevant library function.
385
386
 
387
; does not use division?
388
;   PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'
389
;      algorithm.
390
;   PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.
391
392
 
393
; false?
394
;   PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error
395
;      APIs to png_warning.
396
; Otherwise the calls are mapped to png_error.
397
398
 
399
 
400
; constants.
401
; See pngconf.h for base types that vary by machine/system
402
403
 
404
 
405
; do not agree upon the version number.
406
407
 
408
409
 
410
411
 
412
; PNG file.  One of these is always required, although the simplified API
413
; (below) hides the creation and destruction of it.
414
415
 
416
; or more of these must exist while reading or creating a PNG file.  The
417
; information is not used by libpng during read but is used to control what
418
; gets written when a PNG file is created.  "png_get_" function calls read
419
; information during read and "png_set_" functions calls write information
420
; when creating a PNG.
421
; been moved into a separate header file that is not accessible to
422
; applications.  Read libpng-manual.txt or libpng.3 for more info.
423
424
 
425
; names ending 'rp' are identical pointer types except that the pointer is
426
; marked 'restrict', which means that it is the only pointer to the object
427
; passed to the function.  Applications should not use the 'restrict' types;
428
; it is always valid to pass 'p' to a pointer with a function argument of the
429
; corresponding 'rp' type.  Different compilers have different rules with
430
; regard to type matching in the presence of 'restrict'.  For backward
431
; compatibility libpng callbacks never have 'restrict' in their parameters and,
432
; consequentially, writing portable application code is extremely difficult if
433
; an attempt is made to use 'restrict'.
434
435
 
436
; exact size) is not important, although the size of the fields need to
437
; be byte or uint_16 (as defined below).
438
439
 
440
	red   db ? ;byte
441
	green db ? ;byte
442
	blue  db ? ;byte
443
ends
444
445
 
446
	index db ? ;byte ;used for palette files
447
	red   dw ? ;uint_16 ;for use in red green blue files
448
	green dw ? ;uint_16
449
	blue  dw ? ;uint_16
450
	gray  dw ? ;uint_16 ;for use in grayscale files
451
ends
452
453
 
454
	red   db ? ;byte ;for use in red green blue files
455
	green db ? ;byte
456
	blue  db ? ;byte
457
	gray  db ? ;byte ;for use in grayscale files
458
	alpha db ? ;byte ;for alpha channel files
459
ends
460
461
 
462
 
463
; of sPLT chunks.
464
465
 
466
	red   dw ? ;uint_16
467
	green dw ? ;uint_16
468
	blue  dw ? ;uint_16
469
	alpha dw ? ;uint_16
470
	frequency dw ? ;uint_16
471
ends
472
473
 
474
; occupy the LSB of their respective members, and the MSB of each member
475
; is zero-filled.  The frequency member always occupies the full 16 bits.
476
477
 
478
 
479
	name    dd ? ;charp ;palette name
480
	depth   db ? ;byte ;depth of palette samples
481
	entries dd ? ;png_sPLT_entryp ;palette entries
482
	nentries dd ? ;int_32 ;number of palette entries
483
ends
484
485
 
486
; png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
487
; and whether that contents is compressed or not.  The "key" field
488
; points to a regular zero-terminated C string.  The "text" fields can be a
489
; regular C string, an empty string, or a NULL pointer.
490
; However, the structure returned by png_get_text() will always contain
491
; the "text" field as a regular zero-terminated C string (possibly
492
; empty), never a NULL pointer, so it can be safely used in printf() and
493
; other string-handling functions.  Note that the "itxt_length", "lang", and
494
; "lang_key" members of the structure only exist when the library is built
495
; with iTXt chunk support.  Prior to libpng-1.4.0 the library was built by
496
; default without iTXt support. Also note that when iTXt *is* supported,
497
; the "lang" and "lang_key" fields contain NULL pointers when the
498
; "compression" field contains * PNG_TEXT_COMPRESSION_NONE or
499
; PNG_TEXT_COMPRESSION_zTXt. Note that the "compression value" is not the
500
; same as what appears in the PNG tEXt/zTXt/iTXt chunk's "compression flag"
501
; which is always 0 or 1, or its "compression method" which is always 0.
502
503
 
504
	compression dd ? ;int ;compression value:
505
			;-1: tEXt, none
506
			; 0: zTXt, deflate
507
			; 1: iTXt, none
508
			; 2: iTXt, deflate
509
	key  dd ? ;charp ;keyword, 1-79 character description of "text"
510
	text dd ? ;charp ;comment, may be an empty string (ie "")
511
			; or a NULL pointer
512
	text_length dd ? ;png_size_t ;length of the text string
513
	itxt_length dd ? ;png_size_t ;length of the itxt string
514
	lang dd ? ;charp ;language code, 0-79 characters
515
			; or a NULL pointer
516
	lang_key dd ? ;charp ;keyword translated UTF-8 string, 0 or more
517
			; chars or a NULL pointer
518
ends
519
end if
520
521
 
522
; The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed.
523
PNG_TEXT_COMPRESSION_NONE_WR equ -3
524
PNG_TEXT_COMPRESSION_zTXt_WR equ -2
525
PNG_TEXT_COMPRESSION_NONE    equ -1
526
PNG_TEXT_COMPRESSION_zTXt    equ 0
527
PNG_ITXT_COMPRESSION_NONE    equ 1
528
PNG_ITXT_COMPRESSION_zTXt    equ 2
529
PNG_TEXT_COMPRESSION_LAST    equ 3 ;Not a valid value
530
531
 
532
; Two conversions are provided, both from time_t and struct tm.  There
533
; is no portable way to convert to either of these structures, as far
534
; as I know.  If you know of a portable way, send it to me.  As a side
535
; note - PNG has always been Year 2000 compliant!
536
537
 
538
	year  dw ? ;uint_16 ;full year, as in, 1995
539
	month db ? ;byte ;month of year, 1 - 12
540
	day   db ? ;byte ;day of month, 1 - 31
541
	hour  db ? ;byte ;hour of day, 0 - 23
542
	minute db ? ;byte ;minute of hour, 0 - 59
543
	second db ? ;byte ;second of minute, 0 - 60 (for leap seconds)
544
ends
545
546
 
547
; png_unknown_chunk is a structure to hold queued chunks for which there is
548
; no specific support.  The idea is that we can use this to queue
549
; up private chunks for output even though the library doesn't actually
550
; know about their semantics.
551
552
 
553
554
 
555
	name rb 5 ;byte[5] ;Textual chunk name with '\0' terminator
556
	rb 3 ;align
557
	podata dd ? ;byte* ;Data, should not be modified on read!
558
	size dd ? ;png_size_t
559
560
 
561
	; Notice that on read it is set by libpng however the values stored have
562
	; more bits set than are listed below.  Always treat the value as a
563
	; bitmask.  On write set only one bit - setting multiple bits may cause the
564
	; chunk to be written in multiple places.
565
566
 
567
ends
568
end if
569
570
 
571
PNG_HAVE_IHDR equ  0x01
572
PNG_HAVE_PLTE equ  0x02
573
PNG_AFTER_IDAT equ 0x08
574
575
 
576
PNG_UINT_31_MAX equ 0x7fffffff ;uint_32
577
PNG_UINT_32_MAX equ -1 ;uint_32
578
PNG_SIZE_MAX    equ 0x60000000 ;1.5 Gb
579
580
 
581
; PNG specification manner (x100000)
582
583
 
584
PNG_FP_HALF equ 50000
585
PNG_FP_MAX equ ((png_fixed_point)0x7fffffffL)
586
PNG_FP_MIN equ (-PNG_FP_MAX)
587
588
 
589
; color type masks
590
PNG_COLOR_MASK_PALETTE equ 1
591
PNG_COLOR_MASK_COLOR   equ 2
592
PNG_COLOR_MASK_ALPHA   equ 4
593
594
 
595
PNG_COLOR_TYPE_GRAY equ 0
596
PNG_COLOR_TYPE_PALETTE equ (PNG_COLOR_MASK_COLOR or PNG_COLOR_MASK_PALETTE)
597
PNG_COLOR_TYPE_RGB      equ (PNG_COLOR_MASK_COLOR)
598
PNG_COLOR_TYPE_RGB_ALPHA equ (PNG_COLOR_MASK_COLOR or PNG_COLOR_MASK_ALPHA)
599
PNG_COLOR_TYPE_GRAY_ALPHA equ (PNG_COLOR_MASK_ALPHA)
600
; aliases
601
PNG_COLOR_TYPE_RGBA equ PNG_COLOR_TYPE_RGB_ALPHA
602
PNG_COLOR_TYPE_GA equ PNG_COLOR_TYPE_GRAY_ALPHA
603
604
 
605
PNG_COMPRESSION_TYPE_BASE equ 0 ;Deflate method 8, 32K window
606
PNG_COMPRESSION_TYPE_DEFAULT equ PNG_COMPRESSION_TYPE_BASE
607
608
 
609
PNG_FILTER_TYPE_BASE     equ 0 ;Single row per-byte filtering
610
PNG_INTRAPIXEL_DIFFERENCING equ 64 ;Used only in MNG datastreams
611
PNG_FILTER_TYPE_DEFAULT  equ PNG_FILTER_TYPE_BASE
612
613
 
614
PNG_INTERLACE_NONE       equ 0 ;Non-interlaced image
615
PNG_INTERLACE_ADAM7      equ 1 ;Adam7 interlacing
616
PNG_INTERLACE_LAST       equ 2 ;Not a valid value
617
618
 
619
PNG_OFFSET_PIXEL         equ 0 ;Offset in pixels
620
PNG_OFFSET_MICROMETER    equ 1 ;Offset in micrometers (1/10^6 meter)
621
PNG_OFFSET_LAST          equ 2 ;Not a valid value
622
623
 
624
PNG_EQUATION_LINEAR      equ 0 ;Linear transformation
625
PNG_EQUATION_BASE_E      equ 1 ;Exponential base e transform
626
PNG_EQUATION_ARBITRARY   equ 2 ;Arbitrary base exponential transform
627
PNG_EQUATION_HYPERBOLIC  equ 3 ;Hyperbolic sine transformation
628
PNG_EQUATION_LAST        equ 4 ;Not a valid value
629
630
 
631
PNG_SCALE_UNKNOWN        equ 0 ;unknown unit (image scale)
632
PNG_SCALE_METER          equ 1 ;meters per pixel
633
PNG_SCALE_RADIAN         equ 2 ;radians per pixel
634
PNG_SCALE_LAST           equ 3 ;Not a valid value
635
636
 
637
PNG_RESOLUTION_UNKNOWN   equ 0 ;pixels/unknown unit (aspect ratio)
638
PNG_RESOLUTION_METER     equ 1 ;pixels/meter
639
PNG_RESOLUTION_LAST      equ 2 ;Not a valid value
640
641
 
642
PNG_sRGB_INTENT_PERCEPTUAL equ 0
643
PNG_sRGB_INTENT_RELATIVE   equ 1
644
PNG_sRGB_INTENT_SATURATION equ 2
645
PNG_sRGB_INTENT_ABSOLUTE   equ 3
646
PNG_sRGB_INTENT_LAST       equ 4 ;Not a valid value
647
648
 
649
PNG_KEYWORD_MAX_LENGTH equ 79
650
651
 
652
PNG_MAX_PALETTE_LENGTH equ 256
653
654
 
655
; from the PNG header, or if the application has filled in the corresponding
656
; data in the info_struct to be written into the output file.  The values
657
; of the PNG_INFO_ defines should NOT be changed.
658
659
 
660
PNG_INFO_sBIT equ 0x0002
661
PNG_INFO_cHRM equ 0x0004
662
PNG_INFO_PLTE equ 0x0008
663
PNG_INFO_tRNS equ 0x0010
664
PNG_INFO_bKGD equ 0x0020
665
PNG_INFO_hIST equ 0x0040
666
PNG_INFO_pHYs equ 0x0080
667
PNG_INFO_oFFs equ 0x0100
668
PNG_INFO_tIME equ 0x0200
669
PNG_INFO_pCAL equ 0x0400
670
PNG_INFO_sRGB equ 0x0800 ; GR-P, 0.96a
671
PNG_INFO_iCCP equ 0x1000 ; ESR, 1.0.6
672
PNG_INFO_sPLT equ 0x2000 ; ESR, 1.0.6
673
PNG_INFO_sCAL equ 0x4000 ; ESR, 1.0.6
674
PNG_INFO_IDAT equ 0x8000 ; ESR, 1.0.6
675
676
 
677
; change these values for the row.  It also should enable using
678
; the routines for other purposes.
679
680
 
681
	width      dd ? ;uint_32 ;width of row
682
	rowbytes   dd ? ;png_size_t ;number of bytes in row
683
	color_type db ? ;byte ;color type of row
684
	bit_depth  db ? ;byte ;bit depth of row
685
	channels   db ? ;byte ;number of channels (1, 2, 3, or 4)
686
	pixel_depth db ? ;byte ;bits per pixel (depth * channels)
687
ends
688
689
 
690
; This must match the function definition in , and the application
691
; must include this before png.h to obtain the definition of jmp_buf.  The
692
; function is required to be PNG_NORETURN, but this is not checked.  If the
693
; function does return the application will crash via an abort() or similar
694
; system level call.
695
696
 
697
; changes to ensure that pnglibconf.h records the calling convention used by
698
; your compiler.  This may be very difficult - try using a different compiler
699
; to build the library!
700
701
 
702
end if
703
704
 
705
PNG_TRANSFORM_IDENTITY      equ 0x0000 ; read and write
706
PNG_TRANSFORM_STRIP_16      equ 0x0001 ; read only
707
PNG_TRANSFORM_STRIP_ALPHA   equ 0x0002 ; read only
708
PNG_TRANSFORM_PACKING       equ 0x0004 ; read and write
709
PNG_TRANSFORM_PACKSWAP      equ 0x0008 ; read and write
710
PNG_TRANSFORM_EXPAND        equ 0x0010 ; read only
711
PNG_TRANSFORM_INVERT_MONO   equ 0x0020 ; read and write
712
PNG_TRANSFORM_SHIFT         equ 0x0040 ; read and write
713
PNG_TRANSFORM_BGR           equ 0x0080 ; read and write
714
PNG_TRANSFORM_SWAP_ALPHA    equ 0x0100 ; read and write
715
PNG_TRANSFORM_SWAP_ENDIAN   equ 0x0200 ; read and write
716
PNG_TRANSFORM_INVERT_ALPHA  equ 0x0400 ; read and write
717
PNG_TRANSFORM_STRIP_FILLER  equ 0x0800 ; write only
718
; Added to libpng-1.2.34
719
PNG_TRANSFORM_STRIP_FILLER_BEFORE equ PNG_TRANSFORM_STRIP_FILLER
720
PNG_TRANSFORM_STRIP_FILLER_AFTER equ 0x1000 ; write only
721
; Added to libpng-1.4.0
722
PNG_TRANSFORM_GRAY_TO_RGB  equ 0x2000 ; read only
723
; Added to libpng-1.5.4
724
PNG_TRANSFORM_EXPAND_16    equ 0x4000 ;read only
725
;if INT_MAX >= 0x8000 ;else this might break
726
PNG_TRANSFORM_SCALE_16     equ 0x8000 ;read only
727
;end if
728
729
 
730
PNG_FLAG_MNG_EMPTY_PLTE    equ 0x01
731
PNG_FLAG_MNG_FILTER_64     equ 0x04
732
PNG_ALL_MNG_FEATURES       equ 0x05
733
734
 
735
; this allowed the zlib default functions to be used on Windows
736
; platforms.  In 1.5 the zlib default malloc (which just calls malloc and
737
; ignores the first argument) should be completely compatible with the
738
; following.
739
740
 
741
; Here are the function definitions most commonly used.  This is not
742
; the place to find out how to use libpng.  See libpng-manual.txt for the
743
; full explanation, see example.c for the summary.  This just provides
744
; a simple one line description of the use of each function.
745
746
 
747
 
748
 
749
; png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
750
751
 
752
753
 
754
{
755
local .end0
756
	and eax,0xff
757
if PNG_USE_ABS eq 1
758
	add sum,128
759
	sub al,128 ;v - 128
760
	cmp al,128
761
	jl @f
762
		neg al
763
		inc al ;abs(v - 128)
764
	@@:
765
	sub sum,eax
766
else
767
	cmp eax,128
768
	jl @f
769
		add sum,256
770
		sub sum,eax
771
		jmp .end0
772
	@@:
773
		add sum,eax
774
	.end0:
775
end if
776
}
777
778
 
779
PNG_ERROR_ACTION_NONE equ 1
780
PNG_ERROR_ACTION_WARN equ 2
781
PNG_ERROR_ACTION_ERROR equ 3
782
PNG_RGB_TO_GRAY_DEFAULT equ (-1) ;for red/green coefficients
783
784
 
785
; of a PNG file are returned to the calling application when an alpha channel,
786
; or a tRNS chunk in a palette file, is present.
787
788
 
789
; datastream. The color samples in a PNG datastream are never premultiplied
790
; with the alpha samples.
791
792
 
793
; channel is a linear measure of the contribution of the pixel to the
794
; corresponding composited pixel, and the color channels are unassociated
795
; (not premultiplied).  The gamma encoded color channels must be scaled
796
; according to the contribution and to do this it is necessary to undo
797
; the encoding, scale the color values, perform the composition and reencode
798
; the values.  This is the 'PNG' mode.
799
800
 
801
; storing color channel values that have been scaled by the alpha.
802
; image.  These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes
803
; (the latter being the two common names for associated alpha color channels).
804
805
 
806
; value is equal to the maximum value.
807
808
 
809
; broken because, in practice, no implementation that uses this choice
810
; correctly undoes the encoding before handling alpha composition.  Use this
811
; choice only if other serious errors in the software or hardware you use
812
; mandate it; the typical serious error is for dark halos to appear around
813
; opaque areas of the composited PNG image because of arithmetic overflow.
814
815
 
816
; with an enumerated 'mode' value and the gamma of the required output:
817
818
 
819
PNG_ALPHA_STANDARD     equ 1 ;according to Porter/Duff
820
PNG_ALPHA_ASSOCIATED   equ 1 ;as above; this is the normal practice
821
PNG_ALPHA_PREMULTIPLIED equ 1 ;as above
822
PNG_ALPHA_OPTIMIZED    equ 2 ;'PNG' for opaque pixels, else 'STANDARD'
823
PNG_ALPHA_BROKEN       equ 3 ;the alpha channel is gamma encoded
824
825
 
826
; The output_gamma value is a screen gamma in libpng terminology: it expresses
827
; how to decode the output values, not how they are encoded.
828
829
 
830
PNG_GAMMA_MAC_18 equ -2       ;Old Mac '1.8' gamma and color space
831
PNG_GAMMA_sRGB   equ 220000   ;Television standards--matches sRGB gamma
832
PNG_GAMMA_LINEAR equ PNG_FP_1 ;Linear
833
end if
834
835
 
836
PNG_FILLER_BEFORE equ 0
837
PNG_FILLER_AFTER equ 1
838
839
 
840
841
 
842
; libpng-1.5.4 this API must not be called before the PNG file header has been
843
; read.  Doing so will result in unexpected behavior and possible warnings or
844
; errors if the PNG file contains a bKGD chunk.
845
846
 
847
PNG_BACKGROUND_GAMMA_UNKNOWN equ 0
848
PNG_BACKGROUND_GAMMA_SCREEN equ 1
849
PNG_BACKGROUND_GAMMA_FILE   equ 2
850
PNG_BACKGROUND_GAMMA_UNIQUE equ 3
851
end if
852
853
 
854
855
 
856
; library.  The following is the floating point variant.
857
858
 
859
860
 
861
; NOTE: this API simply sets the screen and file gamma values. It will
862
; therefore override the value for gamma in a PNG file if it is called after
863
; the file header has been read - use with care  - call before reading the PNG
864
; file for best results!
865
866
 
867
 
868
; ancillary and critical chunks, and whether to use the data contained
869
; therein.  Note that it is impossible to "discard" data in a critical
870
; chunk.  For versions prior to 0.90, the action was always error/quit,
871
; whereas in version 0.90 and later, the action for CRC errors in ancillary
872
; chunks is warn/discard.  These values should NOT be changed.
873
874
 
875
876
 
877
PNG_CRC_ERROR_QUIT   equ 1 ;error/quit          error/quit
878
PNG_CRC_WARN_DISCARD equ 2 ;(INVALID)           warn/discard data
879
PNG_CRC_WARN_USE     equ 3 ;warn/use data       warn/use data
880
PNG_CRC_QUIET_USE    equ 4 ;quiet/use data      quiet/use data
881
PNG_CRC_NO_CHANGE    equ 5 ;use current value   use current value
882
883
 
884
; are chosen so that they don't conflict with real filter types
885
; below, in case they are supplied instead of the #defined constants.
886
; These values should NOT be changed.
887
888
 
889
PNG_FILTER_NONE  equ 0x08
890
PNG_FILTER_SUB   equ 0x10
891
PNG_FILTER_UP    equ 0x20
892
PNG_FILTER_AVG   equ 0x40
893
PNG_FILTER_PAETH equ 0x80
894
PNG_FAST_FILTERS equ (PNG_FILTER_NONE or PNG_FILTER_SUB or PNG_FILTER_UP)
895
PNG_ALL_FILTERS  equ (PNG_FAST_FILTERS or PNG_FILTER_AVG or PNG_FILTER_PAETH)
896
897
 
898
; These defines should NOT be changed.
899
900
 
901
PNG_FILTER_VALUE_SUB  equ 1
902
PNG_FILTER_VALUE_UP   equ 2
903
PNG_FILTER_VALUE_AVG  equ 3
904
PNG_FILTER_VALUE_PAETH equ 4
905
PNG_FILTER_VALUE_LAST equ 5
906
907
 
908
PNG_FILTER_HEURISTIC_DEFAULT   equ 0 ;Currently "UNWEIGHTED"
909
PNG_FILTER_HEURISTIC_UNWEIGHTED equ 1 ;Used by libpng < 0.95
910
PNG_FILTER_HEURISTIC_WEIGHTED  equ 2 ;Experimental feature
911
PNG_FILTER_HEURISTIC_LAST      equ 3 ;Not a valid value
912
913
 
914
; may result either in memory leaks or double free of allocated data.
915
916
 
917
PNG_DESTROY_WILL_FREE_DATA equ 1
918
PNG_SET_WILL_FREE_DATA equ 1
919
PNG_USER_WILL_FREE_DATA equ 2
920
; Flags for png_ptr->free_me and info_ptr->free_me
921
PNG_FREE_HIST equ 0x0008
922
PNG_FREE_ICCP equ 0x0010
923
PNG_FREE_SPLT equ 0x0020
924
PNG_FREE_ROWS equ 0x0040
925
PNG_FREE_PCAL equ 0x0080
926
PNG_FREE_SCAL equ 0x0100
927
if PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED eq 1
928
	PNG_FREE_UNKN equ 0x0200
929
end if
930
PNG_FREE_LIST equ 0x0400 ;removed in 1.6.0 because it is ignored
931
PNG_FREE_PLTE equ 0x1000
932
PNG_FREE_TRNS equ 0x2000
933
PNG_FREE_TEXT equ 0x4000
934
PNG_FREE_ALL  equ 0x7fff
935
PNG_FREE_MUL  equ 0x4220 ;PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN
936
937
 
938
939
 
940
;#  define png_chunk_error(s1,s2) png_err(s1)
941
;end if
942
943
 
944
;#  define png_warning(s1,s2) ((void)(s1))
945
;#  define png_chunk_warning(s1,s2) ((void)(s1))
946
947
 
948
949
 
950
;#  ifdef PNG_ALLOW_BENIGN_ERRORS
951
macro png_benign_error h,txt
952
{
953
	png_warning h,txt
954
}
955
;#    define png_chunk_benign_error png_chunk_warning
956
;#  else
957
;#    define png_benign_error png_error
958
;#    define png_chunk_benign_error png_chunk_error
959
;#  endif
960
;end if
961
962
 
963
 
964
; specific unknown chunks.
965
966
 
967
; ignored and the default was used, the per-chunk setting only had an effect on
968
; write.  If you wish to have chunk-specific handling on read in code that must
969
; work on earlier versions you must use a user chunk callback to specify the
970
; desired handling (keep or discard.)
971
972
 
973
; parameter is interpreted as follows:
974
975
 
976
;    PNG_HANDLE_CHUNK_AS_DEFAULT:
977
;       Known chunks: do normal libpng processing, do not keep the chunk (but
978
;          see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
979
;       Unknown chunks: for a specific chunk use the global default, when used
980
;          as the default discard the chunk data.
981
;    PNG_HANDLE_CHUNK_NEVER:
982
;       Discard the chunk data.
983
;    PNG_HANDLE_CHUNK_IF_SAFE:
984
;       Keep the chunk data if the chunk is not critical else raise a chunk
985
;       error.
986
;    PNG_HANDLE_CHUNK_ALWAYS:
987
;       Keep the chunk data.
988
989
 
990
; below.  Notice that specifying "AS_DEFAULT" as a global default is equivalent
991
; to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks
992
; it simply resets the behavior to the libpng default.
993
994
 
995
; The per-chunk handling is always used when there is a png_user_chunk_ptr
996
; callback and the callback returns 0; the chunk is then always stored *unless*
997
; it is critical and the per-chunk setting is other than ALWAYS.  Notice that
998
; the global default is *not* used in this case.  (In effect the per-chunk
999
; value is incremented to at least IF_SAFE.)
1000
1001
 
1002
; per-chunk defaults will be honored.  If you want to preserve the current
1003
; behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE
1004
; as the default - if you don't do this libpng 1.6 will issue a warning.
1005
1006
 
1007
; earlier simply return '1' (handled).
1008
1009
 
1010
;    If this is *not* set known chunks will always be handled by libpng and
1011
;    will never be stored in the unknown chunk list.  Known chunks listed to
1012
;    png_set_keep_unknown_chunks will have no effect.  If it is set then known
1013
;    chunks listed with a keep other than AS_DEFAULT will *never* be processed
1014
;    by libpng, in addition critical chunks must either be processed by the
1015
;    callback or saved.
1016
1017
 
1018
;    default handling for chunks that would otherwise be recognized the
1019
;    behavior of libpng transformations may well become incorrect!
1020
1021
 
1022
;    When writing chunks the options only apply to the chunks specified by
1023
;    png_set_unknown_chunks (below), libpng will *always* write known chunks
1024
;    required by png_set_ calls and will always write the core critical chunks
1025
;    (as required for PLTE).
1026
1027
 
1028
;    png_set_keep_unknown_chunks list to find the keep setting, this is then
1029
;    interpreted as follows:
1030
1031
 
1032
;       Write safe-to-copy chunks and write other chunks if the global
1033
;       default is set to _ALWAYS, otherwise don't write this chunk.
1034
;    PNG_HANDLE_CHUNK_NEVER:
1035
;       Do not write the chunk.
1036
;    PNG_HANDLE_CHUNK_IF_SAFE:
1037
;       Write the chunk if it is safe-to-copy, otherwise do not write it.
1038
;    PNG_HANDLE_CHUNK_ALWAYS:
1039
;       Write the chunk.
1040
1041
 
1042
; in read unknown chunks are not stored by default, in write they are written
1043
; by default.  Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different
1044
; - on write the safe-to-copy bit is checked, on read the critical bit is
1045
; checked and on read if the chunk is critical an error will be raised.
1046
1047
 
1048
; ===========
1049
;    If num_chunks is positive, then the "keep" parameter specifies the manner
1050
;    for handling only those chunks appearing in the chunk_list array,
1051
;    otherwise the chunk list array is ignored.
1052
1053
 
1054
;    unknown chunks, as described above.
1055
1056
 
1057
;    for handling all unknown chunks plus all chunks recognized by libpng
1058
;    except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to
1059
;    be processed by libpng.
1060
1061
 
1062
 
1063
PNG_HANDLE_CHUNK_AS_DEFAULT  equ 0
1064
PNG_HANDLE_CHUNK_NEVER       equ 1
1065
PNG_HANDLE_CHUNK_IF_SAFE     equ 2
1066
PNG_HANDLE_CHUNK_ALWAYS      equ 3
1067
PNG_HANDLE_CHUNK_LAST        equ 4
1068
1069
 
1070
;PNG_REMOVED(200, bytep, png_get_io_chunk_name, (png_structrp png_ptr),
1071
;    PNG_DEPRECATED)
1072
1073
 
1074
PNG_IO_NONE        equ 0x0000 ; no I/O at this moment
1075
PNG_IO_READING     equ 0x0001 ; currently reading
1076
PNG_IO_WRITING     equ 0x0002 ; currently writing
1077
PNG_IO_SIGNATURE   equ 0x0010 ; currently at the file signature
1078
PNG_IO_CHUNK_HDR   equ 0x0020 ; currently at the chunk header
1079
PNG_IO_CHUNK_DATA  equ 0x0040 ; currently at the chunk data
1080
PNG_IO_CHUNK_CRC   equ 0x0080 ; currently at the chunk crc
1081
PNG_IO_MASK_OP     equ 0x000f ; current operation: reading/writing
1082
PNG_IO_MASK_LOC    equ 0x00f0 ; current location: sig/hdr/data/crc
1083
;end if /* IO_STATE */
1084
1085
 
1086
; libpng interlace handling is turned off the macros may be used to handle
1087
; interlaced images within the application.
1088
1089
 
1090
1091
 
1092
; full, image which appears in a given pass.  'pass' is in the range 0
1093
; to 6 and the result is in the range 0 to 7.
1094
1095
 
1096
{
1097
	push ebx ecx
1098
	mov eax,pass
1099
	mov ebx,eax
1100
	not eax
1101
	and eax,1
1102
	shr ebx,1
1103
	mov ecx,3
1104
	sub ecx,ebx
1105
	shl eax,cl
1106
	and eax,7
1107
	pop ecx ebx
1108
}
1109
macro PNG_PASS_START_COL pass
1110
{
1111
	push ebx ecx
1112
	mov eax,pass
1113
	mov ebx,eax
1114
	and eax,1
1115
	inc ebx
1116
	shr ebx,1
1117
	mov ecx,3
1118
	sub ecx,ebx
1119
	shl eax,cl
1120
	and eax,7
1121
	pop ecx ebx
1122
}
1123
1124
 
1125
; pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that
1126
; follows.  Note that ROW_OFFSET is the offset from one row to the next whereas
1127
; COL_OFFSET is from one column to the next, within a row.
1128
1129
 
1130
;#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1))
1131
1132
 
1133
; pass.  This is expressed as a shift - effectively log2 of the number or
1134
; rows or columns in each 8x8 tile of the original image.
1135
1136
 
1137
{
1138
local .end0
1139
	mov eax,3
1140
	cmp pass,2
1141
	jle .end0
1142
		mov eax,8
1143
		sub eax,pass
1144
		shr eax,1
1145
	.end0:
1146
}
1147
macro PNG_PASS_COL_SHIFT pass
1148
{
1149
local .end0
1150
	mov eax,3
1151
	cmp pass,1
1152
	jle .end0
1153
		mov eax,7
1154
		sub eax,pass
1155
		shr eax,1
1156
	.end0:
1157
}
1158
1159
 
1160
; pass of an image given its height or width.  In fact these macros may
1161
; return non-zero even though the sub-image is empty, because the other
1162
; dimension may be empty for a small image.
1163
1164
 
1165
{
1166
push ecx
1167
push ebx
1168
	PNG_PASS_START_ROW pass
1169
	mov ebx,eax
1170
	PNG_PASS_ROW_SHIFT pass
1171
	mov ecx,eax
1172
	xor eax,eax
1173
	inc eax
1174
	shl eax,cl
1175
	dec eax
1176
	sub eax,ebx
1177
pop ebx
1178
	add eax,height
1179
	shr eax,cl
1180
pop ecx
1181
}
1182
macro PNG_PASS_COLS width, pass
1183
{
1184
push ecx
1185
push ebx
1186
	PNG_PASS_START_COL pass
1187
	mov ebx,eax
1188
	PNG_PASS_COL_SHIFT pass
1189
	mov ecx,eax
1190
	xor eax,eax
1191
	inc eax
1192
	shl eax,cl
1193
	dec eax
1194
	sub eax,ebx
1195
pop ebx
1196
	add eax,width
1197
	shr eax,cl
1198
pop ecx
1199
}
1200
1201
 
1202
; necessary to find the row in the output image given a row in an interlaced
1203
; image, so two more macros:
1204
1205
 
1206
;   (((y_in)<
1207
;#define PNG_COL_FROM_PASS_COL(x_in, pass) \
1208
;   (((x_in)<
1209
1210
 
1211
; or column is in a particular pass.  These use a common utility macro that
1212
; returns a mask for a given pass - the offset 'off' selects the row or
1213
; column version.  The mask has the appropriate bit set for each column in
1214
; the tile.
1215
1216
 
1217
;   ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \
1218
;   ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0))
1219
1220
 
1221
;   ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)
1222
;#define PNG_COL_IN_INTERLACE_PASS(x, pass) \
1223
;   ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)
1224
1225
 
1226
; With these routines we avoid an integer divide, which will be slower on
1227
; most machines.  However, it does take more operations than the corresponding
1228
; divide method, so it may be slower on a few RISC systems.  There are two
1229
; shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
1230
1231
 
1232
; 32768 are correct for the NODIV code; 127 and 32767 are correct for the
1233
; standard method.
1234
1235
 
1236
1237
 
1238
 
1239
1240
 
1241
;   {                                                     \
1242
;      uint_16 temp = (uint_16)((uint_16)(fg) \
1243
;          * (uint_16)(alpha)                         \
1244
;          + (uint_16)(bg)*(uint_16)(255          \
1245
;          - (uint_16)(alpha)) + 128);                \
1246
;      (composite) = (byte)(((temp + (temp >> 8)) >> 8) & 0xff); \
1247
;   }
1248
1249
 
1250
;   {                                                     \
1251
;      uint_32 temp = (uint_32)((uint_32)(fg) \
1252
;          * (uint_32)(alpha)                         \
1253
;          + (uint_32)(bg)*(65535                     \
1254
;          - (uint_32)(alpha)) + 32768);              \
1255
;      (composite) = (uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); \
1256
;   }
1257
1258
 
1259
1260
 
1261
;   (composite) =                                                       \
1262
;       (byte)(0xff & (((uint_16)(fg) * (uint_16)(alpha) +  \
1263
;       (uint_16)(bg) * (uint_16)(255 - (uint_16)(alpha)) + \
1264
;       127) / 255))
1265
1266
 
1267
;   (composite) =                                                           \
1268
;       (uint_16)(0xffff & (((uint_32)(fg) * (uint_32)(alpha) + \
1269
;       (uint_32)(bg)*(uint_32)(65535 - (uint_32)(alpha)) +     \
1270
;       32767) / 65535))
1271
;end if /* READ_COMPOSITE_NODIV */
1272
1273
 
1274
; Inline macros to do direct reads of bytes from the input buffer.
1275
; The png_get_int_32() routine assumes we are using two's complement
1276
; format for negative values, which is almost certainly true.
1277
1278
 
1279
;   (((uint_32)(*(buf)) << 24) + \
1280
;    ((uint_32)(*((buf) + 1)) << 16) + \
1281
;    ((uint_32)(*((buf) + 2)) << 8) + \
1282
;    ((uint_32)(*((buf) + 3))))
1283
1284
 
1285
	; function) incorrectly returned a value of type uint_32.
1286
1287
 
1288
;   ((uint_16) \
1289
;    (((unsigned int)(*(buf)) << 8) + \
1290
;    ((unsigned int)(*((buf) + 1)))))
1291
1292
 
1293
;   ((int_32)((*(buf) & 0x80) \
1294
;    ? -((int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
1295
;    : (int_32)png_get_uint_32(buf)))
1296
end if
1297
1298
 
1299
; Section 5: SIMPLIFIED API
1300
; *******************************************************************************
1301
1302
 
1303
; documentation) if you don't understand what follows.
1304
1305
 
1306
; itself.  It allows PNG files to be read into a very limited number of
1307
; in-memory bitmap formats or to be written from the same formats.  If these
1308
; formats do not accomodate your needs then you can, and should, use the more
1309
; sophisticated APIs above - these support a wide variety of in-memory formats
1310
; and a wide variety of sophisticated transformations to those formats as well
1311
; as a wide variety of APIs to manipulate ancillary information.
1312
1313
 
1314
1315
 
1316
;    version field to PNG_IMAGE_VERSION and the 'opaque' pointer to NULL
1317
;    (this is REQUIRED, your program may crash if you don't do it.)
1318
; 2) Call the appropriate png_image_begin_read... function.
1319
; 3) Set the png_image 'format' member to the required sample format.
1320
; 4) Allocate a buffer for the image and, if required, the color-map.
1321
; 5) Call png_image_finish_read to read the image and, if required, the
1322
;    color-map into your buffers.
1323
1324
 
1325
; color types, bit depths, and interlace methods are acceptable, and the
1326
; input image is transformed as necessary to the requested in-memory format
1327
; during the png_image_finish_read() step.  The only caveat is that if you
1328
; request a color-mapped image from a PNG that is full-color or makes
1329
; complex use of an alpha channel the transformation is extremely lossy and the
1330
; result may look terrible.
1331
1332
 
1333
1334
 
1335
; 2) Initialize the members of the structure that describe the image, setting
1336
;    the 'format' member to the format of the image samples.
1337
; 3) Call the appropriate png_image_write... function with a pointer to the
1338
;    image and, if necessary, the color-map to write the PNG data.
1339
1340
 
1341
; when it is being read or defines the in-memory format of an image that you
1342
; need to write:
1343
1344
 
1345
;    defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
1346
1347
 
1348
1349
 
1350
	opaque  dd ? ;png_controlp ;Initialize to NULL, free with png_image_free
1351
	version dd ? ;uint_32  ;Set to PNG_IMAGE_VERSION
1352
	width   dd ? ;uint_32  ;Image width in pixels (columns)
1353
	height  dd ? ;uint_32  ;Image height in pixels (rows)
1354
	format  dd ? ;uint_32  ;Image format as defined below
1355
	flags   dd ? ;uint_32  ;A bit mask containing informational flags
1356
	colormap_entries dd ? ;uint_32 ;Number of entries in the color-map
1357
1358
 
1359
	; non-zero value and the 'message' field will contain a '\0' terminated
1360
	; string with the libpng error or warning message.  If both warnings and
1361
	; an error were encountered, only the error is recorded.  If there
1362
	; are multiple warnings, only the first one is recorded.
1363
1364
 
1365
	; a value as follows:
1366
1367
 
1368
PNG_IMAGE_ERROR equ 2
1369
1370
 
1371
; a failure in the API just called:
1372
1373
 
1374
;    1 - warning
1375
;    2 - error
1376
;    3 - error preceded by warning
1377
1378
 
1379
1380
 
1381
	message rb 64 ;char[64]
1382
ends
1383
1384
 
1385
; original values in the range 0 to 1.0:
1386
1387
 
1388
; 2: A gray/luminance channel and an alpha channel (GA).
1389
; 3: Three red, green, blue color channels (RGB).
1390
; 4: Three color channels and an alpha channel (RGBA).
1391
1392
 
1393
1394
 
1395
; alpha channel the original value is simply value/255.  For the color or
1396
; luminance channels the value is encoded according to the sRGB specification
1397
; and matches the 8-bit format expected by typical display devices.
1398
1399
 
1400
; channel and are suitable for passing to color management software.
1401
1402
 
1403
; channels can be converted to the original value by dividing by 65535; all
1404
; channels are linear.  Color channels use the RGB encoding (RGB end-points) of
1405
; the sRGB specification.  This encoding is identified by the
1406
; PNG_FORMAT_FLAG_LINEAR flag below.
1407
1408
 
1409
; the actual sRGB transfer curve defined in the sRGB specification (see the
1410
; article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
1411
; approximation used elsewhere in libpng.
1412
1413
 
1414
; of the color or luminance channels and is returned as an associated alpha
1415
; channel: the color/gray channels are scaled (pre-multiplied) by the alpha
1416
; value.
1417
1418
 
1419
; bytes per pixel according to the encoding, or are held in a color-map indexed
1420
; by bytes in the image data.  In the case of a color-map the color-map entries
1421
; are individual samples, encoded as above, and the image data has one byte per
1422
; pixel to select the relevant sample from the color-map.
1423
1424
 
1425
 
1426
1427
 
1428
; particular layout of sample data and, if present, alpha values.  There are
1429
; separate defines for each of the two component encodings.
1430
1431
 
1432
; valid.  Formats can be built up from the flag values or you can use one of
1433
; the predefined values below.  When testing formats always use the FORMAT_FLAG
1434
; macros to test for individual features - future versions of the library may
1435
; add new flags.
1436
1437
 
1438
; format of the entries in the color-map then png_image_{read,write}_colormap
1439
; called to read or write the color-map and set the format correctly for the
1440
; image data.  Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly!
1441
1442
 
1443
; compiler errors because the definition of one of the following flags has been
1444
; compiled out it is because libpng does not have the required support.  It is
1445
; possible, however, for the libpng configuration to enable the format on just
1446
; read or just write; in that case you may see an error at run time.  You can
1447
; guard against this by checking for the definition of the appropriate
1448
; "_SUPPORTED" macro, one of:
1449
1450
 
1451
1452
 
1453
PNG_FORMAT_FLAG_COLOR    equ 0x02 ;color format: otherwise grayscale
1454
PNG_FORMAT_FLAG_LINEAR   equ 0x04 ;2-byte channels else 1-byte
1455
PNG_FORMAT_FLAG_COLORMAP equ 0x08 ;image data is color-mapped
1456
1457
 
1458
1459
 
1460
1461
 
1462
1463
 
1464
1465
 
1466
PNG_FORMAT_GA  equ PNG_FORMAT_FLAG_ALPHA
1467
PNG_FORMAT_AG  equ (PNG_FORMAT_GA or PNG_FORMAT_FLAG_AFIRST)
8463 IgorA 1468
PNG_FORMAT_RGB equ PNG_FORMAT_FLAG_COLOR
8341 dunkaist 1469
PNG_FORMAT_BGR equ (PNG_FORMAT_FLAG_COLOR or PNG_FORMAT_FLAG_BGR)
8463 IgorA 1470
PNG_FORMAT_RGBA equ (PNG_FORMAT_RGB or PNG_FORMAT_FLAG_ALPHA)
1471
PNG_FORMAT_ARGB equ (PNG_FORMAT_RGBA or PNG_FORMAT_FLAG_AFIRST)
1472
PNG_FORMAT_BGRA equ (PNG_FORMAT_BGR or PNG_FORMAT_FLAG_ALPHA)
1473
PNG_FORMAT_ABGR equ (PNG_FORMAT_BGRA or PNG_FORMAT_FLAG_AFIRST)
1474
8341 dunkaist 1475
 
1476
; indicate a luminance (gray) channel.
1477
1478
 
1479
PNG_FORMAT_LINEAR_Y_ALPHA equ (PNG_FORMAT_FLAG_LINEAR or PNG_FORMAT_FLAG_ALPHA)
8463 IgorA 1480
PNG_FORMAT_LINEAR_RGB equ (PNG_FORMAT_FLAG_LINEAR or PNG_FORMAT_FLAG_COLOR)
1481
PNG_FORMAT_LINEAR_RGB_ALPHA equ\
8341 dunkaist 1482
	(PNG_FORMAT_FLAG_LINEAR or PNG_FORMAT_FLAG_COLOR or PNG_FORMAT_FLAG_ALPHA)
8463 IgorA 1483
8341 dunkaist 1484
 
1485
; is an index into the color-map which is formatted as above.  To obtain a
1486
; color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP
1487
; to one of the above definitions, or you can use one of the definitions below.
1488
1489
 
8463 IgorA 1490
PNG_FORMAT_BGR_COLORMAP equ (PNG_FORMAT_BGR or PNG_FORMAT_FLAG_COLORMAP)
1491
PNG_FORMAT_RGBA_COLORMAP equ (PNG_FORMAT_RGBA or PNG_FORMAT_FLAG_COLORMAP)
1492
PNG_FORMAT_ARGB_COLORMAP equ (PNG_FORMAT_ARGB or PNG_FORMAT_FLAG_COLORMAP)
1493
PNG_FORMAT_BGRA_COLORMAP equ (PNG_FORMAT_BGRA or PNG_FORMAT_FLAG_COLORMAP)
1494
PNG_FORMAT_ABGR_COLORMAP equ (PNG_FORMAT_ABGR or PNG_FORMAT_FLAG_COLORMAP)
1495
8341 dunkaist 1496
 
1497
1498
 
1499
; structure.  The PNG_IMAGE_SAMPLE_ macros return values appropriate to the
1500
; actual image sample values - either the entries in the color-map or the
1501
; pixels in the image.  The PNG_IMAGE_PIXEL_ macros return corresponding values
1502
; for the pixels and will always return 1 for color-mapped formats.  The
1503
; remaining macros return information about the rows in the image and the
1504
; complete image.
1505
1506
 
1507
; constants if the format parameter is, itself, a constant.  Therefore these
1508
; macros can be used in array declarations and case labels where required.
1509
; Similarly the macros are also pre-processor constants (sizeof is not used) so
1510
; they can be used in #if tests.
1511
1512
 
1513
1514
 
1515
{
1516
	mov eax,fmt
1517
	and eax,PNG_FORMAT_FLAG_COLOR or PNG_FORMAT_FLAG_ALPHA
1518
	inc eax
1519
}
1520
; Return the total number of channels in a given format: 1..4
1521
1522
 
1523
;   ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1)
1524
;   /* Return the size in bytes of a single component of a pixel or color-map
1525
; entry (as appropriate) in the image: 1 or 2.
1526
1527
 
1528
 
1529
;   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt))
1530
;   /* This is the size of the sample data for one sample.  If the image is
1531
; color-mapped it is the size of one color-map entry (and image pixels are
1532
; one byte in size), otherwise it is the size of one image pixel.
1533
1534
 
1535
 
1536
;   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256)
1537
;   /* The maximum size of the color-map required by the format expressed in a
1538
; count of components.  This can be used to compile-time allocate a
1539
; color-map:
1540
1541
 
1542
1543
 
1544
1545
 
1546
; information from one of the png_image_begin_read_ APIs and dynamically
1547
; allocate the required memory.
1548
1549
 
1550
 
1551
macro PNG_IMAGE_PIXEL_ p1,fmt
1552
{
1553
local .end0
1554
local .end1
1555
	mov eax,fmt
1556
	and eax,PNG_FORMAT_FLAG_COLORMAP
1557
	or eax,eax
8463 IgorA 1558
	jz .end0
1559
		xor eax,eax
8341 dunkaist 1560
		inc eax
1561
		jmp .end1
1562
	.end0:
1563
		p1 fmt
1564
	.end1:
1565
}
1566
1567
 
1568
{
1569
	PNG_IMAGE_PIXEL_ PNG_IMAGE_SAMPLE_CHANNELS,fmt
1570
}
1571
; The number of separate channels (components) in a pixel; 1 for a
1572
; color-mapped image.
1573
1574
 
1575
 
8463 IgorA 1576
{
1577
	PNG_IMAGE_PIXEL_ PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt
1578
}
1579
; The size, in bytes, of each component in a pixel; 1 for a color-mapped
1580
; image.
8341 dunkaist 1581
1582
 
1583
 
1584
;   /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */
1585
1586
 
1587
;#define PNG_IMAGE_ROW_STRIDE(image)\
1588
;   (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width)
1589
; Return the total number of components in a single row of the image; this
1590
; is the minimum 'row stride', the minimum count of components between each
1591
; row.  For a color-mapped image this is the minimum number of bytes in a
1592
; row.
1593
1594
 
1595
; and very large image widths.  libpng will refuse to process an image where
1596
; this macro would overflow.
1597
1598
 
1599
 
1600
;   (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))
1601
; Return the size, in bytes, of an image buffer given a png_image and a row
1602
; stride - the number of components to leave space for in each row.
1603
1604
 
1605
; libpng will refuse to process an image where such an overflow would occur.
1606
1607
 
1608
 
1609
;   PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))
1610
; Return the size, in bytes, of the image in memory given just a png_image;
1611
; the row stride is the minimum stride required for the image.
1612
1613
 
1614
 
1615
;   (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)
1616
; Return the size, in bytes, of the color-map of this image.  If the image
1617
; format is not a color-map format this will return a size sufficient for
1618
; 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if
1619
; you don't want to allocate a color-map in this case.
1620
1621
 
1622
 
1623
1624
 
1625
; 'flags' field of png_image.
1626
1627
 
1628
; This indicates the the RGB values of the in-memory bitmap do not
1629
; correspond to the red, green and blue end-points defined by sRGB.
1630
1631
 
1632
; On write emphasise speed over compression; the resultant PNG file will be
1633
; larger but will be produced significantly faster, particular for large
1634
; images.  Do not use this option for images which will be distributed, only
1635
; used it when producing intermediate files that will be read back in
1636
; repeatedly.  For a typical 24-bit image the option will double the read
1637
; speed at the cost of increasing the image size by 25%, however for many
1638
; more compressible images the PNG file can be 10 times larger with only a
1639
; slight speed gain.
1640
1641
 
1642
; On read if the image is a 16-bit per component image and there is no gAMA
1643
; or sRGB chunk assume that the components are sRGB encoded.  Notice that
1644
; images output by the simplified API always have gamma information; setting
1645
; this flag only affects the interpretation of 16-bit images from an
1646
; external source.  It is recommended that the application expose this flag
1647
; to the user; the user can normally easily recognize the difference between
1648
; linear and sRGB encoding.  This flag has no effect on write - the data
1649
; passed to the write APIs must have the correct encoding (as defined
1650
; above.)
1651
1652
 
1653
; assumed to be linear.
1654
1655
 
1656
; because that call initializes the 'flags' field.
1657
1658
 
1659
; WRITE APIS
1660
; ----------
1661
; For write you must initialize a png_image structure to describe the image to
1662
; be written.  To do this use memset to set the whole structure to 0 then
1663
; initialize fields describing your image.
1664
1665
 
1666
; opaque: must be initialized to NULL
1667
; width: image width in pixels
1668
; height: image height in rows
1669
; format: the format of the data (image and color-map) you wish to write
1670
; flags: set to 0 unless one of the defined flags applies; set
1671
;    PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB
1672
;    values do not correspond to the colors in sRGB.
1673
; colormap_entries: set to the number of entries in the color-map (0 to 256)
1674
1675
 
1676
; data then setting convert_to_8_bit will cause the output to be an 8-bit PNG
1677
; gamma encoded according to the sRGB specification, otherwise a 16-bit linear
1678
; encoded PNG file is written.
1679
1680
 
1681
; with at least image->colormap_entries encoded in the specified format.  If
1682
; the format is linear the written PNG color-map will be converted to sRGB
1683
; regardless of the convert_to_8_bit flag.
1684
1685
 
1686
; from one row to the next in component sized units (1 or 2 bytes) and if
1687
; negative indicates a bottom-up row layout in the buffer.  If row_stride is
1688
; zero, libpng will calculate it for you from the image width and number of
1689
; channels.
1690
1691
 
1692
; most ancillary chunks.  If you need to write text chunks (e.g. for copyright
1693
; notices) you need to use one of the other APIs.
1694
1695
 
1696
 
1697
;   row_stride, colormap)\
1698
;   png_image_write_to_memory(&(image), 0, &(size), convert_to_8_bit, buffer,\
1699
;         row_stride, colormap)
1700
; Return the amount of memory in 'size' required to compress this image.
1701
; The png_image structure 'image' must be filled in as in the above
1702
; function and must not be changed before the actual write call, the buffer
1703
; and all other parameters must also be identical to that in the final
1704
; write call.  The 'size' variable need not be initialized.
1705
1706
 
1707
; set to zero and the write failed and probably will fail if tried again.
1708
1709
 
1710
; regardless of the amount of compression achieved.  The buffer size will
1711
; always be bigger than the original image and it will never be filled.  The
1712
; following macros are provided to assist in allocating the buffer.
1713
1714
 
1715
; The number of uncompressed bytes in the PNG byte encoding of the image;
1716
; uncompressing the PNG IDAT data will give this number of bytes.
1717
1718
 
1719
; macro can because of the extra bytes used in the PNG byte encoding.  You
1720
; need to avoid this macro if your image size approaches 2^30 in width or
1721
; height.  The same goes for the remainder of these macros; they all produce
1722
; bigger numbers than the actual in-memory image size.
1723
1724
 
1725
;#  define PNG_ZLIB_MAX_SIZE(b) ((b)+(((b)+7U)>>3)+(((b)+63U)>>6)+11U)
1726
; An upper bound on the number of compressed bytes given 'b' uncompressed
1727
; bytes.  This is based on deflateBounds() in zlib; different
1728
; implementations of zlib compression may conceivably produce more data so
1729
; if your zlib implementation is not zlib itself redefine this macro
1730
; appropriately.
1731
1732
 
1733
1734
 
1735
;   PNG_ZLIB_MAX_SIZE((png_alloc_size_t)PNG_IMAGE_DATA_SIZE(image))
1736
	; An upper bound on the size of the data in the PNG IDAT chunks.
1737
1738
 
1739
;   ((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\
1740
;    (((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\
1741
;    12U+3U*(image).colormap_entries/*PLTE data*/+\
1742
;    (((image).format&PNG_FORMAT_FLAG_ALPHA)?\
1743
;    12U/*tRNS*/+(image).colormap_entries:0U):0U)+\
1744
;    12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size))
1745
1746
 
1747
; following macro use this one with the result of
1748
; PNG_IMAGE_COMPRESSED_SIZE_MAX(image) as the second argument (most
1749
; compilers should handle this just fine.)
1750
1751
 
1752
;   PNG_IMAGE_PNG_SIZE_MAX_(image, PNG_IMAGE_COMPRESSED_SIZE_MAX(image))
1753
; An upper bound on the total length of the PNG data stream for 'image'.
1754
; The result is of type png_alloc_size_t, on 32-bit systems this may
1755
; overflow even though PNG_IMAGE_DATA_SIZE does not overflow; the write will
1756
; run out of buffer space but return a corrected size which should work.
1757
1758
 
1759
;/*******************************************************************************
1760
;  END OF SIMPLIFIED API
1761
; ******************************************************************************/
1762
;end if /* SIMPLIFIED_{READ|WRITE} */
1763
1764
 
1765
; Section 6: IMPLEMENTATION OPTIONS
1766
; *******************************************************************************
1767
1768
 
1769
; particular options to be turned on or off.  'Option' is the number of the
1770
; option and 'onoff' is 0 (off) or non-0 (on).  The value returned is given
1771
; by the PNG_OPTION_ defines below.
1772
1773
 
1774
;           are detected at run time, however sometimes it may be impossible
1775
;           to do this in user mode, in which case it is necessary to discover
1776
;           the capabilities in an OS specific way.  Such capabilities are
1777
;           listed here when libpng has support for them and must be turned
1778
;           ON by the application if present.
1779
1780
 
1781
;           decrease on some architectures or systems, or with some sets of
1782
;           PNG images.  'Software' options allow such optimizations to be
1783
;           selected at run time.
1784
1785
 
1786
if PNG_ARM_NEON_API_SUPPORTED eq 1
1787
	PNG_ARM_NEON  equ 0 ;HARDWARE: ARM Neon SIMD instructions supported
1788
end if
1789
PNG_MAXIMUM_INFLATE_WINDOW equ 2 ;SOFTWARE: force maximum window
1790
PNG_SKIP_sRGB_CHECK_PROFILE equ 4 ;SOFTWARE: Check ICC profile for sRGB
1791
if PNG_MIPS_MSA_API_SUPPORTED eq 1
1792
	PNG_MIPS_MSA  equ 6 ;HARDWARE: MIPS Msa SIMD instructions supported
1793
end if
1794
PNG_OPTION_NEXT equ 8 ;Next option - numbers must be even
1795
1796
 
1797
PNG_OPTION_UNSET  equ 0 ;Unset - defaults to off
1798
PNG_OPTION_INVALID equ 1 ;Option number out of range
1799
PNG_OPTION_OFF    equ 2
1800
PNG_OPTION_ON     equ 3
1801
end if ;SET_OPTION
1802
1803
 
1804
;  END OF HARDWARE AND SOFTWARE OPTIONS
1805
; ******************************************************************************/
1806
1807
 
1808
; defs, and in scripts/symbols.def.
1809
1810
 
1811
 
1812
; one to use is one more than this.)
1813
1814
 
1815
; Do not put anything past this line
1816