2 /* Copyright (C) 2002 Olivier Chapuis */
7 /* ---------------------------- included header files ---------------------- */
9 #include "PictureBase.h"
17 /* ---------------------------- global definitions ------------------------- */
19 /* ---------------------------- global macros ------------------------------ */
21 /* ---------------------------- type definitions --------------------------- */
24 typedef unsigned char FzByte
;
25 typedef unsigned int FzuInt
;
26 typedef unsigned long FzuLong
;
27 typedef FzByte FzBytef
;
29 typedef void *Fzvoidpf
;
30 typedef void *Fzvoidp
;
32 typedef FzByte
*Fzvoidpf
;
33 typedef FzByte
*Fzvoidp
;
35 typedef Fzvoidpf (*Fzalloc_func
) (
37 Fzvoidpf opaque
, FzuInt items
, FzuInt size
40 typedef Fzvoidp (*Fzfree_func
) (
42 Fzvoidpf opaque
, Fzvoidpf address
45 typedef struct Fz_stream_s
{
53 struct internal_state
*state
;
61 typedef Fz_stream
*Fz_streamp
;
64 typedef z_Byte FzByte
;
65 typedef z_uInt FzuInt
;
66 typedef z_uLong FzuLong
;
67 typedef z_Bytef FzBytef
;
68 typedef z_voidp Fzvoidp
;
69 typedef z_voidpf Fzvoidpf
;
70 typedef z_stream Fz_stream
;
74 typedef uLong FzuLong
;
75 typedef Bytef FzBytef
;
76 typedef voidp Fzvoidp
;
77 typedef voidpf Fzvoidpf
;
78 typedef z_stream Fz_stream
;
83 typedef png_uint_32 Fpng_uint_32
;
84 typedef png_int_32 Fpng_int_32
;
85 typedef png_uint_16 Fpng_uint_16
;
86 typedef png_int_16 Fpng_int_16
;
87 typedef png_byte Fpng_byte
;
88 typedef png_size_t Fpng_size_t
;
90 typedef png_struct Fpng_struct
;
91 typedef png_structp Fpng_structp
;
92 typedef png_structpp Fpng_structpp
;
93 typedef png_info Fpng_info
;
94 typedef png_infop Fpng_infop
;
95 typedef png_infopp Fpng_infopp
;
97 typedef unsigned long Fpng_uint_32
;
98 typedef long Fpng_int_32
;
99 typedef unsigned short Fpng_uint_16
;
100 typedef short Fpng_int_16
;
101 typedef unsigned char Fpng_byte
;
102 typedef size_t Fpng_size_t
;
103 typedef void *Fpng_voidp
;
104 typedef Fpng_byte
*Fpng_bytep
;
105 typedef Fpng_uint_32
*Fpng_uint_32p
;
106 typedef Fpng_int_32
*Fpng_int_32p
;
107 typedef Fpng_uint_16
*Fpng_uint_16p
;
108 typedef Fpng_int_16
*Fpng_int_16p
;
109 typedef const char *Fpng_const_charp
;
110 typedef char *Fpng_charp
;
111 typedef double *Fpng_doublep
;
112 typedef Fpng_byte
**Fpng_bytepp
;
113 typedef Fpng_uint_32
**Fpng_uint_32pp
;
114 typedef Fpng_int_32
**Fpng_int_32pp
;
115 typedef Fpng_uint_16
**Fpng_uint_16pp
;
116 typedef Fpng_int_16
**Fpng_int_16pp
;
117 typedef const char **Fpng_const_charpp
;
118 typedef char **Fpng_charpp
;
119 typedef double **Fpng_doublepp
;
120 typedef char ** *Fpng_charppp
;
121 typedef struct Fpng_color_struct
127 typedef Fpng_color
*Fpng_colorp
;
128 typedef Fpng_color
**Fpng_colorpp
;
129 typedef struct Fpng_color_16_struct
137 typedef Fpng_color_16
*Fpng_color_16p
;
138 typedef Fpng_color_16
**Fpng_color_16pp
;
139 typedef struct Fpng_color_8_struct
147 typedef Fpng_color_8
*Fpng_color_8p
;
148 typedef Fpng_color_8
**Fpng_color_8pp
;
149 typedef struct Fpng_text_struct
154 Fpng_size_t text_length
;
156 typedef Fpng_text
*Fpng_textp
;
157 typedef Fpng_text
**Fpng_textpp
;
158 typedef struct Fpng_time_struct
167 typedef Fpng_time
*Fpng_timep
;
168 typedef Fpng_time
**Fpng_timepp
;
169 typedef struct Fpng_info_struct
174 Fpng_uint_32 rowbytes
;
176 Fpng_uint_16 num_palette
;
177 Fpng_uint_16 num_trans
;
179 Fpng_byte color_type
;
180 Fpng_byte compression_type
;
181 Fpng_byte filter_type
;
182 Fpng_byte interlace_type
;
184 Fpng_byte pixel_depth
;
185 Fpng_byte spare_byte
;
186 Fpng_byte signature
[8];
188 Fpng_byte srgb_intent
;
193 Fpng_color_8 sig_bit
;
195 Fpng_color_16 trans_values
;
196 Fpng_color_16 background
;
197 Fpng_uint_32 x_offset
;
198 Fpng_uint_32 y_offset
;
199 Fpng_byte offset_unit_type
;
200 Fpng_uint_32 x_pixels_per_unit
;
201 Fpng_uint_32 y_pixels_per_unit
;
202 Fpng_byte phys_unit_type
;
212 Fpng_charp pcal_purpose
;
215 Fpng_charp pcal_units
;
216 Fpng_charpp pcal_params
;
218 Fpng_byte pcal_nparams
;
220 typedef Fpng_info
*Fpng_infop
;
221 typedef Fpng_info
**Fpng_infopp
;
222 typedef struct Fpng_struct_def Fpng_struct
;
223 typedef Fpng_struct
*Fpng_structp
;
224 typedef struct Fpng_row_info_struct
227 Fpng_uint_32 rowbytes
;
228 Fpng_byte color_type
;
231 Fpng_byte pixel_depth
;
233 typedef Fpng_row_info
*Fpng_row_infop
;
234 typedef Fpng_row_info
**Fpng_row_infopp
;
235 typedef void (*Fpng_error_ptr
)(
237 Fpng_structp
, Fpng_const_charp
240 typedef void (*Fpng_rw_ptr
)(
242 Fpng_structp
, Fpng_bytep
, Fpng_size_t
245 typedef void (*Fpng_flush_ptr
) (
250 typedef void (*Fpng_read_status_ptr
) (
252 Fpng_structp
, Fpng_uint_32
, int
255 typedef void (*Fpng_write_status_ptr
) (
257 Fpng_structp
, Fpng_uint_32
, int
260 typedef void (*Fpng_progressive_info_ptr
) (
262 Fpng_structp
, Fpng_infop
265 typedef void (*Fpng_progressive_end_ptr
) (
267 Fpng_structp
, Fpng_infop
270 typedef void (*Fpng_progressive_row_ptr
) (
272 Fpng_structp
, Fpng_bytep
,Fpng_uint_32
, int
275 typedef void (*Fpng_user_transform_ptr
)(
277 Fpng_structp
, Fpng_row_infop
, Fpng_bytep
280 typedef Fpng_voidp (*Fpng_malloc_ptr
) (
282 Fpng_structp
, Fpng_size_t
285 typedef void (*Fpng_free_ptr
) (
287 Fpng_structp
, Fpng_voidp
290 struct png_struct_def
293 Fpng_error_ptr error_fn
;
294 Fpng_error_ptr warning_fn
;
295 Fpng_voidp error_ptr
;
296 Fpng_rw_ptr write_data_fn
;
297 Fpng_rw_ptr read_data_fn
;
299 Fpng_user_transform_ptr read_user_transform_fn
;
300 Fpng_user_transform_ptr write_user_transform_fn
;
301 Fpng_voidp user_transform_ptr
;
302 Fpng_byte user_transform_depth
;
303 Fpng_byte user_transform_channels
;
306 Fpng_uint_32 transformations
;
309 Fpng_size_t zbuf_size
;
312 int zlib_window_bits
;
317 Fpng_uint_32 num_rows
;
318 Fpng_uint_32 usr_width
;
319 Fpng_uint_32 rowbytes
;
320 Fpng_uint_32 irowbytes
;
322 Fpng_uint_32 row_number
;
328 Fpng_bytep paeth_row
;
329 Fpng_row_info row_info
;
330 Fpng_uint_32 idat_size
;
333 Fpng_uint_16 num_palette
;
334 Fpng_uint_16 num_trans
;
335 Fpng_byte chunk_name
[5];
336 Fpng_byte compression
;
338 Fpng_byte interlaced
;
341 Fpng_byte color_type
;
343 Fpng_byte usr_bit_depth
;
344 Fpng_byte pixel_depth
;
346 Fpng_byte usr_channels
;
349 Fpng_byte background_gamma_type
;
350 float background_gamma
;
351 Fpng_color_16 background
;
352 Fpng_color_16 background_1
;
353 Fpng_flush_ptr output_flush_fn
;
354 Fpng_uint_32 flush_dist
;
355 Fpng_uint_32 flush_rows
;
359 Fpng_bytep gamma_table
;
360 Fpng_bytep gamma_from_1
;
361 Fpng_bytep gamma_to_1
;
362 Fpng_uint_16pp gamma_16_table
;
363 Fpng_uint_16pp gamma_16_from_1
;
364 Fpng_uint_16pp gamma_16_to_1
;
365 Fpng_color_8 sig_bit
;
368 Fpng_color_16 trans_values
;
369 Fpng_read_status_ptr read_row_fn
;
370 Fpng_write_status_ptr write_row_fn
;
371 Fpng_progressive_info_ptr info_fn
;
372 Fpng_progressive_row_ptr row_fn
;
373 Fpng_progressive_end_ptr end_fn
;
374 Fpng_bytep save_buffer_ptr
;
375 Fpng_bytep save_buffer
;
376 Fpng_bytep current_buffer_ptr
;
377 Fpng_bytep current_buffer
;
378 Fpng_uint_32 push_length
;
379 Fpng_uint_32 skip_length
;
380 Fpng_size_t save_buffer_size
;
381 Fpng_size_t save_buffer_max
;
382 Fpng_size_t buffer_size
;
383 Fpng_size_t current_buffer_size
;
386 Fpng_size_t current_text_size
;
387 Fpng_size_t current_text_left
;
388 Fpng_charp current_text
;
389 Fpng_charp current_text_ptr
;
390 Fpng_bytepp offset_table_ptr
;
391 Fpng_bytep offset_table
;
392 Fpng_uint_16 offset_table_number
;
393 Fpng_uint_16 offset_table_count
;
394 Fpng_uint_16 offset_table_count_free
;
395 Fpng_bytep palette_lookup
;
396 Fpng_bytep dither_index
;
398 Fpng_byte heuristic_method
;
399 Fpng_byte num_prev_filters
;
400 Fpng_bytep prev_filters
;
401 Fpng_uint_16p filter_weights
;
402 Fpng_uint_16p inv_filter_weights
;
403 Fpng_uint_16p filter_costs
;
404 Fpng_uint_16p inv_filter_costs
;
405 Fpng_charp time_buffer
;
407 Fpng_malloc_ptr malloc_fn
;
408 Fpng_free_ptr free_fn
;
409 Fpng_byte rgb_to_gray_status
;
410 Fpng_byte rgb_to_gray_red_coeff
;
411 Fpng_byte rgb_to_gray_green_coeff
;
412 Fpng_byte rgb_to_gray_blue_coeff
;
413 Fpng_byte empty_plte_permitted
;
415 typedef Fpng_struct
**Fpng_structpp
;
417 /* ---------------------------- global definitions ------------------------- */
419 #define FPNG_BYTES_TO_CHECK 4
423 #define FPNG_LIBPNG_VER_STRING PNG_LIBPNG_VER_STRING
424 #define FPNG_COLOR_TYPE_PALETTE PNG_COLOR_TYPE_PALETTE
425 #define FPNG_COLOR_TYPE_RGB_ALPHA PNG_COLOR_TYPE_RGB_ALPHA
426 #define FPNG_COLOR_TYPE_GRAY_ALPHA PNG_COLOR_TYPE_GRAY_ALPHA
427 #define FPNG_COLOR_TYPE_GRAY PNG_COLOR_TYPE_GRAY
428 #define FPNG_FILLER_BEFORE PNG_FILLER_BEFORE
429 #define FPNG_FILLER_AFTER PNG_FILLER_AFTER
430 #define FPNG_INFO_tRNS PNG_INFO_tRNS
432 #define Fpng_check_sig(a,b) png_check_sig(a,b)
433 #define Fpng_create_read_struct(a,b,c,d) png_create_read_struct(a,b,c,d)
434 #define Fpng_create_info_struct(a) png_create_info_struct(a)
435 #define Fpng_destroy_read_struct(a,b,c) png_destroy_read_struct(a,b,c)
436 #define Fpng_init_io(a,b) png_init_io(a,b)
437 #define Fpng_read_info(a,b) png_read_info(a,b)
438 #define Fpng_get_IHDR(a,b,c,d,e,f,g,h,i) png_get_IHDR(a,b,c,d,e,f,g,h,i)
439 #define Fpng_set_expand(a) png_set_expand(a)
440 #define Fpng_set_swap_alpha(a) png_set_swap_alpha(a)
441 #define Fpng_set_filler(a,b,c) png_set_filler(a,b,c)
442 #define Fpng_set_bgr(a) png_set_bgr(a)
443 #define Fpng_set_strip_16(a) png_set_strip_16(a)
444 #define Fpng_set_packing(a) png_set_packing(a)
445 #define Fpng_set_gray_to_rgb(a) png_set_gray_to_rgb(a)
446 #define Fpng_get_bit_depth(a,b) png_get_bit_depth(a,b)
447 #define Fpng_set_gray_1_2_4_to_8(a) png_set_gray_1_2_4_to_8(a)
448 #define Fpng_get_valid(a,b,c) png_get_valid(a,b,c)
449 #define Fpng_read_end(a,b) png_read_end(a,b)
450 #define Fpng_set_interlace_handling(a) png_set_interlace_handling(a)
451 #define Fpng_read_rows(a,b,c,d) png_read_rows(a,b,c,d)
452 #define Fpng_read_image(a,b) png_read_image(a,b)
456 #define FPNG_LIBPNG_VER_STRING ""
457 #define FPNG_COLOR_TYPE_PALETTE 0
458 #define FPNG_COLOR_TYPE_RGB_ALPHA 1
459 #define FPNG_COLOR_TYPE_GRAY_ALPHA 2
460 #define FPNG_COLOR_TYPE_GRAY 3
461 #define FPNG_FILLER_BEFORE 6
462 #define FPNG_FILLER_AFTER 5
463 #define FPNG_INFO_tRNS 7
465 #define Fpng_check_sig(a,b) 0
466 #define Fpng_create_read_struct(a,b,c,d) NULL
467 #define Fpng_create_info_struct(a) NULL
468 #define Fpng_destroy_read_struct(a,b,c)
469 #define Fpng_init_io(a,b)
470 #define Fpng_read_info(a,b)
471 #define Fpng_get_IHDR(a,b,c,d,e,f,g,h,i)
472 #define Fpng_set_expand(a)
473 #define Fpng_set_swap_alpha(a)
474 #define Fpng_set_filler(a,b,c)
475 #define Fpng_set_bgr(a)
476 #define Fpng_set_strip_16(a)
477 #define Fpng_set_packing(a)
478 #define Fpng_set_gray_to_rgb(a)
479 #define Fpng_get_bit_depth(a,b) 0
480 #define Fpng_set_gray_1_2_4_to_8(a)
481 #define Fpng_get_valid(a,b,c) 0
482 #define Fpng_read_end(a,b)
483 #define Fpng_set_interlace_handling(a) 0
484 #define Fpng_read_rows(a,b,c,d)
485 #define Fpng_read_image(a,b)