D Paste by sergk
Description: libpng/api.d
Hide line numbers

Create new paste
Post a reply
View replies

Paste:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
259  
260  
261  
262  
263  
264  
265  
266  
267  
268  
269  
270  
271  
272  
273  
274  
275  
276  
277  
278  
279  
280  
281  
282  
283  
284  
285  
286  
287  
288  
289  
290  
291  
292  
293  
294  
295  
296  
297  
298  
299  
300  
301  
302  
303  
304  
305  
306  
307  
308  
309  
310  
311  
312  
313  
314  
315  
316  
317  
318  
319  
320  
321  
322  
323  
324  
325  
326  
327  
328  
329  
330  
331  
332  
333  
334  
335  
336  
337  
338  
339  
340  
341  
342  
343  
344  
345  
346  
347  
348  
349  
350  
351  
352  
353  
354  
355  
356  
357  
358  
359  
360  
361  
362  
363  
364  
365  
366  
367  
368  
369  
370  
371  
372  
373  
374  
375  
376  
377  
378  
379  
380  
381  
382  
383  
384  
385  
386  
387  
388  
389  
390  
391  
392  
393  
394  
395  
396  
import zlib;
import std.c.stdio;
import std.c.time;

const PNG_LIBPNG_VER_STRING = "1.2.16";

alias ulong png_uint_32;
alias long png_int_32;
alias ushort png_uint_16;
alias short png_int_16;
alias ubyte png_byte;
alias png_int_32 png_fixed_point;
alias void* png_voidp;
alias png_byte* png_bytep;
alias png_uint_32* png_uint_32p;
alias png_int_32* png_int_32p;
alias png_uint_16* png_uint_16p;
alias png_int_16* png_int_16p;
alias char* png_const_charp;
alias char* png_charp;
alias png_fixed_point* png_fixed_point_p;
alias FILE* png_FILE_p;
alias double* png_doublep;
alias png_byte** png_bytepp;
alias png_uint_32** png_uint_32pp;
alias png_int_32** png_int_32pp;
alias png_uint_16** png_uint_16pp;
alias png_int_16** png_int_16pp;
alias char** png_const_charpp;
alias char** png_charpp;
alias png_fixed_point** png_fixed_point_pp;
alias double** png_doublepp;
alias char*** png_charppp;
alias charf* png_zcharp;
alias charf** png_zcharpp;
alias z_stream* png_zstreamp;
alias size_t png_size_t;

extern (C)
{
    alias void  function(png_structp, png_const_charp)
        png_error_ptr;
    alias void  function(png_structp, png_bytep, png_size_t)
        png_rw_ptr;
    alias void  function(png_structp, png_row_infop, png_bytep)
        png_user_transform_ptr;
    alias void  function(png_structp)
        png_flush_ptr;
    alias void  function(png_structp, png_uint_32, int)
        png_read_status_ptr;
    alias void  function(png_structp, png_uint_32, int)
        png_write_status_ptr;
    alias void  function(png_structp, png_infop)
        png_progressive_info_ptr;
    alias void  function(png_structp, png_bytep, png_uint_32, int)
        png_progressive_row_ptr;
    alias void  function(png_structp, png_infop)
        png_progressive_end_ptr;
    alias int  function(png_structp, png_unknown_chunkp)
        png_user_chunk_ptr;
    alias png_voidp  function(png_structp, png_size_t)
        png_malloc_ptr;
    alias void  function(png_structp, png_voidp)
        png_free_ptr;

    version (X86)
        alias int[16] jmp_buf;

    alias  png_structp version_1_2_16;
    alias  png_struct* png_structp;
    alias  png_struct** png_structpp;
    struct png_struct
    {
        jmp_buf jmpbuf;
        png_error_ptr error_fn;
        png_error_ptr warning_fn;
        png_voidp error_ptr;
        png_rw_ptr write_data_fn;
        png_rw_ptr read_data_fn;
        png_voidp io_ptr;
        png_user_transform_ptr read_user_transform_fn;
        png_user_transform_ptr write_user_transform_fn;
        png_voidp user_transform_ptr;
        png_byte user_transform_depth;
        png_byte user_transform_channels;
        png_uint_32 mode;
        png_uint_32 flags;
        png_uint_32 transformations;
        z_stream zstream;
        png_bytep zbuf;
        png_size_t zbuf_size;
        int zlib_level;
        int zlib_method;
        int zlib_window_bits;
        int zlib_mem_level;
        int zlib_strategy;
        png_uint_32 width;
        png_uint_32 height;
        png_uint_32 num_rows;
        png_uint_32 usr_width;
        png_uint_32 rowbytes;
        png_uint_32 irowbytes;
        png_uint_32 iwidth;
        png_uint_32 row_number;
        png_bytep prev_row;
        png_bytep row_buf;
        png_bytep sub_row;
        png_bytep up_row;
        png_bytep avg_row;
        png_bytep paeth_row;
        png_row_info row_info;
        png_uint_32 idat_size;
        png_uint_32 crc;
        png_colorp palette;
        png_uint_16 num_palette;
        png_uint_16 num_trans;
        png_byte [5]chunk_name;
        png_byte compression;
        png_byte filter;
        png_byte interlaced;
        png_byte pass;
        png_byte do_filter;
        png_byte color_type;
        png_byte bit_depth;
        png_byte usr_bit_depth;
        png_byte pixel_depth;
        png_byte channels;
        png_byte usr_channels;
        png_byte sig_bytes;
        png_uint_16 filler;
        png_byte background_gamma_type;
        float background_gamma;
        png_color_16 background;
        png_color_16 background_1;
        png_flush_ptr output_flush_fn;
        png_uint_32 flush_dist;
        png_uint_32 flush_rows;
        int gamma_shift;
        float gamma;
        float screen_gamma;
        png_bytep gamma_table;
        png_bytep gamma_from_1;
        png_bytep gamma_to_1;
        png_uint_16pp gamma_16_table;
        png_uint_16pp gamma_16_from_1;
        png_uint_16pp gamma_16_to_1;
        png_color_8 sig_bit;
        png_color_8 shift;
        png_bytep trans;
        png_color_16 trans_values;
        png_read_status_ptr read_row_fn;
        png_write_status_ptr write_row_fn;
        png_progressive_info_ptr info_fn;
        png_progressive_row_ptr row_fn;
        png_progressive_end_ptr end_fn;
        png_bytep save_buffer_ptr;
        png_bytep save_buffer;
        png_bytep current_buffer_ptr;
        png_bytep current_buffer;
        png_uint_32 push_length;
        png_uint_32 skip_length;
        png_size_t save_buffer_size;
        png_size_t save_buffer_max;
        png_size_t buffer_size;
        png_size_t current_buffer_size;
        int process_mode;
        int cur_palette;
        png_size_t current_text_size;
        png_size_t current_text_left;
        png_charp current_text;
        png_charp current_text_ptr;
        png_bytep palette_lookup;
        png_bytep dither_index;
        png_uint_16p hist;
        png_byte heuristic_method;
        png_byte num_prev_filters;
        png_bytep prev_filters;
        png_uint_16p filter_weights;
        png_uint_16p inv_filter_weights;
        png_uint_16p filter_costs;
        png_uint_16p inv_filter_costs;
        png_charp time_buffer;
        png_uint_32 free_me;
        png_voidp user_chunk_ptr;
        png_user_chunk_ptr read_user_chunk_fn;
        int num_chunk_list;
        png_bytep chunk_list;
        png_byte rgb_to_gray_status;
        png_uint_16 rgb_to_gray_red_coeff;
        png_uint_16 rgb_to_gray_green_coeff;
        png_uint_16 rgb_to_gray_blue_coeff;
        png_uint_32 mng_features_permitted;
        png_fixed_point int_gamma;
        png_byte filter_type;
        png_uint_32 asm_flags;
        png_voidp mem_ptr;
        png_malloc_ptr malloc_fn;
        png_free_ptr free_fn;
        png_bytep big_row_buf;
        png_bytep dither_sort;
        png_bytep index_to_palette;
        png_bytep palette_to_index;
        png_byte compression_type;
        png_uint_32 user_width_max;
        png_uint_32 user_height_max;
    }

    alias  png_row_info* png_row_infop;
    alias  png_row_info** png_row_infopp;
    struct png_row_info
    {
        png_uint_32 width;
        png_uint_32 rowbytes;
        png_byte color_type;
        png_byte bit_depth;
        png_byte channels;
        png_byte pixel_depth;
    }

    alias  png_color* png_colorp;
    alias  png_color** png_colorpp;
    struct png_color
    {
        png_byte red;
        png_byte green;
        png_byte blue;
    }

    alias  png_color_16* png_color_16p;
    alias  png_color_16** png_color_16pp;
    struct png_color_16
    {
        png_byte index;
        png_uint_16 red;
        png_uint_16 green;
        png_uint_16 blue;
        png_uint_16 gray;
    }

    alias  png_color_8* png_color_8p;
    alias  png_color_8** png_color_8pp;
    struct png_color_8
    {
        png_byte red;
        png_byte green;
        png_byte blue;
        png_byte gray;
        png_byte alpha;
    }

    alias  png_info* png_infop;
    alias  png_info** png_infopp;
    struct png_info
    {
        png_uint_32 width;
        png_uint_32 height;
        png_uint_32 valid;
        png_uint_32 rowbytes;
        png_colorp palette;
        png_uint_16 num_palette;
        png_uint_16 num_trans;
        png_byte bit_depth;
        png_byte color_type;
        png_byte compression_type;
        png_byte filter_type;
        png_byte interlace_type;
        png_byte channels;
        png_byte pixel_depth;
        png_byte spare_byte;
        png_byte [8]signature;
        float gamma;
        png_byte srgb_intent;
        int num_text;
        int max_text;
        png_textp text;
        png_time mod_time;
        png_color_8 sig_bit;
        png_bytep trans;
        png_color_16 trans_values;
        png_color_16 background;
        png_int_32 x_offset;
        png_int_32 y_offset;
        png_byte offset_unit_type;
        png_uint_32 x_pixels_per_unit;
        png_uint_32 y_pixels_per_unit;
        png_byte phys_unit_type;
        png_uint_16p hist;
        float x_white;
        float y_white;
        float x_red;
        float y_red;
        float x_green;
        float y_green;
        float x_blue;
        float y_blue;
        png_charp pcal_purpose;
        png_int_32 pcal_X0;
        png_int_32 pcal_X1;
        png_charp pcal_units;
        png_charpp pcal_params;
        png_byte pcal_type;
        png_byte pcal_nparams;
        png_uint_32 free_me;
        png_unknown_chunkp unknown_chunks;
        png_size_t unknown_chunks_num;
        png_charp iccp_name;
        png_charp iccp_profile;
        png_uint_32 iccp_proflen;
        png_byte iccp_compression;
        png_sPLT_tp splt_palettes;
        png_uint_32 splt_palettes_num;
        png_byte scal_unit;
        double scal_pixel_width;
        double scal_pixel_height;
        png_charp scal_s_width;
        png_charp scal_s_height;
        png_bytepp row_pointers;
        png_fixed_point int_gamma;
        png_fixed_point int_x_white;
        png_fixed_point int_y_white;
        png_fixed_point int_x_red;
        png_fixed_point int_y_red;
        png_fixed_point int_x_green;
        png_fixed_point int_y_green;
        png_fixed_point int_x_blue;
        png_fixed_point int_y_blue;
    }

    alias  png_unknown_chunk* png_unknown_chunkp;
    alias  png_unknown_chunk** png_unknown_chunkpp;
    struct png_unknown_chunk
    {
        png_byte[5] name;
        png_byte* data;
        png_size_t size;
        png_byte location;
    }

    alias  png_text *png_textp;
    alias  png_text **png_textpp;
    struct png_text
    {
        int compression;
        png_charp key;
        png_charp text;
        png_size_t text_length;
    }

    alias  png_time* png_timep;
    alias  png_time** png_timepp;
    struct png_time
    {
        png_uint_16 year;
        png_byte month;
        png_byte day;
        png_byte hour;
        png_byte minute;
        png_byte second;
    }

    alias  png_sPLT_t* png_sPLT_tp;
    alias  png_sPLT_t** png_sPLT_tpp;
    struct png_sPLT_t
    {
        png_charp name;
        png_byte depth;
        png_sPLT_entryp entries;
        png_int_32 nentries;
    }

    alias  png_sPLT_entry* png_sPLT_entryp;
    alias  png_sPLT_entry** png_sPLT_entrypp;
    struct png_sPLT_entry
    {
        png_uint_16 red;
        png_uint_16 green;
        png_uint_16 blue;
        png_uint_16 alpha;
        png_uint_16 frequency;
    }

    png_infop  png_create_info_struct(png_structp png_ptr);
    png_structp  png_create_read_struct(png_const_charp user_png_ver,
            png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn);
    void  png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn);
    void  png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
            png_error_ptr error_fn, png_error_ptr warning_fn);
    void  png_read_info(png_structp png_ptr, png_infop info_ptr);
    png_uint_32  png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
            png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type,
            int *interlace_method, int *compression_method, int *filter_method);
    png_uint_32  png_get_image_width(png_structp png_ptr, png_infop info_ptr);
    void  png_destroy_read_struct(png_structpp png_ptr_ptr,
            png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr);
    png_voidp  png_get_io_ptr(png_structp png_ptr);
}

Replies:
No replies posted yet