Debian Codegraph @

imext.h

raw
1 #ifndef IMAGER_IMEXT_H_
2 #define IMAGER_IMEXT_H_
3
4 #include "imexttypes.h"
5 #include "immacros.h"
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 extern im_ext_funcs *imager_function_ext_table;
12
13 #define DEFINE_IMAGER_CALLBACKS im_ext_funcs *imager_function_ext_table
14
15 #ifndef IMAGER_MIN_API_LEVEL
16 #define IMAGER_MIN_API_LEVEL IMAGER_API_LEVEL
17 #endif
18
19 #define PERL_INITIALIZE_IMAGER_CALLBACKS_NAME(name) \
20 do { \
21 imager_function_ext_table = INT2PTR(im_ext_funcs *, SvIV(get_sv(PERL_FUNCTION_TABLE_NAME, 1))); \
22 if (!imager_function_ext_table) \
23 croak("Imager API function table not found!"); \
24 if (imager_function_ext_table->version != IMAGER_API_VERSION) { \
25 croak("Imager API version incorrect loaded %d vs expected %d in %s", \
26 imager_function_ext_table->version, IMAGER_API_VERSION, (name)); \
27 } \
28 if (imager_function_ext_table->level < IMAGER_MIN_API_LEVEL) \
29 croak("API level %d below minimum of %d in %s", imager_function_ext_table->level, IMAGER_MIN_API_LEVEL, (name)); \
30 } while (0)
31
32 #define PERL_INITIALIZE_IMAGER_CALLBACKS PERL_INITIALIZE_IMAGER_CALLBACKS_NAME(__FILE__)
33
34 /* just for use here */
35 #define im_extt imager_function_ext_table
36
37 #define im_get_context() ((im_extt->f_im_get_context)())
38 #define im_context_refinc(ctx, where) ((im_extt->f_im_context_refinc)((ctx), (where)))
39 #define im_context_refdec(ctx, where) ((im_extt->f_im_context_refdec)((ctx), (where)))
40
41 #ifdef IMAGER_DEBUG_MALLOC
42
43 #define mymalloc(size) ((im_extt->f_mymalloc_file_line)((size), __FILE__, __LINE__))
44 #define myrealloc(ptr, size) ((im_extt->f_myrealloc_file_line)((ptr), (size), __FILE__, __LINE__))
45 #define myfree(ptr) ((im_extt->f_myfree_file_line)((ptr), __FILE__, __LINE__))
46
47 #else
48
49 #define mymalloc(size) ((im_extt->f_mymalloc)(size))
50 #define myfree(size) ((im_extt->f_myfree)(size))
51 #define myrealloc(block, newsize) ((im_extt->f_myrealloc)((block), (newsize)))
52
53 #endif
54
55 #define im_img_8_new(ctx, xsize, ysize, channels) ((im_extt->f_im_img_8_new)((ctx), (xsize), (ysize), (channels)))
56 #define im_img_16_new(ctx, xsize, ysize, channels) ((im_extt->f_im_img_16_new)((ctx), (xsize), (ysize), (channels)))
57 #define im_img_double_new(ctx, xsize, ysize, channels) ((im_extt->f_im_img_double_new)((ctx), (xsize), (ysize), (channels)))
58 #define im_img_pal_new(ctx, xsize, ysize, channels, maxpal) ((im_extt->f_im_img_pal_new)((ctx), (xsize), (ysize), (channels), (maxpal)))
59
60 #define i_img_destroy(im) ((im_extt->f_i_img_destroy)(im))
61 #define i_sametype(im, xsize, ysize) ((im_extt->f_i_sametype)((im), (xsize), (ysize)))
62 #define i_sametype_chans(im, xsize, ysize, channels) ((im_extt->f_i_sametype_chans)((im), (xsize), (ysize), (channels)))
63 #define i_img_info(im, info) ((im_extt->f_i_img_info)((im), (info)))
64
65 #ifndef IMAGER_DIRECT_IMAGE_CALLS
66 #define IMAGER_DIRECT_IMAGE_CALLS 1
67 #endif
68
69 #if !IMAGER_DIRECT_IMAGE_CALLS
70
71 #define i_ppix(im, x, y, val) ((im_extt->f_i_ppix)((im), (x), (y), (val)))
72 #define i_gpix(im, x, y, val) ((im_extt->f_i_gpix)((im), (x), (y), (val)))
73 #define i_ppixf(im, x, y, val) ((im_extt->f_i_ppixf)((im), (x), (y), (val)))
74 #define i_gpixf(im, x, y, val) ((im_extt->f_i_gpixf)((im), (x), (y), (val)))
75 #define i_plin(im, l, r, y, val) ((im_extt->f_i_plin)((im), (l), (r), (y), (val)))
76 #define i_glin(im, l, r, y, val) ((im_extt->f_i_glin)((im), (l), (r), (y), (val)))
77 #define i_plinf(im, l, r, y, val) ((im_extt->f_i_plinf)((im), (l), (r), (y), (val)))
78 #define i_glinf(im, l, r, y, val) ((im_extt->f_i_glinf)((im), (l), (r), (y), (val)))
79 #define i_gsamp(im, l, r, y, samps, chans, count) \
80 ((im_extt->f_i_gsamp)((im), (l), (r), (y), (samps), (chans), (count)))
81 #define i_gsampf(im, l, r, y, samps, chans, count) \
82 ((im_extt->f_i_gsampf)((im), (l), (r), (y), (samps), (chans), (count)))
83
84 #endif
85
86 #define i_gsamp_bits(im, l, r, y, samps, chans, count, bits) \
87 (((im)->i_f_gsamp_bits) ? ((im)->i_f_gsamp_bits)((im), (l), (r), (y), (samps), (chans), (count), (bits)) : -1)
88 #define i_psamp_bits(im, l, r, y, samps, chans, count, bits) \
89 (((im)->i_f_psamp_bits) ? ((im)->i_f_psamp_bits)((im), (l), (r), (y), (samps), (chans), (count), (bits)) : -1)
90
91 #define i_new_fill_solid(c, combine) ((im_extt->f_i_new_fill_solid)((c), (combine)))
92 #define i_new_fill_solidf(c, combine) ((im_extt->f_i_new_fill_solidf)((c), (combine)))
93 #define i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy) \
94 ((im_extt->f_i_new_fill_hatch)((fg), (bg), (combine), (hatch), (cust_hatch), (dx), (dy)))
95 #define i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy) \
96 ((im_extt->f_i_new_fill_hatchf)((fg), (bg), (combine), (hatch), (cust_hatch), (dx), (dy)))
97 #define i_new_fill_image(im, matrix, xoff, yoff, combine) \
98 ((im_extt->f_i_new_fill_image)((im), (matrix), (xoff), (yoff), (combine)))
99 #define i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, count, segs) \
100 ((im_extt->f_i_new_fill_fount)((xa), (ya), (xb), (yb), (type), (repeat), (combine), (super_sample), (ssample_param), (count), (segs)))
101 #define i_fill_destroy(fill) ((im_extt->f_i_fill_destroy)(fill))
102
103 #define i_quant_makemap(quant, imgs, count) \
104 ((im_extt->f_i_quant_makemap)((quant), (imgs), (count)))
105 #define i_quant_translate(quant, img) \
106 ((im_extt->f_i_quant_translate)((quant), (img)))
107 #define i_quant_transparent(quant, indices, img, trans_index) \
108 ((im_extt->f_i_quant_transparent)((quant), (indices), (img), (trans_index)))
109
110 #define im_clear_error(ctx) ((im_extt->f_im_clear_error)(ctx))
111 #define im_push_error(ctx, code, msg) ((im_extt->f_im_push_error)((ctx), (code), (msg)))
112 #define i_push_errorf (im_extt->f_i_push_errorf)
113 #define im_push_errorvf(ctx, code, fmt, list) \
114 ((im_extt->f_im_push_errorvf)((ctx), (code), (fmt), (list)))
115
116 #define i_tags_new(tags) ((im_extt->f_i_tags_new)(tags))
117 #define i_tags_set(tags, name, data, size) \
118 ((im_extt->f_i_tags_set)((tags), (name), (data), (size)))
119 #define i_tags_setn(tags, name, idata) \
120 ((im_extt->f_i_tags_setn)((tags), (name), (idata)))
121 #define i_tags_destroy(tags) ((im_extt->f_i_tags_destroy)(tags))
122 #define i_tags_find(tags, name, start, entry) \
123 ((im_extt->f_i_tags_find)((tags), (name), (start), (entry)))
124 #define i_tags_findn(tags, code, start, entry) \
125 ((im_extt->f_i_tags_findn)((tags), (code), (start), (entry)))
126 #define i_tags_delete(tags, entry) \
127 ((im_extt->f_i_tags_delete)((tags), (entry)))
128 #define i_tags_delbyname(tags, name) \
129 ((im_extt->f_i_tags_delbyname)((tags), (name)))
130 #define i_tags_delbycode(tags, code) \
131 ((im_extt->f_i_tags_delbycode)((tags), (code)))
132 #define i_tags_get_float(tags, name, code, value) \
133 ((im_extt->f_i_tags_get_float)((tags), (name), (code), (value)))
134 #define i_tags_set_float(tags, name, code, value) \
135 ((im_extt->f_i_tags_set_float)((tags), (name), (code), (value)))
136 #define i_tags_set_float2(tags, name, code, value, places) \
137 ((im_extt->f_i_tags_set_float2)((tags), (name), (code), (value), (places)))
138 #define i_tags_get_int(tags, name, code, value) \
139 ((im_extt->f_i_tags_get_int)((tags), (name), (code), (value)))
140 #define i_tags_get_string(tags, name, code, value, value_size) \
141 ((im_extt->f_i_tags_get_string)((tags), (name), (code), (value), (value_size)))
142 #define i_tags_get_color(tags, name, code, value) \
143 ((im_extt->f_i_tags_get_color)((tags), (name), (code), (value)))
144 #define i_tags_set_color(tags, name, code, value) \
145 ((im_extt->f_i_tags_set_color)((tags), (name), (code), (value)))
146
147 #define i_box(im, x1, y1, x2, y2, val) ((im_extt->f_i_box)((im), (x1), (y1), (x2), (y2), (val)))
148 #define i_box_filled(im, x1, y1, x2, y2, val) ((im_extt->f_i_box_filled)((im), (x1), (y1), (x2), (y2), (val)))
149 #define i_box_cfill(im, x1, y1, x2, y2, fill) ((im_extt->f_i_box_cfill)((im), (x1), (y1), (x2), (y2), (fill)))
150 #define i_line(im, x1, y1, x2, y2, val, endp) ((im_extt->f_i_line)((im), (x1), (y1), (x2), (y2), (val), (endp)))
151 #define i_line_aa(im, x1, y1, x2, y2, val, endp) ((im_extt->f_i_line_aa)((im), (x1), (y1), (x2), (y2), (val), (endp)))
152 #define i_arc(im, x, y, rad, d1, d2, val) ((im_extt->f_i_arc)((im), (x), (y), (rad), (d1), (d2), (val)))
153 #define i_arc_aa(im, x, y, rad, d1, d2, val) ((im_extt->f_i_arc_aa)((im), (x), (y), (rad), (d1), (d2), (val)))
154 #define i_arc_cfill(im, x, y, rad, d1, d2, fill) ((im_extt->f_i_arc_cfill)((im), (x), (y), (rad), (d1), (d2), (fill)))
155 #define i_arc_aa_cfill(im, x, y, rad, d1, d2, fill) ((im_extt->f_i_arc_aa_cfill)((im), (x), (y), (rad), (d1), (d2), (fill)))
156 #define i_circle_aa(im, x, y, rad, val) ((im_extt->f_i_circle_aa)((im), (x), (y), (rad), (val)))
157 #define i_flood_fill(im, seedx, seedy, dcol) ((im_extt->f_i_flood_fill)((im), (seedx), (seedy), (dcol)))
158 #define i_flood_cfill(im, seedx, seedy, fill) ((im_extt->f_i_flood_cfill)((im), (seedx), (seedy), (fill)))
159 #define i_flood_fill_border(im, seedx, seedy, dcol, border) ((im_extt->f_i_flood_fill_border)((im), (seedx), (seedy), (dcol), (border)))
160 #define i_flood_cfill_border(im, seedx, seedy, fill, border) ((im_extt->f_i_flood_cfill_border)((im), (seedx), (seedy), (fill), (border)))
161
162 #define i_poly_aa_m(im, count, x, y, mode, c) ((im_extt->f_i_poly_aa_m)((im), (count), (x), (y), (mode), (c)))
163 #define i_poly_aa_cfill_m(im, count, x, y, mode, fill) ((im_extt->f_i_poly_aa_cfill_m)((im), (count), (x), (y), (mode), (fill)))
164 #define i_poly_poly_aa(im, count, polys, mode, c) ((im_extt->f_i_poly_poly_aa)((im), (count), (polys), (mode), (c)))
165 #define i_poly_poly_aa_cfill(im, count, polys, mode, fill) ((im_extt->f_i_poly_poly_aa_cfill)((im), (count), (polys), (mode), (fill)))
166
167 #define i_copyto(im, src, x1, y1, x2, y2, tx, ty) \
168 ((im_extt->f_i_copyto)((im), (src), (x1), (y1), (x2), (y2), (tx), (ty)))
169 #define i_copyto_trans(im, src, x1, y1, x2, y2, tx, ty, trans) \
170 ((im_extt->f_i_copyto_trans)((im), (src), (x1), (y1), (x2), (y2), (tx), (ty), (trans)))
171 #define i_copy(im) ((im_extt->f_i_copy)(im))
172 #define i_rubthru(im, src, tx, ty, src_minx, src_miny, src_maxx, src_maxy) \
173 ((im_extt->f_i_rubthru)((im), (src), (tx), (ty), (src_minx), (src_miny), (src_maxx), (src_maxy)))
174
175 #define im_set_image_file_limits(ctx, max_width, max_height, max_bytes) \
176 ((im_extt->f_im_set_image_file_limits)((max_width), (max_height), (max_bytes)))
177 #define im_get_image_file_limits(ctx, pmax_width, pmax_height, pmax_bytes) \
178 ((im_extt->f_im_get_image_file_limits)((ctx), (pmax_width), (pmax_height), (pmax_bytes)))
179 #define im_int_check_image_file_limits(ctx, width, height, channels, sample_size) \
180 ((im_extt->f_im_int_check_image_file_limits)((ctx), (width), (height), (channels), (sample_size)))
181
182 #define i_img_setmask(img, mask) ((im_extt->f_i_img_setmask)((img), (mask)))
183 #define i_img_getmask(img) ((im_extt->f_i_img_getmask)(img))
184 #define i_img_getchannels(img) ((im_extt->f_i_img_getchannels)(img))
185 #define i_img_get_width(img) ((im_extt->f_i_img_get_width)(img))
186 #define i_img_get_height(img) ((im_extt->f_i_img_get_height)(img))
187 #define i_lhead(file, line) ((im_extt->f_i_lhead)((file), (line)))
188 #define i_loog (im_extt->f_i_loog)
189 #define im_lhead(ctx, file, line) ((im_extt->f_im_lhead)((ctx), (file), (line)))
190 #define im_loog (im_extt->f_im_loog)
191
192 #define im_img_alloc(ctx) ((im_extt->f_im_img_alloc)(ctx))
193 #define im_img_init(ctx, img) ((im_extt->fm_i_img_init)((ctx), (img)))
194
195 #define i_img_is_monochrome(img, zero_is_white) ((im_extt->f_i_img_is_monochrome)((img), (zero_is_white)))
196
197 #define i_gsamp_bg(im, l, r, y, samples, out_channels, bg) \
198 ((im_extt->f_i_gsamp_bg)((im), (l), (r), (y), (samples), (out_channels), (bg)))
199 #define i_gsampf_bg(im, l, r, y, samples, out_channels, bg) \
200 ((im_extt->f_i_gsampf_bg)((im), (l), (r), (y), (samples), (out_channels), (bg)))
201 #define i_get_file_background(im, bg) \
202 ((im_extt->f_i_get_file_background)((im), (bg)))
203 #define i_get_file_backgroundf(im, bg) \
204 ((im_extt->f_i_get_file_backgroundf)((im), (bg)))
205
206 #define i_utf8_advance(p, s) ((im_extt->f_i_utf8_advance)((p), (s)))
207
208 #define i_render_new(im, width) ((im_extt->f_i_render_new)((im), (width)))
209 #define i_render_delete(r) ((im_extt->f_i_render_delete)(r))
210 #define i_render_color(r, x, y, width, src, color) \
211 ((im_extt->f_i_render_color)((r), (x), (y), (width), (src), (color)))
212 #define i_render_fill(r, x, y, width, src, fill) \
213 ((im_extt->f_i_render_fill)((r), (x), (y), (width), (src), (fill)))
214 #define i_render_line(r, x, y, width, src, line, combine) \
215 ((im_extt->f_i_render_line)((r), (x), (y), (width), (src), (line), (combine)))
216 #define i_render_linef(r, x, y, width, src, line, combine) \
217 ((im_extt->f_i_render_linef)((r), (x), (y), (width), (src), (line), (combine)))
218
219 #define i_io_getc_imp (im_extt->f_i_io_getc_imp)
220 #define i_io_peekc_imp (im_extt->f_i_io_peekc_imp)
221 #define i_io_peekn (im_extt->f_i_io_peekn)
222 #define i_io_putc_imp (im_extt->f_i_io_putc_imp)
223 #define i_io_read (im_extt->f_i_io_read)
224 #define i_io_write (im_extt->f_i_io_write)
225 #define i_io_seek (im_extt->f_i_io_seek)
226 #define i_io_flush (im_extt->f_i_io_flush)
227 #define i_io_close (im_extt->f_i_io_close)
228 #define i_io_set_buffered (im_extt->f_i_io_set_buffered)
229 #define i_io_gets (im_extt->f_i_io_gets)
230 #define im_io_new_fd(ctx, fd) ((im_extt->f_im_io_new_fd)(ctx, fd))
231 #define im_io_new_bufchain(ctx) ((im_extt->f_im_io_new_bufchain)(ctx))
232 #define im_io_new_buffer(ctx, data, len, closecb, closedata) \
233 ((im_extt->f_im_io_new_buffer)((ctx), (data), (len), (closecb), (closedata)))
234 #define im_io_new_cb(ctx, p, readcb, writecb, seekcb, closecb, destroycb) \
235 ((im_extt->f_im_io_new_cb)((ctx), (p), (readcb), (writecb), (seekcb), (closecb), (destroycb)))
236 #define io_slurp(ig, datap) ((im_extt->f_io_slurp)((ig), (datap)))
237 #define io_glue_destroy(ig) ((im_extt->f_io_glue_destroy)(ig))
238
239 #define i_mutex_new() ((im_extt->f_i_mutex_new)())
240 #define i_mutex_destroy(m) ((im_extt->f_i_mutex_destroy)(m))
241 #define i_mutex_lock(m) ((im_extt->f_i_mutex_lock)(m))
242 #define i_mutex_unlock(m) ((im_extt->f_i_mutex_unlock)(m))
243
244 #define im_context_slot_new(destructor) ((im_extt->f_im_context_slot_new)(destructor))
245 #define im_context_slot_get(ctx, slot) ((im_extt->f_im_context_slot_get)((ctx), (slot)))
246 #define im_context_slot_set(ctx, slot, value) ((im_extt->f_im_context_slot_set)((ctx), (slot), (value)))
247
248 #define im_push_errorf (im_extt->f_im_push_errorf)
249
250 #define i_img_alpha_channel(im, channel) ((im_extt->f_i_img_alpha_channel)((im), (channel)))
251 #define i_img_color_model(im) ((im_extt->f_i_img_color_model)((im)))
252 #define i_img_color_channels(im) ((im_extt->f_i_img_color_channels)((im)))
253
254 #define im_decode_exif(im, data, len) ((im_extt->f_im_decode_exif)((im), (data), (len)))
255
256 #ifdef IMAGER_LOG
257 #ifndef IMAGER_NO_CONTEXT
258 #define mm_log(x) { i_lhead(__FILE__,__LINE__); i_loog x; }
259 #endif
260 #define im_log(x) { im_lhead(aIMCTX, __FILE__,__LINE__); im_loog x; }
261 #else
262 #define mm_log(x)
263 #endif
264
265 #ifdef __cplusplus
266 }
267 #endif
268
269 #endif