]> git.imager.perl.org - imager.git/blob - imexttypes.h
split Imager's typemap into internal, public and old perl bugfixes
[imager.git] / imexttypes.h
1 #ifndef IMAGER_IMEXTTYPES_H_
2 #define IMAGER_IMEXTTYPES_H_
3
4 /* keep this file simple - apidocs.perl parses it. */
5
6 #include "imdatatypes.h"
7 #include <stdarg.h>
8
9 /*
10  IMAGER_API_VERSION is similar to the version number in the third and
11  fourth bytes of TIFF files - if it ever changes then the API has changed
12  too much for any application to remain compatible.
13
14  Version 2 changed the types of some parameters and pointers.  A
15  simple recompile should be enough in most cases.
16
17  Version 3 changed the behaviour of some of the I/O layer functions,
18  and in some cases the initial seek position when calling file
19  readers.  Switching away from calling readcb etc to i_io_read() etc
20  should fix your code.
21
22  Version 4 added i_psamp() and i_psampf() pointers to the i_img
23  structure.
24
25 */
26 #define IMAGER_API_VERSION 4
27
28 /*
29  IMAGER_API_LEVEL is the level of the structure.  New function pointers
30  will always remain at the end (unless IMAGER_API_VERSION changes), and
31  will result in an increment of IMAGER_API_LEVEL.
32 */
33
34 #define IMAGER_API_LEVEL 7
35
36 typedef struct {
37   int version;
38   int level;
39
40   /* IMAGER_API_LEVEL 1 functions */
41   void * (*f_mymalloc)(size_t size);
42   void (*f_myfree)(void *block);
43   void * (*f_myrealloc)(void *block, size_t newsize);
44   void* (*f_mymalloc_file_line)(size_t size, char* file, int line);
45   void  (*f_myfree_file_line)(void *p, char*file, int line);
46   void* (*f_myrealloc_file_line)(void *p, size_t newsize, char* file,int line);
47
48   i_img *(*f_i_img_8_new)(i_img_dim xsize, i_img_dim ysize, int channels);
49   i_img *(*f_i_img_16_new)(i_img_dim xsize, i_img_dim ysize, int channels);
50   i_img *(*f_i_img_double_new)(i_img_dim xsize, i_img_dim ysize, int channels);
51   i_img *(*f_i_img_pal_new)(i_img_dim xsize, i_img_dim ysize, int channels, int maxpal);
52   void (*f_i_img_destroy)(i_img *im);
53   i_img *(*f_i_sametype)(i_img *im, i_img_dim xsize, i_img_dim ysize);
54   i_img *(*f_i_sametype_chans)(i_img *im, i_img_dim xsize, i_img_dim ysize, int channels);
55   void (*f_i_img_info)(i_img *im, i_img_dim *info);
56
57   int (*f_i_ppix)(i_img *im, i_img_dim x, i_img_dim y, const i_color *val);
58   int (*f_i_gpix)(i_img *im, i_img_dim x, i_img_dim y, i_color *val);
59   int (*f_i_ppixf)(i_img *im, i_img_dim x, i_img_dim y, const i_fcolor *val);
60   int (*f_i_gpixf)(i_img *im, i_img_dim x, i_img_dim y, i_fcolor *val);
61   i_img_dim (*f_i_plin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_color *vals);
62   i_img_dim (*f_i_glin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_color *vals);
63   i_img_dim (*f_i_plinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_fcolor *vals);
64   i_img_dim (*f_i_glinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fcolor *vals);
65   i_img_dim (*f_i_gsamp)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_sample_t *samp, 
66                    const int *chans, int chan_count);
67   i_img_dim (*f_i_gsampf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samp, 
68                    const int *chans, int chan_count);
69   i_img_dim (*f_i_gpal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, i_palidx *vals);
70   i_img_dim (*f_i_ppal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, const i_palidx *vals);
71   int (*f_i_addcolors)(i_img *im, const i_color *colors, int count);
72   int (*f_i_getcolors)(i_img *im, int i, i_color *, int count);
73   int (*f_i_colorcount)(i_img *im);
74   int (*f_i_maxcolors)(i_img *im);
75   int (*f_i_findcolor)(i_img *im, const i_color *color, i_palidx *entry);
76   int (*f_i_setcolors)(i_img *im, int index, const i_color *colors, 
77                        int count);
78
79   i_fill_t *(*f_i_new_fill_solid)(const i_color *c, int combine);
80   i_fill_t *(*f_i_new_fill_solidf)(const i_fcolor *c, int combine);
81
82   i_fill_t *(*f_i_new_fill_hatch)(const i_color *fg, const i_color *bg, int combine, 
83                                   int hatch, const unsigned char *cust_hatch, 
84                                   i_img_dim dx, i_img_dim dy);
85   i_fill_t *(*f_i_new_fill_hatchf)(const i_fcolor *fg, const i_fcolor *bg, int combine, 
86                                   int hatch, const unsigned char *cust_hatch, 
87                                   i_img_dim dx, i_img_dim dy);
88   i_fill_t *(*f_i_new_fill_image)(i_img *im, const double *matrix, i_img_dim xoff, 
89                                 i_img_dim yoff, int combine);
90   i_fill_t *(*f_i_new_fill_fount)(double xa, double ya, double xb, double yb, 
91                  i_fountain_type type, i_fountain_repeat repeat, 
92                  int combine, int super_sample, double ssample_param, 
93                  int count, i_fountain_seg *segs);  
94
95   void (*f_i_fill_destroy)(i_fill_t *fill);
96
97   void (*f_i_quant_makemap)(i_quantize *quant, i_img **imgs, int count);
98   i_palidx * (*f_i_quant_translate)(i_quantize *quant, i_img *img);
99   void (*f_i_quant_transparent)(i_quantize *quant, i_palidx *indices, 
100                                 i_img *img, i_palidx trans_index);
101
102   void (*f_i_clear_error)(void);
103   void (*f_i_push_error)(int code, char const *msg);
104   void (*f_i_push_errorf)(int code, char const *fmt, ...);
105   void (*f_i_push_errorvf)(int code, char const *fmt, va_list);
106   
107   void (*f_i_tags_new)(i_img_tags *tags);
108   int (*f_i_tags_set)(i_img_tags *tags, char const *name, char const *data, 
109                       int size);
110   int (*f_i_tags_setn)(i_img_tags *tags, char const *name, int idata);
111   void (*f_i_tags_destroy)(i_img_tags *tags);
112   int (*f_i_tags_find)(i_img_tags *tags, char const *name, int start, 
113                        int *entry);
114   int (*f_i_tags_findn)(i_img_tags *tags, int code, int start, int *entry);
115   int (*f_i_tags_delete)(i_img_tags *tags, int entry);
116   int (*f_i_tags_delbyname)(i_img_tags *tags, char const *name);
117   int (*f_i_tags_delbycode)(i_img_tags *tags, int code);
118   int (*f_i_tags_get_float)(i_img_tags *tags, char const *name, int code, 
119                             double *value);
120   int (*f_i_tags_set_float)(i_img_tags *tags, char const *name, int code, 
121                             double value);
122   int (*f_i_tags_set_float2)(i_img_tags *tags, char const *name, int code,
123                              double value, int places);
124   int (*f_i_tags_get_int)(i_img_tags *tags, char const *name, int code, 
125                           int *value);
126   int (*f_i_tags_get_string)(i_img_tags *tags, char const *name, int code,
127                              char *value, size_t value_size);
128   int (*f_i_tags_get_color)(i_img_tags *tags, char const *name, int code,
129                             i_color *value);
130   int (*f_i_tags_set_color)(i_img_tags *tags, char const *name, int code,
131                             i_color const *value);
132
133   void (*f_i_box)(i_img *im, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, const i_color *val);
134   void (*f_i_box_filled)(i_img *im, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, const i_color *val);
135   void (*f_i_box_cfill)(i_img *im, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, i_fill_t *fill);
136   void (*f_i_line)(i_img *im, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, const i_color *val, int endp);
137   void (*f_i_line_aa)(i_img *im, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, const i_color *val, int endp);
138   void (*f_i_arc)(i_img *im, i_img_dim x, i_img_dim y, double rad, double d1, double d2, const i_color *val);
139   void (*f_i_arc_aa)(i_img *im, double x, double y, double rad, double d1, double d2, const i_color *val);
140   void (*f_i_arc_cfill)(i_img *im, i_img_dim x, i_img_dim y, double rad, double d1, double d2, i_fill_t *val);
141   void (*f_i_arc_aa_cfill)(i_img *im, double x, double y, double rad, double d1, double d2, i_fill_t *fill);
142   void (*f_i_circle_aa)(i_img *im, double x, double y, double rad, const i_color *val);
143   int (*f_i_flood_fill)(i_img *im, i_img_dim seedx, i_img_dim seedy, const i_color *dcol);
144   int (*f_i_flood_cfill)(i_img *im, i_img_dim seedx, i_img_dim seedy, i_fill_t *fill);
145
146   void (*f_i_copyto)(i_img *im, i_img *src, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, i_img_dim tx, i_img_dim ty);
147   void (*f_i_copyto_trans)(i_img *im, i_img *src, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, i_img_dim tx, i_img_dim ty, const i_color *trans);
148   i_img *(*f_i_copy)(i_img *im);
149   int (*f_i_rubthru)(i_img *im, i_img *src, i_img_dim tx, i_img_dim ty, i_img_dim src_minx, i_img_dim src_miny, i_img_dim src_maxx, i_img_dim src_maxy);
150
151   /* IMAGER_API_LEVEL 2 functions */
152   int (*f_i_set_image_file_limits)(i_img_dim width, i_img_dim height, size_t bytes);
153   int (*f_i_get_image_file_limits)(i_img_dim *width, i_img_dim *height, size_t *bytes);
154   int (*f_i_int_check_image_file_limits)(i_img_dim width, i_img_dim height, int channels, size_t sample_size);
155   int (*f_i_flood_fill_border)(i_img *im, i_img_dim seedx, i_img_dim seedy, const i_color *dcol, const i_color *border);
156   int (*f_i_flood_cfill_border)(i_img *im, i_img_dim seedx, i_img_dim seedy, i_fill_t *fill, const i_color *border);
157
158   /* IMAGER_API_LEVEL 3 functions */
159   void (*f_i_img_setmask)(i_img *im, int ch_mask);
160   int (*f_i_img_getmask)(i_img *im);
161   int (*f_i_img_getchannels)(i_img *im);
162   i_img_dim (*f_i_img_get_width)(i_img *im);
163   i_img_dim (*f_i_img_get_height)(i_img *im);
164   void (*f_i_lhead)(const char *file, int line_number);
165   void (*f_i_loog)(int level, const char *msg, ...);
166
167   /* IMAGER_API_LEVEL 4 functions will be added here */
168   i_img *(*f_i_img_alloc)(void);
169   void (*f_i_img_init)(i_img *);
170
171   /* IMAGER_API_LEVEL 5 functions will be added here */
172   /* added i_psampf?_bits macros */
173   int (*f_i_img_is_monochrome)(i_img *, int *zero_is_white);
174   int (*f_i_gsamp_bg)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_sample_t *samples,
175                       int out_channels, i_color const * bg);
176   int (*f_i_gsampf_bg)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samples,
177                       int out_channels, i_fcolor const * bg);
178   void (*f_i_get_file_background)(i_img *im, i_color *bg);
179   void (*f_i_get_file_backgroundf)(i_img *im, i_fcolor *bg);
180   unsigned long (*f_i_utf8_advance)(char const **p, size_t *len);
181   i_render *(*f_i_render_new)(i_img *im, i_img_dim width);
182   void (*f_i_render_delete)(i_render *r);
183   void (*f_i_render_color)(i_render *r, i_img_dim x, i_img_dim y,
184                            i_img_dim width, unsigned char const *src,
185                            i_color const *color);
186   void (*f_i_render_fill)(i_render *r, i_img_dim x, i_img_dim y,
187                           i_img_dim width, unsigned char const *src,
188                           i_fill_t *fill);
189   void (*f_i_render_line)(i_render *r, i_img_dim x, i_img_dim y,
190                           i_img_dim width, const i_sample_t *src,
191                           i_color *line, i_fill_combine_f combine);
192   void (*f_i_render_linef)(i_render *r, i_img_dim x, i_img_dim y,
193                           i_img_dim width, const double *src,
194                           i_fcolor *line, i_fill_combinef_f combine);
195
196   /* Level 6 lost to mis-numbering */
197   /* IMAGER_API_LEVEL 7 */
198   int (*f_i_io_getc_imp)(io_glue *ig);
199   int (*f_i_io_peekc_imp)(io_glue *ig);
200   ssize_t (*f_i_io_peekn)(io_glue *ig, void *buf, size_t size);
201   int (*f_i_io_putc_imp)(io_glue *ig, int c);
202   ssize_t (*f_i_io_read)(io_glue *, void *buf, size_t size);
203   ssize_t (*f_i_io_write)(io_glue *, const void *buf, size_t size);
204   off_t (*f_i_io_seek)(io_glue *, off_t offset, int whence);
205   int (*f_i_io_flush)(io_glue *ig);
206   int (*f_i_io_close)(io_glue *ig);
207   int (*f_i_io_set_buffered)(io_glue *ig, int buffered);
208   ssize_t (*f_i_io_gets)(io_glue *ig, char *, size_t, int);
209
210   i_io_glue_t *(*f_io_new_fd)(int fd);
211   i_io_glue_t *(*f_io_new_bufchain)(void);
212   i_io_glue_t *(*f_io_new_buffer)(const char *data, size_t len, i_io_closebufp_t closecb, void *closedata);
213   i_io_glue_t *(*f_io_new_cb)(void *p, i_io_readl_t readcb, i_io_writel_t writecb, i_io_seekl_t seekcb, i_io_closel_t closecb, i_io_destroyl_t destroycb);
214   size_t (*f_io_slurp)(i_io_glue_t *ig, unsigned char **c);
215   void (*f_io_glue_destroy)(i_io_glue_t *ig);
216
217   /* IMAGER_API_LEVEL 8 functions will be added here */
218   
219 } im_ext_funcs;
220
221 #define PERL_FUNCTION_TABLE_NAME "Imager::__ext_func_table"
222
223 #endif