Move freetype 2 support into its own module
[imager.git] / imext.h
CommitLineData
92bda632
TC
1#ifndef IMAGER_IMEXT_H_
2#define IMAGER_IMEXT_H_
3
4#include "imexttypes.h"
bea65b1f 5#include "immacros.h"
92bda632
TC
6
7extern im_ext_funcs *imager_function_ext_table;
8
9#define DEFINE_IMAGER_CALLBACKS im_ext_funcs *imager_function_ext_table
10
d1f5892c
TC
11#ifndef IMAGER_MIN_API_LEVEL
12#define IMAGER_MIN_API_LEVEL IMAGER_API_LEVEL
13#endif
14
92bda632 15#define PERL_INITIALIZE_IMAGER_CALLBACKS \
d1f5892c
TC
16 do { \
17 imager_function_ext_table = INT2PTR(im_ext_funcs *, SvIV(get_sv(PERL_FUNCTION_TABLE_NAME, 1))); \
18 if (!imager_function_ext_table) \
19 croak("Imager API function table not found!"); \
20 if (imager_function_ext_table->version != IMAGER_API_VERSION) \
21 croak("Imager API version incorrect"); \
22 if (imager_function_ext_table->level < IMAGER_MIN_API_LEVEL) \
23 croak("API level %d below minimum of %d", imager_function_ext_table->level, IMAGER_MIN_API_LEVEL); \
24 } while (0)
92bda632
TC
25
26/* just for use here */
27#define im_extt imager_function_ext_table
28
e310e5f9
TC
29#ifdef IMAGER_DEBUG_MALLOC
30
31#define mymalloc(size) ((im_extt->f_mymalloc_file_line)((size), __FILE__, __LINE__))
32#define myrealloc(ptr, size) ((im_extt->f_myrealloc_file_line)((ptr), (size), __FILE__, __LINE__))
33#define myfree(ptr) ((im_extt->f_myfree_file_line)((ptr), __FILE__, __LINE__))
34
35#else
36
92bda632
TC
37#define mymalloc(size) ((im_extt->f_mymalloc)(size))
38#define myfree(size) ((im_extt->f_myfree)(size))
39#define myrealloc(block, newsize) ((im_extt->f_myrealloc)((block), (newsize)))
40
e310e5f9
TC
41#endif
42
92bda632
TC
43#define i_img_8_new(xsize, ysize, channels) ((im_extt->f_i_img_8_new)((xsize), (ysize), (channels)))
44#define i_img_16_new(xsize, ysize, channels) ((im_extt->f_i_img_16_new)((xsize), (ysize), (channels)))
45#define i_img_double_new(xsize, ysize, channels) ((im_extt->f_i_img_double_new)((xsize), (ysize), (channels)))
46#define i_img_pal_new(xsize, ysize, channels, maxpal) ((im_extt->f_i_img_pal_new)((xsize), (ysize), (channels), (maxpal)))
47
48#define i_img_destroy(im) ((im_extt->f_i_img_destroy)(im))
49#define i_sametype(im, xsize, ysize) ((im_extt->f_i_sametype)((im), (xsize), (ysize)))
50#define i_sametype_chans(im, xsize, ysize, channels) ((im_extt->f_i_sametype_chans)((im), (xsize), (ysize), (channels)))
51#define i_img_info(im, info) ((im_extt->f_i_img_info)((im), (info)))
52
53#ifndef IMAGER_DIRECT_IMAGE_CALLS
54#define IMAGER_DIRECT_IMAGE_CALLS 1
55#endif
56
57#if IMAGER_DIRECT_IMAGE_CALLS
58#define i_ppix(im, x, y, val) (((im)->i_f_ppix)((im), (x), (y), (val)))
59#define i_gpix(im, x, y, val) (((im)->i_f_gpix)((im), (x), (y), (val)))
60#define i_ppixf(im, x, y, val) (((im)->i_f_ppixf)((im), (x), (y), (val)))
61#define i_gpixf(im, x, y, val) (((im)->i_f_gpixf)((im), (x), (y), (val)))
62#define i_plin(im, l, r, y, val) (((im)->i_f_plin)(im, l, r, y, val))
63#define i_glin(im, l, r, y, val) (((im)->i_f_glin)(im, l, r, y, val))
64#define i_plinf(im, l, r, y, val) (((im)->i_f_plinf)(im, l, r, y, val))
65#define i_glinf(im, l, r, y, val) (((im)->i_f_glinf)(im, l, r, y, val))
66
67#define i_gsamp(im, l, r, y, samps, chans, count) \
68 (((im)->i_f_gsamp)((im), (l), (r), (y), (samps), (chans), (count)))
69#define i_gsampf(im, l, r, y, samps, chans, count) \
70 (((im)->i_f_gsampf)((im), (l), (r), (y), (samps), (chans), (count)))
71
72#define i_findcolor(im, color, entry) \
73 (((im)->i_f_findcolor) ? ((im)->i_f_findcolor)((im), (color), (entry)) : 0)
74
75#define i_gpal(im, l, r, y, vals) \
76 (((im)->i_f_gpal) ? ((im)->i_f_gpal)((im), (l), (r), (y), (vals)) : 0)
77#define i_ppal(im, l, r, y, vals) \
78 (((im)->i_f_ppal) ? ((im)->i_f_ppal)((im), (l), (r), (y), (vals)) : 0)
79#define i_addcolors(im, colors, count) \
80 (((im)->i_f_addcolors) ? ((im)->i_f_addcolors)((im), (colors), (count)) : -1)
81#define i_getcolors(im, index, color, count) \
82 (((im)->i_f_getcolors) ? \
83 ((im)->i_f_getcolors)((im), (index), (color), (count)) : 0)
84#define i_setcolors(im, index, color, count) \
85 (((im)->i_f_setcolors) ? \
86 ((im)->i_f_setcolors)((im), (index), (color), (count)) : 0)
87#define i_colorcount(im) \
88 (((im)->i_f_colorcount) ? ((im)->i_f_colorcount)(im) : -1)
89#define i_maxcolors(im) \
90 (((im)->i_f_maxcolors) ? ((im)->i_f_maxcolors)(im) : -1)
91#define i_findcolor(im, color, entry) \
92 (((im)->i_f_findcolor) ? ((im)->i_f_findcolor)((im), (color), (entry)) : 0)
93#else
94#define i_ppix(im, x, y, val) ((im_extt->f_i_ppix)((im), (x), (y), (val)))
95#define i_gpix(im, x, y, val) ((im_extt->f_i_gpix)((im), (x), (y), (val)))
96#define i_ppixf(im, x, y, val) ((im_extt->f_i_ppixf)((im), (x), (y), (val)))
97#define i_gpixf(im, x, y, val) ((im_extt->f_i_gpixf)((im), (x), (y), (val)))
98#define i_plin(im, l, r, y, val) ((im_extt->f_i_plin)((im), (l), (r), (y), (val)))
99#define i_glin(im, l, r, y, val) ((im_extt->f_i_glin)((im), (l), (r), (y), (val)))
100#define i_plinf(im, l, r, y, val) ((im_extt->f_i_plinf)((im), (l), (r), (y), (val)))
101#define i_glinf(im, l, r, y, val) ((im_extt->f_i_glinf)((im), (l), (r), (y), (val)))
102#define i_gsamp(im, l, r, y, samps, chans, count) \
103 ((im_extt->f_i_gsamp)((im), (l), (r), (y), (samps), (chans), (count)))
104#define i_gsampf(im, l, r, y, samps, chans, count) \
105 ((im_extt->f_i_gsampf)((im), (l), (r), (y), (samps), (chans), (count)))
106
107#endif
108
e5ee047b
TC
109#define i_gsamp_bits(im, l, r, y, samps, chans, count, bits) \
110 (((im)->i_f_gsamp_bits) ? ((im)->i_f_gsamp_bits)((im), (l), (r), (y), (samps), (chans), (count), (bits)) : -1)
111#define i_psamp_bits(im, l, r, y, samps, chans, count, bits) \
112 (((im)->i_f_psamp_bits) ? ((im)->i_f_psamp_bits)((im), (l), (r), (y), (samps), (chans), (count), (bits)) : -1)
113
92bda632
TC
114#define i_new_fill_solid(c, combine) ((im_extt->f_i_new_fill_solid)((c), (combine)))
115#define i_new_fill_solidf(c, combine) ((im_extt->f_i_new_fill_solidf)((c), (combine)))
116#define i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy) \
117 ((im_extt->f_i_new_fill_hatch)((fg), (bg), (combine), (hatch), (cust_hatch), (dx), (dy)))
118#define i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy) \
119 ((im_extt->f_i_new_fill_hatchf)((fg), (bg), (combine), (hatch), (cust_hatch), (dx), (dy)))
120#define i_new_fill_image(im, matrix, xoff, yoff, combine) \
121 ((im_extt->f_i_new_fill_image)((im), (matrix), (xoff), (yoff), (combine)))
122#define i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, count, segs) \
123 ((im_extt->f_i_new_fill_fount)((xa), (ya), (xb), (yb), (type), (repeat), (combine), (super_sample), (ssample_param), (count), (segs)))
124#define i_fill_destroy(fill) ((im_extt->f_i_fill_destroy)(fill))
125
126#define i_quant_makemap(quant, imgs, count) \
127 ((im_extt->f_i_quant_makemap)((quant), (imgs), (count)))
128#define i_quant_translate(quant, img) \
129 ((im_extt->f_i_quant_translate)((quant), (img)))
130#define i_quant_transparent(quant, indices, img, trans_index) \
131 ((im_extt->f_i_quant_transparent)((quant), (indices), (img), (trans_index)))
132
133#define i_clear_error() ((im_extt->f_i_clear_error)())
134#define i_push_error(code, msg) ((im_extt->f_i_push_error)((code), (msg)))
135#define i_push_errorf (im_extt->f_i_push_errorf)
136#define i_push_errorvf(code, fmt, list) \
137 ((im_extt->f_i_push_errorvf)((code), (fmt), (list)))
138
139#define i_tags_new(tags) ((im_extt->f_i_tags_new)(tags))
140#define i_tags_set(tags, name, data, size) \
141 ((im_extt->f_i_tags_set)((tags), (name), (data), (size)))
142#define i_tags_setn(tags, name, idata) \
143 ((im_extt->f_i_tags_setn)((tags), (name), (idata)))
144#define i_tags_destroy(tags) ((im_extt->f_i_tags_destroy)(tags))
145#define i_tags_find(tags, name, start, entry) \
146 ((im_extt->f_i_tags_find)((tags), (name), (start), (entry)))
147#define i_tags_findn(tags, code, start, entry) \
148 ((im_extt->f_i_tags_findn)((tags), (code), (start), (entry)))
149#define i_tags_delete(tags, entry) \
150 ((im_extt->f_i_tags_delete)((tags), (entry)))
151#define i_tags_delbyname(tags, name) \
152 ((im_extt->f_i_tags_delbyname)((tags), (name)))
153#define i_tags_delbycode(tags, code) \
154 ((im_extt->f_i_tags_delbycode)((tags), (code)))
155#define i_tags_get_float(tags, name, code, value) \
156 ((im_extt->f_i_tags_get_float)((tags), (name), (code), (value)))
157#define i_tags_set_float(tags, name, code, value) \
158 ((im_extt->f_i_tags_set_float)((tags), (name), (code), (value)))
159#define i_tags_set_float2(tags, name, code, value, places) \
160 ((im_extt->f_i_tags_set_float2)((tags), (name), (code), (value), (places)))
161#define i_tags_get_int(tags, name, code, value) \
162 ((im_extt->f_i_tags_get_int)((tags), (name), (code), (value)))
163#define i_tags_get_string(tags, name, code, value, value_size) \
164 ((im_extt->f_i_tags_get_string)((tags), (name), (code), (value), (value_size)))
165#define i_tags_get_color(tags, name, code, value) \
166 ((im_extt->f_i_tags_get_color)((tags), (name), (code), (value)))
167#define i_tags_set_color(tags, name, code, value) \
168 ((im_extt->f_i_tags_set_color)((tags), (name), (code), (value)))
169
170#define i_box(im, x1, y1, x2, y2, val) ((im_extt->f_i_box)((im), (x1), (y1), (x2), (y2), (val)))
171#define i_box_filled(im, x1, y1, x2, y2, val) ((im_extt->f_i_box_filled)((im), (x1), (y1), (x2), (y2), (val)))
172#define i_box_cfill(im, x1, y1, x2, y2, fill) ((im_extt->f_i_box_cfill)((im), (x1), (y1), (x2), (y2), (fill)))
173#define i_line(im, x1, y1, x2, y2, val, endp) ((im_extt->f_i_line)((im), (x1), (y1), (x2), (y2), (val), (endp)))
174#define i_line_aa(im, x1, y1, x2, y2, val, endp) ((im_extt->f_i_line_aa)((im), (x1), (y1), (x2), (y2), (val), (endp)))
175#define i_arc(im, x, y, rad, d1, d2, val) ((im_extt->f_i_arc)((im), (x), (y), (rad), (d1), (d2), (val)))
176#define i_arc_aa(im, x, y, rad, d1, d2, val) ((im_extt->f_i_arc_aa)((im), (x), (y), (rad), (d1), (d2), (val)))
177#define i_arc_cfill(im, x, y, rad, d1, d2, fill) ((im_extt->f_i_arc_cfill)((im), (x), (y), (rad), (d1), (d2), (fill)))
178#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)))
179#define i_circle_aa(im, x, y, rad, val) ((im_extt->f_i_circle_aa)((im), (x), (y), (rad), (val)))
180#define i_flood_fill(im, seedx, seedy, dcol) ((im_extt->f_i_flood_fill)((im), (seedx), (seedy), (dcol)))
181#define i_flood_cfill(im, seedx, seedy, fill) ((im_extt->f_i_flood_cfill)((im), (seedx), (seedy), (fill)))
3efb0915
TC
182#define i_flood_fill_border(im, seedx, seedy, dcol, border) ((im_extt->f_i_flood_fill_border)((im), (seedx), (seedy), (dcol), (border)))
183#define i_flood_cfill_border(im, seedx, seedy, fill, border) ((im_extt->f_i_flood_cfill_border)((im), (seedx), (seedy), (fill), (border)))
92bda632
TC
184
185#define i_copyto(im, src, x1, y1, x2, y2, tx, ty) \
186 ((im_extt->f_i_copyto)((im), (src), (x1), (y1), (x2), (y2), (tx), (ty)))
187#define i_copyto_trans(im, src, x1, y1, x2, y2, tx, ty, trans) \
188 ((im_extt->f_i_copyto_trans)((im), (src), (x1), (y1), (x2), (y2), (tx), (ty), (trans)))
189#define i_copy(im) ((im_extt->f_i_copy)(im))
190#define i_rubthru(im, src, tx, ty, src_minx, src_miny, src_maxx, src_maxy) \
191 ((im_extt->f_i_rubthru)((im), (src), (tx), (ty), (src_minx), (src_miny), (src_maxx), (src_maxy)))
192
2b405c9e
TC
193#define i_set_image_file_limits(max_width, max_height, max_bytes) \
194 ((im_extt->f_i_set_image_file_limits)((max_width), (max_height), (max_bytes)))
195#define i_get_image_file_limits(max_width, max_height, max_bytes) \
196 ((im_extt->f_i_get_image_file_limits)((pmax_width), (pmax_height), (pmax_bytes)))
197#define i_int_check_image_file_limits(width, height, channels, sample_size) \
198 ((im_extt->f_i_int_check_image_file_limits)((width), (height), (channels), (sample_size)))
199
d5477d3d
TC
200#define i_img_setmask(img, mask) ((im_extt->f_i_img_setmask)((img), (mask)))
201#define i_img_getmask(img) ((im_extt->f_i_img_getmask)(img))
202#define i_img_getchannels(img) ((im_extt->f_i_img_getchannels)(img))
203#define i_img_get_width(img) ((im_extt->f_i_img_get_width)(img))
204#define i_img_get_height(img) ((im_extt->f_i_img_get_height)(img))
205#define i_lhead(file, line) ((im_extt->f_i_lhead)((file), (line)))
206#define i_loog (im_extt->f_i_loog)
207
bd8052a6
TC
208#define i_img_alloc() ((im_extt->f_i_img_alloc)())
209#define i_img_init(img) ((im_extt->f_i_img_init)(img))
210
e5ee047b
TC
211#define i_img_is_monochrome(img, zero_is_white) ((im_extt->f_i_img_is_monochrome)((img), (zero_is_white)))
212
797a9f9c
TC
213#define i_gsamp_bg(im, l, r, y, samples, out_channels, bg) \
214 ((im_extt->f_i_gsamp_bg)((im), (l), (r), (y), (samples), (out_channels), (bg)))
215#define i_gsampf_bg(im, l, r, y, samples, out_channels, bg) \
216 ((im_extt->f_i_gsampf_bg)((im), (l), (r), (y), (samples), (out_channels), (bg)))
217#define i_get_file_background(im, bg) \
218 ((im_extt->f_i_get_file_background)((im), (bg)))
219#define i_get_file_backgroundf(im, bg) \
220 ((im_extt->f_i_get_file_backgroundf)((im), (bg)))
221
718b8c97
TC
222#define i_utf8_advance(p, s) ((im_extt->f_i_utf8_advance)((p), (s)))
223
50c75381
TC
224#define i_render_new(im, width) ((im_extt->f_i_render_new)((im), (width)))
225#define i_render_delete(r) ((im_extt->f_i_render_delete)(r))
226#define i_render_color(r, x, y, width, src, color) \
227 ((im_extt->f_i_render_color)((r), (x), (y), (width), (src), (color)))
228#define i_render_fill(r, x, y, width, src, fill) \
229 ((im_extt->f_i_render_fill)((r), (x), (y), (width), (src), (fill)))
230#define i_render_line(r, x, y, width, src, line, combine) \
231 ((im_extt->f_i_render_line)((r), (x), (y), (width), (src), (line), (combine)))
232#define i_render_linef(r, x, y, width, src, line, combine) \
233 ((im_extt->f_i_render_linef)((r), (x), (y), (width), (src), (line), (combine)))
234
92bda632 235#endif