Debian Codegraph @

src/images/castleinternalpng_dynamic.inc

raw
1 {%MainUnit castleinternalpng.pas}
2 (*
3 Libpng bindings. See [http://www.libpng.org/].
4 Bases on FPC sources, modified by Michalis Kamburelis for Castle Game Engine.
5
6 Michalis modifications:
7
8 @unorderedList(
9 @item(
10 If libpng is not installed on your system, there is no exception
11 at initialization. Instead it merely sets CastlePngInitialized to false.
12 This way programs that use this unit do not require libpng to be
13 installed on target system. Libpng must be present only if program
14 at runtime will really need it, e.g. Images.LoadPNG will raise an
15 exception if CastlePngInitialized is @false.)
16
17 @item(Use my CastleInternalZLib instead of Zlib module. Primarily for having
18 CastleZLibInitialized, similar to CastlePngInitialized for zlib.)
19
20 @item(We try to open libpng library from various names, to try hard
21 to work with various libpng so/dll names user may have installed
22 on his/her system.
23
24 In particular, we eventually fallback to using libpng.so name
25 (usually coming from libpng-dev packages on Linux distros).
26 So it can work with any libpng version.
27 This is possible by using explicit loading at unit
28 initialization, instead of using "exported" declarations
29 (that would tie us to particular so name, the one "ld" saw referenced
30 by libpng.so symlink at compilation).
31
32 Of course, this works as long as we use only functions that are really
33 compatible across all existing libpng versions.)
34
35 @item(All functions are loaded using my TDynLib class in unit's initialization,
36 instead of "external" declarations. This allows various above features,
37 it also allows to easily find if some functions are missing in
38 libpng.(so|dll).)
39
40 @item(Added all missing constants (probably lost in FPC during h2pas).)
41
42 @item(
43 Works with Windows libpng version with stdcalls
44 (changed "cdecl" to "{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif}"))
45
46 @item(
47 Many deprecated stuff removed by default.
48 See LIBPNG_DEPRECATED define.)
49
50 @item(
51 We account for breaking changes in LibPng 1.4 to some types (size_t vs
52 32-bit difference, which matters on non-32-bit systems).
53 See http://www.libpng.org/pub/png/src/libpng-1.2.x-to-1.4.x-summary.txt .
54
55 By default the routines are just commented out, for safety and to force
56 max compatibility.
57 But you can define LIBPNG_1_4 to enable them.
58 )
59
60 @item(
61 Compatible and tested with both FPC and Delphi.)
62 )
63 *)
64
65 interface
66
67 uses CTypes, CastleInternalZLib;
68
69 { Automatically converted by H2Pas 0.99.15 from png.h }
70 { The following command line parameters were used:
71 png.h
72 }
73
74 {$ifndef FPC}
75 {$ALIGN 4}
76 {$else}
77 {$PACKRECORDS C}
78 {$endif}
79
80 const
81 { Supported compression types for text in PNG files (tEXt, and zTXt).
82 The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. }
83 PNG_TEXT_COMPRESSION_NONE_WR = -3;
84 PNG_TEXT_COMPRESSION_zTXt_WR = -2;
85 PNG_TEXT_COMPRESSION_NONE = -1;
86 PNG_TEXT_COMPRESSION_zTXt = 0;
87 PNG_ITXT_COMPRESSION_NONE = 1;
88 PNG_ITXT_COMPRESSION_zTXt = 2;
89 PNG_TEXT_COMPRESSION_LAST = 3; { Not a valid value }
90
91 { Maximum positive integer used in PNG is (2^31)-1 }
92 PNG_MAX_UINT = High(UInt32);
93
94 { These describe the color_type field in png_info. }
95 { color type masks }
96 PNG_COLOR_MASK_PALETTE = 1;
97 PNG_COLOR_MASK_COLOR = 2;
98 PNG_COLOR_MASK_ALPHA = 4;
99
100 { color types. Note that not all combinations are legal }
101 PNG_COLOR_TYPE_GRAY = 0;
102 PNG_COLOR_TYPE_PALETTE = (PNG_COLOR_MASK_COLOR or PNG_COLOR_MASK_PALETTE);
103 PNG_COLOR_TYPE_RGB = (PNG_COLOR_MASK_COLOR);
104 PNG_COLOR_TYPE_RGB_ALPHA = (PNG_COLOR_MASK_COLOR or PNG_COLOR_MASK_ALPHA);
105 PNG_COLOR_TYPE_GRAY_ALPHA = (PNG_COLOR_MASK_ALPHA);
106 { aliases }
107 PNG_COLOR_TYPE_RGBA = PNG_COLOR_TYPE_RGB_ALPHA;
108 PNG_COLOR_TYPE_GA = PNG_COLOR_TYPE_GRAY_ALPHA;
109
110 { This is for compression type. PNG 1.0-1.2 only define the single type. }
111 PNG_COMPRESSION_TYPE_BASE = 0 { Deflate method 8, 32K window };
112 PNG_COMPRESSION_TYPE_DEFAULT = PNG_COMPRESSION_TYPE_BASE;
113
114 { This is for filter type. PNG 1.0-1.2 only define the single type. }
115 PNG_FILTER_TYPE_BASE = 0 { Single row per-byte filtering };
116 PNG_INTRAPIXEL_DIFFERENCING = 64 { Used only in MNG datastreams };
117 PNG_FILTER_TYPE_DEFAULT = PNG_FILTER_TYPE_BASE;
118
119 { These are for the interlacing type. These values should NOT be changed. }
120 PNG_INTERLACE_NONE = 0 { Non-interlaced image };
121 PNG_INTERLACE_ADAM7 = 1 { Adam7 interlacing };
122 PNG_INTERLACE_LAST = 2 { Not a valid value };
123
124 { These are for the oFFs chunk. These values should NOT be changed. }
125 PNG_OFFSET_PIXEL = 0 { Offset in pixels };
126 PNG_OFFSET_MICROMETER = 1 { Offset in micrometers (1/10^6 meter) };
127 PNG_OFFSET_LAST = 2 { Not a valid value };
128
129 { These are for the pCAL chunk. These values should NOT be changed. }
130 PNG_EQUATION_LINEAR = 0 { Linear transformation };
131 PNG_EQUATION_BASE_E = 1 { Exponential base e transform };
132 PNG_EQUATION_ARBITRARY = 2 { Arbitrary base exponential transform };
133 PNG_EQUATION_HYPERBOLIC = 3 { Hyperbolic sine transformation };
134 PNG_EQUATION_LAST = 4 { Not a valid value };
135
136 { These are for the sCAL chunk. These values should NOT be changed. }
137 PNG_SCALE_UNKNOWN = 0 { unknown unit (image scale) };
138 PNG_SCALE_METER = 1 { meters per pixel };
139 PNG_SCALE_RADIAN = 2 { radians per pixel };
140 PNG_SCALE_LAST = 3 { Not a valid value };
141
142 { These are for the pHYs chunk. These values should NOT be changed. }
143 PNG_RESOLUTION_UNKNOWN = 0 { pixels/unknown unit (aspect ratio) };
144 PNG_RESOLUTION_METER = 1 { pixels/meter };
145 PNG_RESOLUTION_LAST = 2 { Not a valid value };
146
147 { These are for the sRGB chunk. These values should NOT be changed. }
148 PNG_sRGB_INTENT_PERCEPTUAL =0;
149 PNG_sRGB_INTENT_RELATIVE =1;
150 PNG_sRGB_INTENT_SATURATION =2;
151 PNG_sRGB_INTENT_ABSOLUTE =3;
152 PNG_sRGB_INTENT_LAST = 4 { Not a valid value };
153
154 { This is for text chunks }
155 PNG_KEYWORD_MAX_LENGTH = 79;
156
157 { Maximum number of entries in PLTE/sPLT/tRNS arrays }
158 PNG_MAX_PALETTE_LENGTH = 256;
159
160 { These determine if an ancillary chunk's data has been successfully read
161 * from the PNG header, or if the application has filled in the corresponding
162 * data in the info_struct to be written into the output file. The values
163 * of the PNG_INFO_<chunk> defines should NOT be changed.
164 }
165 PNG_INFO_gAMA = $0001;
166 PNG_INFO_sBIT = $0002;
167 PNG_INFO_cHRM = $0004;
168 PNG_INFO_PLTE = $0008;
169 PNG_INFO_tRNS = $0010;
170 PNG_INFO_bKGD = $0020;
171 PNG_INFO_hIST = $0040;
172 PNG_INFO_pHYs = $0080;
173 PNG_INFO_oFFs = $0100;
174 PNG_INFO_tIME = $0200;
175 PNG_INFO_pCAL = $0400;
176 PNG_INFO_sRGB = $0800 { GR-P, 0.96a };
177 PNG_INFO_iCCP = $1000 { ESR, 1.0.6 };
178 PNG_INFO_sPLT = $2000 { ESR, 1.0.6 };
179 PNG_INFO_sCAL = $4000 { ESR, 1.0.6 };
180 PNG_INFO_IDAT = $8000 { ESR, 1.0.6 };
181
182 { Transform masks for the high-level interface }
183 PNG_TRANSFORM_IDENTITY = $0000 { read and write };
184 PNG_TRANSFORM_STRIP_16 = $0001 { read only };
185 PNG_TRANSFORM_STRIP_ALPHA = $0002 { read only };
186 PNG_TRANSFORM_PACKING = $0004 { read and write };
187 PNG_TRANSFORM_PACKSWAP = $0008 { read and write };
188 PNG_TRANSFORM_EXPAND = $0010 { read only };
189 PNG_TRANSFORM_INVERT_MONO = $0020 { read and write };
190 PNG_TRANSFORM_SHIFT = $0040 { read and write };
191 PNG_TRANSFORM_BGR = $0080 { read and write };
192 PNG_TRANSFORM_SWAP_ALPHA = $0100 { read and write };
193 PNG_TRANSFORM_SWAP_ENDIAN = $0200 { read and write };
194 PNG_TRANSFORM_INVERT_ALPHA = $0400 { read and write };
195 PNG_TRANSFORM_STRIP_FILLER = $0800 { WRITE only };
196
197 { Flags for MNG supported features }
198 PNG_FLAG_MNG_EMPTY_PLTE = $01;
199 PNG_FLAG_MNG_FILTER_64 = $04;
200 PNG_ALL_MNG_FEATURES = $05;
201
202 { png_set_filler : Add a filler byte to 24-bit RGB images. }
203 { The values of the PNG_FILLER_ defines should NOT be changed }
204 PNG_FILLER_BEFORE =0;
205 PNG_FILLER_AFTER =1;
206
207 { png_set_background : Handle alpha and tRNS by replacing with a background color. }
208 PNG_BACKGROUND_GAMMA_UNKNOWN =0;
209 PNG_BACKGROUND_GAMMA_SCREEN =1;
210 PNG_BACKGROUND_GAMMA_FILE =2;
211 PNG_BACKGROUND_GAMMA_UNIQUE =3;
212
213 { Values for png_set_crc_action() to say how to handle CRC errors in
214 * ancillary and critical chunks, and whether to use the data contained
215 * therein. Note that it is impossible to "discard" data in a critical
216 * chunk. For versions prior to 0.90, the action was always error/quit,
217 * whereas in version 0.90 and later, the action for CRC errors in ancillary
218 * chunks is warn/discard. These values should NOT be changed.
219 *
220 * value action:critical action:ancillary
221 }
222 PNG_CRC_DEFAULT = 0 { error/quit warn/discard data };
223 PNG_CRC_ERROR_QUIT = 1 { error/quit error/quit };
224 PNG_CRC_WARN_DISCARD = 2 { (INVALID) warn/discard data };
225 PNG_CRC_WARN_USE = 3 { warn/use data warn/use data };
226 PNG_CRC_QUIET_USE = 4 { quiet/use data quiet/use data };
227 PNG_CRC_NO_CHANGE = 5 { use current value use current value };
228
229 { Flags for png_set_filter() to say which filters to use. The flags
230 * are chosen so that they don't conflict with real filter types
231 * below, in case they are supplied instead of the #defined constants.
232 * These values should NOT be changed.
233 }
234 PNG_NO_FILTERS = $00;
235 PNG_FILTER_NONE = $08;
236 PNG_FILTER_SUB = $10;
237 PNG_FILTER_UP = $20;
238 PNG_FILTER_AVG = $40;
239 PNG_FILTER_PAETH = $80;
240 PNG_ALL_FILTERS = (PNG_FILTER_NONE or PNG_FILTER_SUB or PNG_FILTER_UP or
241 PNG_FILTER_AVG or PNG_FILTER_PAETH);
242
243 { Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
244 * These defines should NOT be changed.
245 }
246 PNG_FILTER_VALUE_NONE =0;
247 PNG_FILTER_VALUE_SUB =1;
248 PNG_FILTER_VALUE_UP =2;
249 PNG_FILTER_VALUE_AVG =3;
250 PNG_FILTER_VALUE_PAETH =4;
251 PNG_FILTER_VALUE_LAST =5;
252
253 { Heuristic used for row filter selection. These defines should NOT be
254 * changed.
255 }
256 PNG_FILTER_HEURISTIC_DEFAULT = 0 { Currently "UNWEIGHTED" };
257 PNG_FILTER_HEURISTIC_UNWEIGHTED = 1 { Used by libpng < 0.95 };
258 PNG_FILTER_HEURISTIC_WEIGHTED = 2 { Experimental feature };
259 PNG_FILTER_HEURISTIC_LAST = 3 { Not a valid value };
260
261 type
262 png_time_t = CInt32;
263 png_int = CInt32;
264 z_stream = TZStream;
265
266 png_uint_32 = UInt32;
267 png_int_32 = Int32;
268 png_uint_16 = word;
269 png_int_16 = smallint;
270 png_byte = byte;
271 ppng_uint_32 = ^png_uint_32;
272 ppng_int_32 = ^png_int_32;
273 ppng_uint_16 = ^png_uint_16;
274 ppng_int_16 = ^png_int_16;
275 ppng_byte = ^png_byte;
276 pppng_uint_32 = ^ppng_uint_32;
277 pppng_int_32 = ^ppng_int_32;
278 pppng_uint_16 = ^ppng_uint_16;
279 pppng_int_16 = ^ppng_int_16;
280 pppng_byte = ^ppng_byte;
281 png_size_t = csize_t;
282 png_fixed_point = png_int_32;
283 ppng_fixed_point = ^png_fixed_point;
284 pppng_fixed_point = ^ppng_fixed_point;
285 png_voidp = pointer;
286 png_bytep = Ppng_byte;
287 ppng_bytep = ^png_bytep;
288 png_uint_32p = Ppng_uint_32;
289 png_int_32p = Ppng_int_32;
290 png_uint_16p = Ppng_uint_16;
291 ppng_uint_16p = ^png_uint_16p;
292 png_int_16p = Ppng_int_16;
293 (* Const before type ignored *)
294 png_const_charp = PAnsichar;
295 png_charp = PAnsichar;
296 ppng_charp = ^png_charp;
297 png_fixed_point_p = Ppng_fixed_point;
298 TFile = Pointer;
299 png_FILE_p = ^FILE;
300 png_doublep = Pdouble;
301 png_bytepp = PPpng_byte;
302 png_uint_32pp = PPpng_uint_32;
303 png_int_32pp = PPpng_int_32;
304 png_uint_16pp = PPpng_uint_16;
305 png_int_16pp = PPpng_int_16;
306 (* Const before type ignored *)
307 png_const_charpp = PPAnsichar;
308 png_charpp = PPAnsichar;
309 ppng_charpp = ^png_charpp;
310 png_fixed_point_pp = PPpng_fixed_point;
311 PPDouble = ^PDouble;
312 png_doublepp = PPdouble;
313 PPPChar = ^PPAnsiCHar;
314 png_charppp = PPPchar;
315 Pcharf = PAnsichar;
316 PPcharf = ^Pcharf;
317 png_zcharp = Pcharf;
318 png_zcharpp = PPcharf;
319 png_zstreamp = Pzstream;
320
321 {$ifdef LIBPNG_DEPRECATED}
322 { These variables didn't work since a long time,
323 and http://www.libpng.org/pub/png/src/libpng-1.2.x-to-1.4.x-summary.txt
324 confirms they are deprecated and removed in newer libpng 1.4. }
325 var
326 png_libpng_ver : array[0..11] of char; cvar; external;
327 png_pass_start : array[0..6] of CInt32; cvar; external;
328 png_pass_inc : array[0..6] of CInt32; cvar; external;
329 png_pass_ystart : array[0..6] of CInt32;cvar; external;
330 png_pass_yinc : array[0..6] of CInt32; cvar; external;
331 png_pass_mask : array[0..6] of CInt32; cvar; external;
332 png_pass_dsp_mask : array[0..6] of CInt32; cvar; external;
333 {$endif LIBPNG_DEPRECATED}
334
335 Type
336 png_color = record
337 red : png_byte;
338 green : png_byte;
339 blue : png_byte;
340 end;
341 ppng_color = ^png_color;
342 pppng_color = ^ppng_color;
343
344 png_color_struct = png_color;
345 png_colorp = Ppng_color;
346 ppng_colorp = ^png_colorp;
347 png_colorpp = PPpng_color;
348 png_color_16 = record
349 index : png_byte;
350 red : png_uint_16;
351 green : png_uint_16;
352 blue : png_uint_16;
353 gray : png_uint_16;
354 end;
355 ppng_color_16 = ^png_color_16 ;
356 pppng_color_16 = ^ppng_color_16 ;
357 png_color_16_struct = png_color_16;
358 png_color_16p = Ppng_color_16;
359 ppng_color_16p = ^png_color_16p;
360 png_color_16pp = PPpng_color_16;
361 png_color_8 = record
362 red : png_byte;
363 green : png_byte;
364 blue : png_byte;
365 gray : png_byte;
366 alpha : png_byte;
367 end;
368 ppng_color_8 = ^png_color_8;
369 pppng_color_8 = ^ppng_color_8;
370 png_color_8_struct = png_color_8;
371 png_color_8p = Ppng_color_8;
372 ppng_color_8p = ^png_color_8p;
373 png_color_8pp = PPpng_color_8;
374 png_sPLT_entry = record
375 red : png_uint_16;
376 green : png_uint_16;
377 blue : png_uint_16;
378 alpha : png_uint_16;
379 frequency : png_uint_16;
380 end;
381 ppng_sPLT_entry = ^png_sPLT_entry;
382 pppng_sPLT_entry = ^ppng_sPLT_entry;
383 png_sPLT_entry_struct = png_sPLT_entry;
384 png_sPLT_entryp = Ppng_sPLT_entry;
385 png_sPLT_entrypp = PPpng_sPLT_entry;
386 png_sPLT_t = record
387 name : png_charp;
388 depth : png_byte;
389 entries : png_sPLT_entryp;
390 nentries : png_int_32;
391 end;
392 ppng_sPLT_t = ^png_sPLT_t;
393 pppng_sPLT_t = ^ppng_sPLT_t;
394 png_sPLT_struct = png_sPLT_t;
395 png_sPLT_tp = Ppng_sPLT_t;
396 png_sPLT_tpp = PPpng_sPLT_t;
397 png_text = record
398 compression : CInt32;
399 key : png_charp;
400 text : png_charp;
401 text_length : png_size_t;
402 end;
403 ppng_text = ^png_text;
404 pppng_text = ^ppng_text;
405
406 png_text_struct = png_text;
407 png_textp = Ppng_text;
408 ppng_textp = ^png_textp;
409 png_textpp = PPpng_text;
410 png_time = record
411 year : png_uint_16;
412 month : png_byte;
413 day : png_byte;
414 hour : png_byte;
415 minute : png_byte;
416 second : png_byte;
417 end;
418 ppng_time = ^png_time;
419 pppng_time = ^ppng_time;
420
421 png_time_struct = png_time;
422 png_timep = Ppng_time;
423 PPNG_TIMEP = ^PNG_TIMEP;
424 png_timepp = PPpng_time;
425 png_unknown_chunk = record
426 name : array[0..4] of png_byte;
427 data : Ppng_byte;
428 size : png_size_t;
429 location : png_byte;
430 end;
431 ppng_unknown_chunk = ^png_unknown_chunk;
432 pppng_unknown_chunk = ^ppng_unknown_chunk;
433
434 png_unknown_chunk_t = png_unknown_chunk;
435 png_unknown_chunkp = Ppng_unknown_chunk;
436 png_unknown_chunkpp = PPpng_unknown_chunk;
437 png_info = record
438 width : png_uint_32;
439 height : png_uint_32;
440 valid : png_uint_32;
441 rowbytes : png_uint_32;
442 palette : png_colorp;
443 num_palette : png_uint_16;
444 num_trans : png_uint_16;
445 bit_depth : png_byte;
446 color_type : png_byte;
447 compression_type : png_byte;
448 filter_type : png_byte;
449 interlace_type : png_byte;
450 channels : png_byte;
451 pixel_depth : png_byte;
452 spare_byte : png_byte;
453 signature : array[0..7] of png_byte;
454 gamma : double;
455 srgb_intent : png_byte;
456 num_text : CInt32;
457 max_text : CInt32;
458 text : png_textp;
459 mod_time : png_time;
460 sig_bit : png_color_8;
461 trans : png_bytep;
462 trans_values : png_color_16;
463 background : png_color_16;
464 x_offset : png_int_32;
465 y_offset : png_int_32;
466 offset_unit_type : png_byte;
467 x_pixels_per_unit : png_uint_32;
468 y_pixels_per_unit : png_uint_32;
469 phys_unit_type : png_byte;
470 hist : png_uint_16p;
471 x_white : double;
472 y_white : double;
473 x_red : double;
474 y_red : double;
475 x_green : double;
476 y_green : double;
477 x_blue : double;
478 y_blue : double;
479 pcal_purpose : png_charp;
480 pcal_X0 : png_int_32;
481 pcal_X1 : png_int_32;
482 pcal_units : png_charp;
483 pcal_params : png_charpp;
484 pcal_type : png_byte;
485 pcal_nparams : png_byte;
486 free_me : png_uint_32;
487 unknown_chunks : png_unknown_chunkp;
488 unknown_chunks_num : png_size_t;
489 iccp_name : png_charp;
490 iccp_profile : png_charp;
491 iccp_proflen : png_uint_32;
492 iccp_compression : png_byte;
493 splt_palettes : png_sPLT_tp;
494 splt_palettes_num : png_uint_32;
495 scal_unit : png_byte;
496 scal_pixel_width : double;
497 scal_pixel_height : double;
498 scal_s_width : png_charp;
499 scal_s_height : png_charp;
500 row_pointers : png_bytepp;
501 int_gamma : png_fixed_point;
502 int_x_white : png_fixed_point;
503 int_y_white : png_fixed_point;
504 int_x_red : png_fixed_point;
505 int_y_red : png_fixed_point;
506 int_x_green : png_fixed_point;
507 int_y_green : png_fixed_point;
508 int_x_blue : png_fixed_point;
509 int_y_blue : png_fixed_point;
510 end;
511 ppng_info = ^png_info;
512 pppng_info = ^ppng_info;
513
514 png_info_struct = png_info;
515 png_infop = Ppng_info;
516 png_infopp = PPpng_info;
517 png_row_info = record
518 width : png_uint_32;
519 rowbytes : png_uint_32;
520 color_type : png_byte;
521 bit_depth : png_byte;
522 channels : png_byte;
523 pixel_depth : png_byte;
524 end;
525 ppng_row_info = ^png_row_info;
526 pppng_row_info = ^ppng_row_info;
527
528 png_row_info_struct = png_row_info;
529 png_row_infop = Ppng_row_info;
530 png_row_infopp = PPpng_row_info;
531 // png_struct_def = png_struct;
532 png_structp = ^png_struct;
533
534 png_error_ptr = Procedure(Arg1 : png_structp; Arg2 : png_const_charp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
535 png_rw_ptr = Procedure(Arg1 : png_structp; Arg2 : png_bytep; Arg3 : png_size_t);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
536 png_flush_ptr = procedure (Arg1 : png_structp) ;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
537 png_read_status_ptr = procedure (Arg1 : png_structp; Arg2 : png_uint_32; Arg3: png_int);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
538 png_write_status_ptr = Procedure (Arg1 : png_structp; Arg2: png_uint_32;Arg3 : png_int) ;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
539 png_progressive_info_ptr = Procedure (Arg1 : png_structp; Arg2 : png_infop) ;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
540 png_progressive_end_ptr = Procedure (Arg1 : png_structp; Arg2 : png_infop) ;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
541 png_progressive_row_ptr = Procedure (Arg1 : png_structp; Arg2 : png_bytep; Arg3 : png_uint_32; Arg4 : png_int) ;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
542 png_user_transform_ptr = Procedure (Arg1 : png_structp; Arg2 : png_row_infop; Arg3 : png_bytep) ;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
543 png_user_chunk_ptr = Function (Arg1 : png_structp; Arg2 : png_unknown_chunkp): CInt32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
544 png_unknown_chunk_ptr = Procedure (Arg1 : png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
545 png_malloc_ptr = Function (Arg1 : png_structp; Arg2 : png_size_t) : png_voidp ;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
546 png_free_ptr = Procedure (Arg1 : png_structp; Arg2 : png_voidp) ; {$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
547
548 png_struct_def = record
549 jmpbuf : {$ifdef FPC} jmp_buf {$else} pointer {$endif};
550 error_fn : png_error_ptr;
551 warning_fn : png_error_ptr;
552 error_ptr : png_voidp;
553 write_data_fn : png_rw_ptr;
554 read_data_fn : png_rw_ptr;
555 io_ptr : png_voidp;
556 read_user_transform_fn : png_user_transform_ptr;
557 write_user_transform_fn : png_user_transform_ptr;
558 user_transform_ptr : png_voidp;
559 user_transform_depth : png_byte;
560 user_transform_channels : png_byte;
561 mode : png_uint_32;
562 flags : png_uint_32;
563 transformations : png_uint_32;
564 zstream : z_stream;
565 zbuf : png_bytep;
566 zbuf_size : png_size_t;
567 zlib_level : CInt32;
568 zlib_method : CInt32;
569 zlib_window_bits : CInt32;
570 zlib_mem_level : CInt32;
571 zlib_strategy : CInt32;
572 width : png_uint_32;
573 height : png_uint_32;
574 num_rows : png_uint_32;
575 usr_width : png_uint_32;
576 rowbytes : png_uint_32;
577 irowbytes : png_uint_32;
578 iwidth : png_uint_32;
579 row_number : png_uint_32;
580 prev_row : png_bytep;
581 row_buf : png_bytep;
582 sub_row : png_bytep;
583 up_row : png_bytep;
584 avg_row : png_bytep;
585 paeth_row : png_bytep;
586 row_info : png_row_info;
587 idat_size : png_uint_32;
588 crc : png_uint_32;
589 palette : png_colorp;
590 num_palette : png_uint_16;
591 num_trans : png_uint_16;
592 chunk_name : array[0..4] of png_byte;
593 compression : png_byte;
594 filter : png_byte;
595 interlaced : png_byte;
596 pass : png_byte;
597 do_filter : png_byte;
598 color_type : png_byte;
599 bit_depth : png_byte;
600 usr_bit_depth : png_byte;
601 pixel_depth : png_byte;
602 channels : png_byte;
603 usr_channels : png_byte;
604 sig_bytes : png_byte;
605 filler : png_uint_16;
606 background_gamma_type : png_byte;
607 background_gamma : double;
608 background : png_color_16;
609 background_1 : png_color_16;
610 output_flush_fn : png_flush_ptr;
611 flush_dist : png_uint_32;
612 flush_rows : png_uint_32;
613 gamma_shift : CInt32;
614 gamma : double;
615 screen_gamma : double;
616 gamma_table : png_bytep;
617 gamma_from_1 : png_bytep;
618 gamma_to_1 : png_bytep;
619 gamma_16_table : png_uint_16pp;
620 gamma_16_from_1 : png_uint_16pp;
621 gamma_16_to_1 : png_uint_16pp;
622 sig_bit : png_color_8;
623 shift : png_color_8;
624 trans : png_bytep;
625 trans_values : png_color_16;
626 read_row_fn : png_read_status_ptr;
627 write_row_fn : png_write_status_ptr;
628 info_fn : png_progressive_info_ptr;
629 row_fn : png_progressive_row_ptr;
630 end_fn : png_progressive_end_ptr;
631 save_buffer_ptr : png_bytep;
632 save_buffer : png_bytep;
633 current_buffer_ptr : png_bytep;
634 current_buffer : png_bytep;
635 push_length : png_uint_32;
636 skip_length : png_uint_32;
637 save_buffer_size : png_size_t;
638 save_buffer_max : png_size_t;
639 buffer_size : png_size_t;
640 current_buffer_size : png_size_t;
641 process_mode : CInt32;
642 cur_palette : CInt32;
643 current_text_size : png_size_t;
644 current_text_left : png_size_t;
645 current_text : png_charp;
646 current_text_ptr : png_charp;
647 palette_lookup : png_bytep;
648 dither_index : png_bytep;
649 hist : png_uint_16p;
650 heuristic_method : png_byte;
651 num_prev_filters : png_byte;
652 prev_filters : png_bytep;
653 filter_weights : png_uint_16p;
654 inv_filter_weights : png_uint_16p;
655 filter_costs : png_uint_16p;
656 inv_filter_costs : png_uint_16p;
657 time_buffer : png_charp;
658 free_me : png_uint_32;
659 user_chunk_ptr : png_voidp;
660 read_user_chunk_fn : png_user_chunk_ptr;
661 num_chunk_list : CInt32;
662 chunk_list : png_bytep;
663 rgb_to_gray_status : png_byte;
664 rgb_to_gray_red_coeff : png_uint_16;
665 rgb_to_gray_green_coeff : png_uint_16;
666 rgb_to_gray_blue_coeff : png_uint_16;
667 empty_plte_permitted : png_byte;
668 int_gamma : png_fixed_point;
669 end;
670 ppng_struct_def = ^png_struct_def;
671 pppng_struct_def = ^ppng_struct_def;
672 png_struct = png_struct_def;
673 ppng_struct = ^png_struct;
674 pppng_struct = ^ppng_struct;
675
676 version_1_0_8 = png_structp;
677 png_structpp = PPpng_struct;
678
679 var
680 png_access_version_number: function: png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
681 png_set_sig_bytes: procedure(png_ptr: png_structp; num_bytes: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
682 png_sig_cmp: function(sig: png_bytep; start: png_size_t; num_to_check: png_size_t): CInt32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
683 png_create_read_struct: function(user_png_ver: png_const_charp; error_ptr: png_voidp; error_fn: png_error_ptr; warn_fn: png_error_ptr): png_structp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
684 png_create_write_struct: function(user_png_ver: png_const_charp; error_ptr: png_voidp; error_fn: png_error_ptr; warn_fn: png_error_ptr): png_structp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
685 {$ifdef LIBPNG_1_4}
686 png_get_compression_buffer_size: function(png_ptr: png_structp): png_size_t { png_uint_32 in libpng < 1.4 };{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
687 png_set_compression_buffer_size: procedure(png_ptr: png_structp; size: png_size_t { png_uint_32 in libpng < 1.4 });{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
688 {$endif}
689 png_reset_zstream: function(png_ptr: png_structp): CInt32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
690 png_write_chunk: procedure(png_ptr: png_structp; chunk_name: png_bytep; data: png_bytep; length: png_size_t);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
691 png_write_chunk_start: procedure(png_ptr: png_structp; chunk_name: png_bytep; length: png_uint_32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
692 png_write_chunk_data: procedure(png_ptr: png_structp; data: png_bytep; length: png_size_t);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
693 png_write_chunk_end: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
694 png_create_info_struct: function(png_ptr: png_structp): png_infop;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
695 png_write_info_before_PLTE: procedure(png_ptr: png_structp; info_ptr: png_infop);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
696 png_write_info: procedure(png_ptr: png_structp; info_ptr: png_infop);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
697 png_read_info: procedure(png_ptr: png_structp; info_ptr: png_infop);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
698 png_convert_to_rfc1123: function(png_ptr: png_structp; ptime: png_timep): png_charp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
699 png_convert_from_struct_tm: procedure(ptime: png_timep; ttime: Pointer);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
700 png_convert_from_time_t: procedure(ptime: png_timep; ttime: png_time_t);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
701 png_set_expand: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
702 png_set_palette_to_rgb: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
703 png_set_tRNS_to_alpha: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
704 png_set_bgr: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
705 png_set_gray_to_rgb: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
706 png_set_rgb_to_gray: procedure(png_ptr: png_structp; error_action: CInt32; red: double; green: double);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
707 png_set_rgb_to_gray_fixed: procedure(png_ptr: png_structp; error_action: CInt32; red: png_fixed_point; green: png_fixed_point);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
708 png_get_rgb_to_gray_status: function(png_ptr: png_structp): png_byte;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
709 png_build_grayscale_palette: procedure(bit_depth: CInt32; palette: png_colorp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
710 png_set_strip_alpha: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
711 png_set_swap_alpha: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
712 png_set_invert_alpha: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
713 png_set_filler: procedure(png_ptr: png_structp; filler: png_uint_32; flags: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
714 png_set_swap: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
715 png_set_packing: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
716 png_set_packswap: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
717 png_set_shift: procedure(png_ptr: png_structp; true_bits: png_color_8p);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
718 png_set_interlace_handling: function(png_ptr: png_structp): CInt32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
719 png_set_invert_mono: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
720 png_set_background: procedure(png_ptr: png_structp; background_color: png_color_16p; background_gamma_code: CInt32; need_expand: CInt32; background_gamma: double);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
721 png_set_strip_16: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
722 png_set_gamma: procedure(png_ptr: png_structp; screen_gamma: double; default_file_gamma: double);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
723 png_set_flush: procedure(png_ptr: png_structp; nrows: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
724 png_write_flush: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
725 png_start_read_image: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
726 png_read_update_info: procedure(png_ptr: png_structp; info_ptr: png_infop);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
727 png_read_rows: procedure(png_ptr: png_structp; row: png_bytepp; display_row: png_bytepp; num_rows: png_uint_32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
728 png_read_row: procedure(png_ptr: png_structp; row: png_bytep; display_row: png_bytep);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
729 png_read_image: procedure(png_ptr: png_structp; image: png_bytepp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
730 png_write_row: procedure(png_ptr: png_structp; row: png_bytep);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
731 png_write_rows: procedure(png_ptr: png_structp; row: png_bytepp; num_rows: png_uint_32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
732 png_write_image: procedure(png_ptr: png_structp; image: png_bytepp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
733 png_write_end: procedure(png_ptr: png_structp; info_ptr: png_infop);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
734 png_read_end: procedure(png_ptr: png_structp; info_ptr: png_infop);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
735 png_destroy_info_struct: procedure(png_ptr: png_structp; info_ptr_ptr: png_infopp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
736 png_destroy_read_struct: procedure(png_ptr_ptr: png_structpp; info_ptr_ptr: png_infopp; end_info_ptr_ptr: png_infopp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
737 png_destroy_write_struct: procedure(png_ptr_ptr: png_structpp; info_ptr_ptr: png_infopp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
738
739 png_set_crc_action: procedure(png_ptr: png_structp; crit_action: CInt32; ancil_action: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
740 png_set_filter: procedure(png_ptr: png_structp; method: CInt32; filters: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
741 png_set_filter_heuristics: procedure(png_ptr: png_structp; heuristic_method: CInt32; num_weights: CInt32; filter_weights: png_doublep; filter_costs: png_doublep);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
742 png_set_compression_level: procedure(png_ptr: png_structp; level: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
743 png_set_compression_mem_level: procedure(png_ptr: png_structp; mem_level: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
744 png_set_compression_strategy: procedure(png_ptr: png_structp; strategy: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
745 png_set_compression_window_bits: procedure(png_ptr: png_structp; window_bits: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
746 png_set_compression_method: procedure(png_ptr: png_structp; method: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
747 png_init_io: procedure(png_ptr: png_structp; fp: png_FILE_p);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
748 png_set_error_fn: procedure(png_ptr: png_structp; error_ptr: png_voidp; error_fn: png_error_ptr; warning_fn: png_error_ptr);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
749 png_get_error_ptr: function(png_ptr: png_structp): png_voidp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
750 png_set_write_fn: procedure(png_ptr: png_structp; io_ptr: png_voidp; write_data_fn: png_rw_ptr; output_flush_fn: png_flush_ptr);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
751 png_set_read_fn: procedure(png_ptr: png_structp; io_ptr: png_voidp; read_data_fn: png_rw_ptr);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
752 png_get_io_ptr: function(png_ptr: png_structp): png_voidp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
753 png_set_read_status_fn: procedure(png_ptr: png_structp; read_row_fn: png_read_status_ptr);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
754 png_set_write_status_fn: procedure(png_ptr: png_structp; write_row_fn: png_write_status_ptr);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
755 png_set_read_user_transform_fn: procedure(png_ptr: png_structp; read_user_transform_fn: png_user_transform_ptr);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
756 png_set_write_user_transform_fn: procedure(png_ptr: png_structp; write_user_transform_fn: png_user_transform_ptr);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
757 png_set_user_transform_info: procedure(png_ptr: png_structp; user_transform_ptr: png_voidp; user_transform_depth: CInt32; user_transform_channels: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
758 png_get_user_transform_ptr: function(png_ptr: png_structp): png_voidp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
759 png_set_read_user_chunk_fn: procedure(png_ptr: png_structp; user_chunk_ptr: png_voidp; read_user_chunk_fn: png_user_chunk_ptr);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
760 png_get_user_chunk_ptr: function(png_ptr: png_structp): png_voidp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
761 png_set_progressive_read_fn: procedure(png_ptr: png_structp; progressive_ptr: png_voidp; info_fn: png_progressive_info_ptr; row_fn: png_progressive_row_ptr; end_fn: png_progressive_end_ptr);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
762 png_get_progressive_ptr: function(png_ptr: png_structp): png_voidp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
763 png_process_data: procedure(png_ptr: png_structp; info_ptr: png_infop; buffer: png_bytep; buffer_size: png_size_t);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
764 png_progressive_combine_row: procedure(png_ptr: png_structp; old_row: png_bytep; new_row: png_bytep);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
765 {$ifdef LIBPNG_1_4}
766 png_malloc: function(png_ptr: png_structp; size: png_alloc_size_t { png_uint_32 in libpng < 1.4 }): png_voidp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
767 {$endif}
768 png_free: procedure(png_ptr: png_structp; ptr: png_voidp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
769 png_free_data: procedure(png_ptr: png_structp; info_ptr: png_infop; free_me: png_uint_32; num: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
770 png_data_freer: procedure(png_ptr: png_structp; info_ptr: png_infop; freer: CInt32; mask: png_uint_32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
771 png_error: procedure(png_ptr: png_structp; error: png_const_charp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
772 png_chunk_error: procedure(png_ptr: png_structp; error: png_const_charp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
773 png_warning: procedure(png_ptr: png_structp; message: png_const_charp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
774 png_chunk_warning: procedure(png_ptr: png_structp; message: png_const_charp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
775 png_get_valid: function(png_ptr: png_structp; info_ptr: png_infop; flag: png_uint_32): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
776 png_get_rowbytes: function(png_ptr: png_structp; info_ptr: png_infop): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
777 png_get_rows: function(png_ptr: png_structp; info_ptr: png_infop): png_bytepp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
778 png_set_rows: procedure(png_ptr: png_structp; info_ptr: png_infop; row_pointers: png_bytepp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
779 png_get_channels: function(png_ptr: png_structp; info_ptr: png_infop): png_byte;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
780 png_get_image_width: function(png_ptr: png_structp; info_ptr: png_infop): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
781 png_get_image_height: function(png_ptr: png_structp; info_ptr: png_infop): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
782 png_get_bit_depth: function(png_ptr: png_structp; info_ptr: png_infop): png_byte;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
783 png_get_color_type: function(png_ptr: png_structp; info_ptr: png_infop): png_byte;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
784 png_get_filter_type: function(png_ptr: png_structp; info_ptr: png_infop): png_byte;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
785 png_get_interlace_type: function(png_ptr: png_structp; info_ptr: png_infop): png_byte;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
786 png_get_compression_type: function(png_ptr: png_structp; info_ptr: png_infop): png_byte;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
787 png_get_pixels_per_meter: function(png_ptr: png_structp; info_ptr: png_infop): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
788 png_get_x_pixels_per_meter: function(png_ptr: png_structp; info_ptr: png_infop): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
789 png_get_y_pixels_per_meter: function(png_ptr: png_structp; info_ptr: png_infop): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
790 png_get_pixel_aspect_ratio: function(png_ptr: png_structp; info_ptr: png_infop): double;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
791 png_get_x_offset_pixels: function(png_ptr: png_structp; info_ptr: png_infop): png_int_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
792 png_get_y_offset_pixels: function(png_ptr: png_structp; info_ptr: png_infop): png_int_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
793 png_get_x_offset_microns: function(png_ptr: png_structp; info_ptr: png_infop): png_int_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
794 png_get_y_offset_microns: function(png_ptr: png_structp; info_ptr: png_infop): png_int_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
795 png_get_signature: function(png_ptr: png_structp; info_ptr: png_infop): png_bytep;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
796 png_get_bKGD: function(png_ptr: png_structp; info_ptr: png_infop; background: Ppng_color_16p): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
797 png_set_bKGD: procedure(png_ptr: png_structp; info_ptr: png_infop; background: png_color_16p);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
798 png_get_cHRM: function(png_ptr: png_structp; info_ptr: png_infop; white_x: Pdouble; white_y: Pdouble; red_x: Pdouble;
799 red_y: Pdouble; green_x: Pdouble; green_y: Pdouble; blue_x: Pdouble; blue_y: Pdouble): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
800 png_get_cHRM_fixed: function(png_ptr: png_structp; info_ptr: png_infop; int_white_x: Ppng_fixed_point; int_white_y: Ppng_fixed_point; int_red_x: Ppng_fixed_point;
801 int_red_y: Ppng_fixed_point; int_green_x: Ppng_fixed_point; int_green_y: Ppng_fixed_point; int_blue_x: Ppng_fixed_point; int_blue_y: Ppng_fixed_point): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
802 png_set_cHRM: procedure(png_ptr: png_structp; info_ptr: png_infop; white_x: double; white_y: double; red_x: double;
803 red_y: double; green_x: double; green_y: double; blue_x: double; blue_y: double);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
804 png_set_cHRM_fixed: procedure(png_ptr: png_structp; info_ptr: png_infop; int_white_x: png_fixed_point; int_white_y: png_fixed_point; int_red_x: png_fixed_point;
805 int_red_y: png_fixed_point; int_green_x: png_fixed_point; int_green_y: png_fixed_point; int_blue_x: png_fixed_point; int_blue_y: png_fixed_point);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
806 png_get_gAMA: function(png_ptr: png_structp; info_ptr: png_infop; file_gamma: Pdouble): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
807 png_get_gAMA_fixed: function(png_ptr: png_structp; info_ptr: png_infop; int_file_gamma: Ppng_fixed_point): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
808 png_set_gAMA: procedure(png_ptr: png_structp; info_ptr: png_infop; file_gamma: double);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
809 png_set_gAMA_fixed: procedure(png_ptr: png_structp; info_ptr: png_infop; int_file_gamma: png_fixed_point);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
810 png_get_hIST: function(png_ptr: png_structp; info_ptr: png_infop; hist: Ppng_uint_16p): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
811 png_set_hIST: procedure(png_ptr: png_structp; info_ptr: png_infop; hist: png_uint_16p);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
812 png_get_IHDR: function(png_ptr: png_structp; info_ptr: png_infop; width: Ppng_uint_32; height: Ppng_uint_32; bit_depth: PCInt32;
813 color_type: PCInt32; interlace_type: PCInt32; compression_type: PCInt32; filter_type: PCInt32): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
814 png_set_IHDR: procedure(png_ptr: png_structp; info_ptr: png_infop; width: png_uint_32; height: png_uint_32; bit_depth: CInt32;
815 color_type: CInt32; interlace_type: CInt32; compression_type: CInt32; filter_type: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
816 png_get_oFFs: function(png_ptr: png_structp; info_ptr: png_infop; offset_x: Ppng_int_32; offset_y: Ppng_int_32; unit_type: PCInt32): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
817 png_set_oFFs: procedure(png_ptr: png_structp; info_ptr: png_infop; offset_x: png_int_32; offset_y: png_int_32; unit_type: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
818 png_get_pCAL: function(png_ptr: png_structp; info_ptr: png_infop; purpose: Ppng_charp; X0: Ppng_int_32; X1: Ppng_int_32;
819 atype: PCInt32; nparams: PCInt32; units: Ppng_charp; params: Ppng_charpp): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
820 png_set_pCAL: procedure(png_ptr: png_structp; info_ptr: png_infop; purpose: png_charp; X0: png_int_32; X1: png_int_32;
821 atype: CInt32; nparams: CInt32; units: png_charp; params: png_charpp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
822 png_get_pHYs: function(png_ptr: png_structp; info_ptr: png_infop; res_x: Ppng_uint_32; res_y: Ppng_uint_32; unit_type: PCInt32): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
823 png_set_pHYs: procedure(png_ptr: png_structp; info_ptr: png_infop; res_x: png_uint_32; res_y: png_uint_32; unit_type: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
824 png_get_PLTE: function(png_ptr: png_structp; info_ptr: png_infop; palette: Ppng_colorp; num_palette: PCInt32): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
825 png_set_PLTE: procedure(png_ptr: png_structp; info_ptr: png_infop; palette: png_colorp; num_palette: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
826 png_get_sBIT: function(png_ptr: png_structp; info_ptr: png_infop; sig_bit: Ppng_color_8p): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
827 png_set_sBIT: procedure(png_ptr: png_structp; info_ptr: png_infop; sig_bit: png_color_8p);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
828 png_get_sRGB: function(png_ptr: png_structp; info_ptr: png_infop; intent: PCInt32): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
829 png_set_sRGB: procedure(png_ptr: png_structp; info_ptr: png_infop; intent: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
830 png_set_sRGB_gAMA_and_cHRM: procedure(png_ptr: png_structp; info_ptr: png_infop; intent: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
831 png_get_iCCP: function(png_ptr: png_structp; info_ptr: png_infop; name: png_charpp; compression_type: PCInt32; profile: png_charpp;
832 proflen: Ppng_uint_32): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
833 png_set_iCCP: procedure(png_ptr: png_structp; info_ptr: png_infop; name: png_charp; compression_type: CInt32; profile: png_charp;
834 proflen: png_uint_32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
835 png_get_sPLT: function(png_ptr: png_structp; info_ptr: png_infop; entries: png_sPLT_tpp): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
836 png_set_sPLT: procedure(png_ptr: png_structp; info_ptr: png_infop; entries: png_sPLT_tp; nentries: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
837 png_get_text: function(png_ptr: png_structp; info_ptr: png_infop; text_ptr: Ppng_textp; num_text: PCInt32): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
838 png_set_text: procedure(png_ptr: png_structp; info_ptr: png_infop; text_ptr: png_textp; num_text: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
839 png_get_tIME: function(png_ptr: png_structp; info_ptr: png_infop; mod_time: Ppng_timep): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
840 png_set_tIME: procedure(png_ptr: png_structp; info_ptr: png_infop; mod_time: png_timep);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
841 png_get_tRNS: function(png_ptr: png_structp; info_ptr: png_infop; trans: Ppng_bytep; num_trans: PCInt32; trans_values: Ppng_color_16p): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
842 png_set_tRNS: procedure(png_ptr: png_structp; info_ptr: png_infop; trans: png_bytep; num_trans: CInt32; trans_values: png_color_16p);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
843 png_get_sCAL: function(png_ptr: png_structp; info_ptr: png_infop; aunit: PCInt32; width: Pdouble; height: Pdouble): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
844 png_set_sCAL: procedure(png_ptr: png_structp; info_ptr: png_infop; aunit: CInt32; width: double; height: double);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
845 png_set_keep_unknown_chunks: procedure(png_ptr: png_structp; keep: CInt32; chunk_list: png_bytep; num_chunks: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
846 png_set_unknown_chunks: procedure(png_ptr: png_structp; info_ptr: png_infop; unknowns: png_unknown_chunkp; num_unknowns: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
847 png_set_unknown_chunk_location: procedure(png_ptr: png_structp; info_ptr: png_infop; chunk: CInt32; location: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
848 png_get_unknown_chunks: function(png_ptr: png_structp; info_ptr: png_infop; entries: png_unknown_chunkpp): png_uint_32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
849 png_set_invalid: procedure(png_ptr: png_structp; info_ptr: png_infop; mask: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
850 png_read_png: procedure(png_ptr: png_structp; info_ptr: png_infop; transforms: CInt32; params: png_voidp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
851 png_write_png: procedure(png_ptr: png_structp; info_ptr: png_infop; transforms: CInt32; params: png_voidp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
852 png_get_header_ver: function(png_ptr: png_structp): png_charp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
853 png_get_header_version: function(png_ptr: png_structp): png_charp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
854
855 { Since libpng-1.0.18 and 1.2.9, according to
856 http://www.libpng.org/pub/png/src/libpng-1.2.x-to-1.4.x-summary.txt.
857 Will be set to @nil for older libpngs. }
858 png_set_expand_gray_1_2_4_to_8: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
859
860 {$ifdef LIBPNG_DEPRECATED}
861 { These are deprecated, and not available anymore in many libgpng,
862 by experience. }
863 png_write_destroy_info: procedure(info_ptr: png_infop);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
864 png_set_sCAL_s: procedure(png_ptr: png_structp; info_ptr: png_infop; aunit: CInt32; swidth: png_charp; sheight: png_charp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
865 { Not since libpng 1.4 }
866 png_set_dither: procedure(png_ptr: png_structp; palette: png_colorp; num_palette: CInt32; maximum_colors: CInt32; histogram: png_uint_16p;
867 full_dither: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
868
869 { These are deprecated since libpng 0.95,
870 and not available anymore in libpng 1.4
871 (following http://www.libpng.org/pub/png/src/libpng-1.2.x-to-1.4.x-summary.txt) }
872 png_info_init: procedure(info_ptr: png_infop);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
873 png_read_destroy: procedure(png_ptr: png_structp; info_ptr: png_infop; end_info_ptr: png_infop);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
874 png_write_destroy: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
875
876 { These are deprecated since libpng 1.0.9,
877 and not available anymore in libpng 1.4
878 (following http://www.libpng.org/pub/png/src/libpng-1.2.x-to-1.4.x-summary.txt) }
879 png_permit_empty_plte: procedure(png_ptr: png_structp; empty_plte_permitted: CInt32);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
880
881 { These are deprecated,
882 and not available anymore in libpng 1.4
883 (following http://www.libpng.org/pub/png/src/libpng-1.2.x-to-1.4.x-summary.txt) }
884 png_check_sig: function(sig: png_bytep; num: CInt32): CInt32;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
885 png_memcpy_check: function(png_ptr: png_structp; s1: png_voidp; s2: png_voidp; size: png_uint_32): png_voidp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
886 png_memset_check: function(png_ptr: png_structp; s1: png_voidp; value: CInt32; size: png_uint_32): png_voidp;{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
887 png_set_gray_1_2_4_to_8: procedure(png_ptr: png_structp);{$ifndef LIBPNG_CDECL} stdcall {$else} cdecl {$endif};
888 {$endif LIBPNG_DEPRECATED}
889
890 { Returns true if Libpng was available and has compatible version.
891 When @true, most functions
892 in this unit are guaranteed to be initialized to non-nil values
893 (although there are some functions that are optional, see docs above).
894
895 It returns false if libpng library was not available (or maybe the required
896 version was not available). Then all png_xxx functions in this unit are nil
897 and you can't use them. }
898 function CastlePngInitialized: boolean;
899
900 procedure PngInitialization;
901
902 implementation
903
904 uses SysUtils,
905 CastleDynLib, CastleUtils, CastleLog
906 {$ifdef DARWIN}, { for BundlePath } CastleFilesUtils {$endif};
907
908 var
909 PngLibrary: TDynLib;
910
911 function CastlePngInitialized: boolean;
912 begin
913 Result := PngLibrary <> nil;
914 end;
915
916 procedure PngInitialization;
917
918 function CheckVersion: Boolean;
919 var
920 VerNumber: png_uint_32;
921 Release, Minor, Major: Integer;
922 begin
923 VerNumber := png_access_version_number();
924 Release := VerNumber mod 100;
925 Minor := (VerNumber mod 10000) div 100;
926 Major := VerNumber div 10000;
927
928 Result := Major = 1;
929 if not Result then
930 WritelnWarning('LibPng dynamic library exists, but has incompatible version: %d.%d.%d',
931 [Major, Minor, Release]);
932 end;
933
934 begin
935 FreeAndNil(PngLibrary);
936
937 {$ifdef MSWINDOWS}
938 { libpng common names for Windows }
939 { libpng for win64 distributed by http://www.gtk.org/download/win64.php }
940 if PngLibrary = nil then
941 PngLibrary := TDynLib.Load('libpng14-14.dll', false);
942 { libpng distributed by gnuwin32.sourceforge.net }
943 if PngLibrary = nil then
944 PngLibrary := TDynLib.Load('libpng13.dll', false);
945 if PngLibrary = nil then
946 PngLibrary := TDynLib.Load('libpng12.dll', false);
947 {$endif}
948
949 {$ifdef UNIX}
950
951 {$ifdef DARWIN}
952 { libpng common names for macOS }
953 if PngLibrary = nil then
954 PngLibrary := TDynLib.Load('libpng.dylib', false);
955 if (PngLibrary = nil) and (BundlePath <> '') then
956 PngLibrary := TDynLib.Load(BundlePath + 'Contents/MacOS/libpng14.14.dylib', false);
957
958 {$else DARWIN}
959 { libpng common names for Linux, FreeBSD and other Unixes (except macOS) }
960 if PngLibrary = nil then
961 PngLibrary := TDynLib.Load('libpng16.so.16', false);
962 if PngLibrary = nil then
963 PngLibrary := TDynLib.Load('libpng14.so.14', false);
964 if PngLibrary = nil then
965 PngLibrary := TDynLib.Load('libpng14.so', false);
966 if PngLibrary = nil then
967 PngLibrary := TDynLib.Load('libpng12.so.0', false);
968 { As a final fallback, use the libpng that comes from a package like libpng-dev.
969 Also this matches name on Android. }
970 if PngLibrary = nil then
971 PngLibrary := TDynLib.Load('libpng.so', false);
972 {$endif DARWIN}
973
974 {$endif UNIX}
975
976 if PngLibrary <> nil then
977 begin
978 {$ifdef ANDROID}
979 { Temporarily continue, despite missing symbols, on Android, as a workaround for
980 https://trello.com/c/wmxWrx8d/190-android-50-libpng-not-found }
981 PngLibrary.SymbolError := seWarnAndReturnNil;
982 {$endif}
983
984 Pointer({$ifndef FPC}@{$endif} png_access_version_number) := PngLibrary.Symbol('png_access_version_number');
985 Pointer({$ifndef FPC}@{$endif} png_set_sig_bytes) := PngLibrary.Symbol('png_set_sig_bytes');
986 Pointer({$ifndef FPC}@{$endif} png_sig_cmp) := PngLibrary.Symbol('png_sig_cmp');
987 Pointer({$ifndef FPC}@{$endif} png_create_read_struct) := PngLibrary.Symbol('png_create_read_struct');
988 Pointer({$ifndef FPC}@{$endif} png_create_write_struct) := PngLibrary.Symbol('png_create_write_struct');
989 {$ifdef LIBPNG_1_4}
990 Pointer({$ifndef FPC}@{$endif} png_get_compression_buffer_size) := PngLibrary.Symbol('png_get_compression_buffer_size');
991 Pointer({$ifndef FPC}@{$endif} png_set_compression_buffer_size) := PngLibrary.Symbol('png_set_compression_buffer_size');
992 {$endif}
993 Pointer({$ifndef FPC}@{$endif} png_reset_zstream) := PngLibrary.Symbol('png_reset_zstream');
994 Pointer({$ifndef FPC}@{$endif} png_write_chunk) := PngLibrary.Symbol('png_write_chunk');
995 Pointer({$ifndef FPC}@{$endif} png_write_chunk_start) := PngLibrary.Symbol('png_write_chunk_start');
996 Pointer({$ifndef FPC}@{$endif} png_write_chunk_data) := PngLibrary.Symbol('png_write_chunk_data');
997 Pointer({$ifndef FPC}@{$endif} png_write_chunk_end) := PngLibrary.Symbol('png_write_chunk_end');
998 Pointer({$ifndef FPC}@{$endif} png_create_info_struct) := PngLibrary.Symbol('png_create_info_struct');
999 Pointer({$ifndef FPC}@{$endif} png_write_info_before_PLTE) := PngLibrary.Symbol('png_write_info_before_PLTE');
1000 Pointer({$ifndef FPC}@{$endif} png_write_info) := PngLibrary.Symbol('png_write_info');
1001 Pointer({$ifndef FPC}@{$endif} png_read_info) := PngLibrary.Symbol('png_read_info');
1002 Pointer({$ifndef FPC}@{$endif} png_convert_to_rfc1123) := PngLibrary.Symbol('png_convert_to_rfc1123');
1003 Pointer({$ifndef FPC}@{$endif} png_convert_from_struct_tm) := PngLibrary.Symbol('png_convert_from_struct_tm');
1004 Pointer({$ifndef FPC}@{$endif} png_convert_from_time_t) := PngLibrary.Symbol('png_convert_from_time_t');
1005 Pointer({$ifndef FPC}@{$endif} png_set_expand) := PngLibrary.Symbol('png_set_expand');
1006 Pointer({$ifndef FPC}@{$endif} png_set_palette_to_rgb) := PngLibrary.Symbol('png_set_palette_to_rgb');
1007 Pointer({$ifndef FPC}@{$endif} png_set_tRNS_to_alpha) := PngLibrary.Symbol('png_set_tRNS_to_alpha');
1008 Pointer({$ifndef FPC}@{$endif} png_set_bgr) := PngLibrary.Symbol('png_set_bgr');
1009 Pointer({$ifndef FPC}@{$endif} png_set_gray_to_rgb) := PngLibrary.Symbol('png_set_gray_to_rgb');
1010 Pointer({$ifndef FPC}@{$endif} png_set_rgb_to_gray) := PngLibrary.Symbol('png_set_rgb_to_gray');
1011 Pointer({$ifndef FPC}@{$endif} png_set_rgb_to_gray_fixed) := PngLibrary.Symbol('png_set_rgb_to_gray_fixed');
1012 Pointer({$ifndef FPC}@{$endif} png_get_rgb_to_gray_status) := PngLibrary.Symbol('png_get_rgb_to_gray_status');
1013 Pointer({$ifndef FPC}@{$endif} png_build_grayscale_palette) := PngLibrary.Symbol('png_build_grayscale_palette');
1014 Pointer({$ifndef FPC}@{$endif} png_set_strip_alpha) := PngLibrary.Symbol('png_set_strip_alpha');
1015 Pointer({$ifndef FPC}@{$endif} png_set_swap_alpha) := PngLibrary.Symbol('png_set_swap_alpha');
1016 Pointer({$ifndef FPC}@{$endif} png_set_invert_alpha) := PngLibrary.Symbol('png_set_invert_alpha');
1017 Pointer({$ifndef FPC}@{$endif} png_set_filler) := PngLibrary.Symbol('png_set_filler');
1018 Pointer({$ifndef FPC}@{$endif} png_set_swap) := PngLibrary.Symbol('png_set_swap');
1019 Pointer({$ifndef FPC}@{$endif} png_set_packing) := PngLibrary.Symbol('png_set_packing');
1020 Pointer({$ifndef FPC}@{$endif} png_set_packswap) := PngLibrary.Symbol('png_set_packswap');
1021 Pointer({$ifndef FPC}@{$endif} png_set_shift) := PngLibrary.Symbol('png_set_shift');
1022 Pointer({$ifndef FPC}@{$endif} png_set_interlace_handling) := PngLibrary.Symbol('png_set_interlace_handling');
1023 Pointer({$ifndef FPC}@{$endif} png_set_invert_mono) := PngLibrary.Symbol('png_set_invert_mono');
1024 Pointer({$ifndef FPC}@{$endif} png_set_background) := PngLibrary.Symbol('png_set_background');
1025 Pointer({$ifndef FPC}@{$endif} png_set_strip_16) := PngLibrary.Symbol('png_set_strip_16');
1026 Pointer({$ifndef FPC}@{$endif} png_set_gamma) := PngLibrary.Symbol('png_set_gamma');
1027 Pointer({$ifndef FPC}@{$endif} png_set_flush) := PngLibrary.Symbol('png_set_flush');
1028 Pointer({$ifndef FPC}@{$endif} png_write_flush) := PngLibrary.Symbol('png_write_flush');
1029 Pointer({$ifndef FPC}@{$endif} png_start_read_image) := PngLibrary.Symbol('png_start_read_image');
1030 Pointer({$ifndef FPC}@{$endif} png_read_update_info) := PngLibrary.Symbol('png_read_update_info');
1031 Pointer({$ifndef FPC}@{$endif} png_read_rows) := PngLibrary.Symbol('png_read_rows');
1032 Pointer({$ifndef FPC}@{$endif} png_read_row) := PngLibrary.Symbol('png_read_row');
1033 Pointer({$ifndef FPC}@{$endif} png_read_image) := PngLibrary.Symbol('png_read_image');
1034 Pointer({$ifndef FPC}@{$endif} png_write_row) := PngLibrary.Symbol('png_write_row');
1035 Pointer({$ifndef FPC}@{$endif} png_write_rows) := PngLibrary.Symbol('png_write_rows');
1036 Pointer({$ifndef FPC}@{$endif} png_write_image) := PngLibrary.Symbol('png_write_image');
1037 Pointer({$ifndef FPC}@{$endif} png_write_end) := PngLibrary.Symbol('png_write_end');
1038 Pointer({$ifndef FPC}@{$endif} png_read_end) := PngLibrary.Symbol('png_read_end');
1039 Pointer({$ifndef FPC}@{$endif} png_destroy_info_struct) := PngLibrary.Symbol('png_destroy_info_struct');
1040 Pointer({$ifndef FPC}@{$endif} png_destroy_read_struct) := PngLibrary.Symbol('png_destroy_read_struct');
1041 Pointer({$ifndef FPC}@{$endif} png_destroy_write_struct) := PngLibrary.Symbol('png_destroy_write_struct');
1042 Pointer({$ifndef FPC}@{$endif} png_set_crc_action) := PngLibrary.Symbol('png_set_crc_action');
1043 Pointer({$ifndef FPC}@{$endif} png_set_filter) := PngLibrary.Symbol('png_set_filter');
1044 Pointer({$ifndef FPC}@{$endif} png_set_filter_heuristics) := PngLibrary.Symbol('png_set_filter_heuristics');
1045 Pointer({$ifndef FPC}@{$endif} png_set_compression_level) := PngLibrary.Symbol('png_set_compression_level');
1046 Pointer({$ifndef FPC}@{$endif} png_set_compression_mem_level) := PngLibrary.Symbol('png_set_compression_mem_level');
1047 Pointer({$ifndef FPC}@{$endif} png_set_compression_strategy) := PngLibrary.Symbol('png_set_compression_strategy');
1048 Pointer({$ifndef FPC}@{$endif} png_set_compression_window_bits) := PngLibrary.Symbol('png_set_compression_window_bits');
1049 Pointer({$ifndef FPC}@{$endif} png_set_compression_method) := PngLibrary.Symbol('png_set_compression_method');
1050 Pointer({$ifndef FPC}@{$endif} png_init_io) := PngLibrary.Symbol('png_init_io');
1051 Pointer({$ifndef FPC}@{$endif} png_set_error_fn) := PngLibrary.Symbol('png_set_error_fn');
1052 Pointer({$ifndef FPC}@{$endif} png_get_error_ptr) := PngLibrary.Symbol('png_get_error_ptr');
1053 Pointer({$ifndef FPC}@{$endif} png_set_write_fn) := PngLibrary.Symbol('png_set_write_fn');
1054 Pointer({$ifndef FPC}@{$endif} png_set_read_fn) := PngLibrary.Symbol('png_set_read_fn');
1055 Pointer({$ifndef FPC}@{$endif} png_get_io_ptr) := PngLibrary.Symbol('png_get_io_ptr');
1056 Pointer({$ifndef FPC}@{$endif} png_set_read_status_fn) := PngLibrary.Symbol('png_set_read_status_fn');
1057 Pointer({$ifndef FPC}@{$endif} png_set_write_status_fn) := PngLibrary.Symbol('png_set_write_status_fn');
1058 Pointer({$ifndef FPC}@{$endif} png_set_read_user_transform_fn) := PngLibrary.Symbol('png_set_read_user_transform_fn');
1059 Pointer({$ifndef FPC}@{$endif} png_set_write_user_transform_fn) := PngLibrary.Symbol('png_set_write_user_transform_fn');
1060 Pointer({$ifndef FPC}@{$endif} png_set_user_transform_info) := PngLibrary.Symbol('png_set_user_transform_info');
1061 Pointer({$ifndef FPC}@{$endif} png_get_user_transform_ptr) := PngLibrary.Symbol('png_get_user_transform_ptr');
1062 Pointer({$ifndef FPC}@{$endif} png_set_read_user_chunk_fn) := PngLibrary.Symbol('png_set_read_user_chunk_fn');
1063 Pointer({$ifndef FPC}@{$endif} png_get_user_chunk_ptr) := PngLibrary.Symbol('png_get_user_chunk_ptr');
1064 Pointer({$ifndef FPC}@{$endif} png_set_progressive_read_fn) := PngLibrary.Symbol('png_set_progressive_read_fn');
1065 Pointer({$ifndef FPC}@{$endif} png_get_progressive_ptr) := PngLibrary.Symbol('png_get_progressive_ptr');
1066 Pointer({$ifndef FPC}@{$endif} png_process_data) := PngLibrary.Symbol('png_process_data');
1067 Pointer({$ifndef FPC}@{$endif} png_progressive_combine_row) := PngLibrary.Symbol('png_progressive_combine_row');
1068 {$ifdef LIBPNG_1_4}
1069 Pointer({$ifndef FPC}@{$endif} png_malloc) := PngLibrary.Symbol('png_malloc');
1070 {$endif}
1071 Pointer({$ifndef FPC}@{$endif} png_free) := PngLibrary.Symbol('png_free');
1072 Pointer({$ifndef FPC}@{$endif} png_free_data) := PngLibrary.Symbol('png_free_data');
1073 Pointer({$ifndef FPC}@{$endif} png_data_freer) := PngLibrary.Symbol('png_data_freer');
1074 Pointer({$ifndef FPC}@{$endif} png_error) := PngLibrary.Symbol('png_error');
1075 Pointer({$ifndef FPC}@{$endif} png_chunk_error) := PngLibrary.Symbol('png_chunk_error');
1076 Pointer({$ifndef FPC}@{$endif} png_warning) := PngLibrary.Symbol('png_warning');
1077 Pointer({$ifndef FPC}@{$endif} png_chunk_warning) := PngLibrary.Symbol('png_chunk_warning');
1078 Pointer({$ifndef FPC}@{$endif} png_get_valid) := PngLibrary.Symbol('png_get_valid');
1079 Pointer({$ifndef FPC}@{$endif} png_get_rowbytes) := PngLibrary.Symbol('png_get_rowbytes');
1080 Pointer({$ifndef FPC}@{$endif} png_get_rows) := PngLibrary.Symbol('png_get_rows');
1081 Pointer({$ifndef FPC}@{$endif} png_set_rows) := PngLibrary.Symbol('png_set_rows');
1082 Pointer({$ifndef FPC}@{$endif} png_get_channels) := PngLibrary.Symbol('png_get_channels');
1083 Pointer({$ifndef FPC}@{$endif} png_get_image_width) := PngLibrary.Symbol('png_get_image_width');
1084 Pointer({$ifndef FPC}@{$endif} png_get_image_height) := PngLibrary.Symbol('png_get_image_height');
1085 Pointer({$ifndef FPC}@{$endif} png_get_bit_depth) := PngLibrary.Symbol('png_get_bit_depth');
1086 Pointer({$ifndef FPC}@{$endif} png_get_color_type) := PngLibrary.Symbol('png_get_color_type');
1087 Pointer({$ifndef FPC}@{$endif} png_get_filter_type) := PngLibrary.Symbol('png_get_filter_type');
1088 Pointer({$ifndef FPC}@{$endif} png_get_interlace_type) := PngLibrary.Symbol('png_get_interlace_type');
1089 Pointer({$ifndef FPC}@{$endif} png_get_compression_type) := PngLibrary.Symbol('png_get_compression_type');
1090 Pointer({$ifndef FPC}@{$endif} png_get_pixels_per_meter) := PngLibrary.Symbol('png_get_pixels_per_meter');
1091 Pointer({$ifndef FPC}@{$endif} png_get_x_pixels_per_meter) := PngLibrary.Symbol('png_get_x_pixels_per_meter');
1092 Pointer({$ifndef FPC}@{$endif} png_get_y_pixels_per_meter) := PngLibrary.Symbol('png_get_y_pixels_per_meter');
1093 Pointer({$ifndef FPC}@{$endif} png_get_pixel_aspect_ratio) := PngLibrary.Symbol('png_get_pixel_aspect_ratio');
1094 Pointer({$ifndef FPC}@{$endif} png_get_x_offset_pixels) := PngLibrary.Symbol('png_get_x_offset_pixels');
1095 Pointer({$ifndef FPC}@{$endif} png_get_y_offset_pixels) := PngLibrary.Symbol('png_get_y_offset_pixels');
1096 Pointer({$ifndef FPC}@{$endif} png_get_x_offset_microns) := PngLibrary.Symbol('png_get_x_offset_microns');
1097 Pointer({$ifndef FPC}@{$endif} png_get_y_offset_microns) := PngLibrary.Symbol('png_get_y_offset_microns');
1098 Pointer({$ifndef FPC}@{$endif} png_get_signature) := PngLibrary.Symbol('png_get_signature');
1099 Pointer({$ifndef FPC}@{$endif} png_get_bKGD) := PngLibrary.Symbol('png_get_bKGD');
1100 Pointer({$ifndef FPC}@{$endif} png_set_bKGD) := PngLibrary.Symbol('png_set_bKGD');
1101 Pointer({$ifndef FPC}@{$endif} png_get_cHRM) := PngLibrary.Symbol('png_get_cHRM');
1102 Pointer({$ifndef FPC}@{$endif} png_get_cHRM_fixed) := PngLibrary.Symbol('png_get_cHRM_fixed');
1103 Pointer({$ifndef FPC}@{$endif} png_set_cHRM) := PngLibrary.Symbol('png_set_cHRM');
1104 Pointer({$ifndef FPC}@{$endif} png_set_cHRM_fixed) := PngLibrary.Symbol('png_set_cHRM_fixed');
1105 Pointer({$ifndef FPC}@{$endif} png_get_gAMA) := PngLibrary.Symbol('png_get_gAMA');
1106 Pointer({$ifndef FPC}@{$endif} png_get_gAMA_fixed) := PngLibrary.Symbol('png_get_gAMA_fixed');
1107 Pointer({$ifndef FPC}@{$endif} png_set_gAMA) := PngLibrary.Symbol('png_set_gAMA');
1108 Pointer({$ifndef FPC}@{$endif} png_set_gAMA_fixed) := PngLibrary.Symbol('png_set_gAMA_fixed');
1109 Pointer({$ifndef FPC}@{$endif} png_get_hIST) := PngLibrary.Symbol('png_get_hIST');
1110 Pointer({$ifndef FPC}@{$endif} png_set_hIST) := PngLibrary.Symbol('png_set_hIST');
1111 Pointer({$ifndef FPC}@{$endif} png_get_IHDR) := PngLibrary.Symbol('png_get_IHDR');
1112 Pointer({$ifndef FPC}@{$endif} png_set_IHDR) := PngLibrary.Symbol('png_set_IHDR');
1113 Pointer({$ifndef FPC}@{$endif} png_get_oFFs) := PngLibrary.Symbol('png_get_oFFs');
1114 Pointer({$ifndef FPC}@{$endif} png_set_oFFs) := PngLibrary.Symbol('png_set_oFFs');
1115 Pointer({$ifndef FPC}@{$endif} png_get_pCAL) := PngLibrary.Symbol('png_get_pCAL');
1116 Pointer({$ifndef FPC}@{$endif} png_set_pCAL) := PngLibrary.Symbol('png_set_pCAL');
1117 Pointer({$ifndef FPC}@{$endif} png_get_pHYs) := PngLibrary.Symbol('png_get_pHYs');
1118 Pointer({$ifndef FPC}@{$endif} png_set_pHYs) := PngLibrary.Symbol('png_set_pHYs');
1119 Pointer({$ifndef FPC}@{$endif} png_get_PLTE) := PngLibrary.Symbol('png_get_PLTE');
1120 Pointer({$ifndef FPC}@{$endif} png_set_PLTE) := PngLibrary.Symbol('png_set_PLTE');
1121 Pointer({$ifndef FPC}@{$endif} png_get_sBIT) := PngLibrary.Symbol('png_get_sBIT');
1122 Pointer({$ifndef FPC}@{$endif} png_set_sBIT) := PngLibrary.Symbol('png_set_sBIT');
1123 Pointer({$ifndef FPC}@{$endif} png_get_sRGB) := PngLibrary.Symbol('png_get_sRGB');
1124 Pointer({$ifndef FPC}@{$endif} png_set_sRGB) := PngLibrary.Symbol('png_set_sRGB');
1125 Pointer({$ifndef FPC}@{$endif} png_set_sRGB_gAMA_and_cHRM) := PngLibrary.Symbol('png_set_sRGB_gAMA_and_cHRM');
1126 Pointer({$ifndef FPC}@{$endif} png_get_iCCP) := PngLibrary.Symbol('png_get_iCCP');
1127 Pointer({$ifndef FPC}@{$endif} png_set_iCCP) := PngLibrary.Symbol('png_set_iCCP');
1128 Pointer({$ifndef FPC}@{$endif} png_get_sPLT) := PngLibrary.Symbol('png_get_sPLT');
1129 Pointer({$ifndef FPC}@{$endif} png_set_sPLT) := PngLibrary.Symbol('png_set_sPLT');
1130 Pointer({$ifndef FPC}@{$endif} png_get_text) := PngLibrary.Symbol('png_get_text');
1131 Pointer({$ifndef FPC}@{$endif} png_set_text) := PngLibrary.Symbol('png_set_text');
1132 Pointer({$ifndef FPC}@{$endif} png_get_tIME) := PngLibrary.Symbol('png_get_tIME');
1133 Pointer({$ifndef FPC}@{$endif} png_set_tIME) := PngLibrary.Symbol('png_set_tIME');
1134 Pointer({$ifndef FPC}@{$endif} png_get_tRNS) := PngLibrary.Symbol('png_get_tRNS');
1135 Pointer({$ifndef FPC}@{$endif} png_set_tRNS) := PngLibrary.Symbol('png_set_tRNS');
1136 Pointer({$ifndef FPC}@{$endif} png_get_sCAL) := PngLibrary.Symbol('png_get_sCAL');
1137 Pointer({$ifndef FPC}@{$endif} png_set_sCAL) := PngLibrary.Symbol('png_set_sCAL');
1138 Pointer({$ifndef FPC}@{$endif} png_set_keep_unknown_chunks) := PngLibrary.Symbol('png_set_keep_unknown_chunks');
1139 Pointer({$ifndef FPC}@{$endif} png_set_unknown_chunks) := PngLibrary.Symbol('png_set_unknown_chunks');
1140 Pointer({$ifndef FPC}@{$endif} png_set_unknown_chunk_location) := PngLibrary.Symbol('png_set_unknown_chunk_location');
1141 Pointer({$ifndef FPC}@{$endif} png_get_unknown_chunks) := PngLibrary.Symbol('png_get_unknown_chunks');
1142 Pointer({$ifndef FPC}@{$endif} png_set_invalid) := PngLibrary.Symbol('png_set_invalid');
1143 Pointer({$ifndef FPC}@{$endif} png_read_png) := PngLibrary.Symbol('png_read_png');
1144 Pointer({$ifndef FPC}@{$endif} png_write_png) := PngLibrary.Symbol('png_write_png');
1145 Pointer({$ifndef FPC}@{$endif} png_get_header_ver) := PngLibrary.Symbol('png_get_header_ver');
1146 Pointer({$ifndef FPC}@{$endif} png_get_header_version) := PngLibrary.Symbol('png_get_header_version');
1147
1148 { Allow png_set_expand_gray_1_2_4_to_8 to be nil when not found in library }
1149 PngLibrary.SymbolError := seReturnNil;
1150 Pointer({$ifndef FPC}@{$endif} png_set_expand_gray_1_2_4_to_8) := PngLibrary.Symbol('png_set_expand_gray_1_2_4_to_8');
1151 PngLibrary.SymbolError := seRaise;
1152
1153 {$ifdef LIBPNG_DEPRECATED}
1154 Pointer({$ifndef FPC}@{$endif} png_check_sig) := PngLibrary.Symbol('png_check_sig');
1155 Pointer({$ifndef FPC}@{$endif} png_info_init) := PngLibrary.Symbol('png_info_init');
1156 Pointer({$ifndef FPC}@{$endif} png_set_gray_1_2_4_to_8) := PngLibrary.Symbol('png_set_gray_1_2_4_to_8');
1157 Pointer({$ifndef FPC}@{$endif} png_permit_empty_plte) := PngLibrary.Symbol('png_permit_empty_plte');
1158 Pointer({$ifndef FPC}@{$endif} png_memcpy_check) := PngLibrary.Symbol('png_memcpy_check');
1159 Pointer({$ifndef FPC}@{$endif} png_memset_check) := PngLibrary.Symbol('png_memset_check');
1160 Pointer({$ifndef FPC}@{$endif} png_read_destroy) := PngLibrary.Symbol('png_read_destroy');
1161 Pointer({$ifndef FPC}@{$endif} png_write_destroy_info) := PngLibrary.Symbol('png_write_destroy_info');
1162 Pointer({$ifndef FPC}@{$endif} png_write_destroy) := PngLibrary.Symbol('png_write_destroy');
1163 Pointer({$ifndef FPC}@{$endif} png_set_sCAL_s) := PngLibrary.Symbol('png_set_sCAL_s');
1164 Pointer({$ifndef FPC}@{$endif} png_set_dither) := PngLibrary.Symbol('png_set_dither');
1165 {$endif LIBPNG_DEPRECATED}
1166
1167 { In case of incompatible version, free PngLibrary,
1168 making sure that CastlePngInitialized is @false.
1169 This way CGE can fallback to use FPImage to load PNG. }
1170 if not CheckVersion then
1171 FreeAndNil(PngLibrary);
1172 end;
1173 end;
1174
1175 initialization
1176 {$ifdef ALLOW_DLOPEN_FROM_UNIT_INITIALIZATION}
1177 PngInitialization;
1178 {$endif}
1179 finalization
1180 FreeAndNil(PngLibrary);
1181 end.