- added version/level to the API function table structure
[imager.git] / imext.h
CommitLineData
92bda632
TC
1#ifndef IMAGER_IMEXT_H_
2#define IMAGER_IMEXT_H_
3
4#include "imexttypes.h"
5
6extern im_ext_funcs *imager_function_ext_table;
7
8#define DEFINE_IMAGER_CALLBACKS im_ext_funcs *imager_function_ext_table
9
d1f5892c
TC
10#ifndef IMAGER_MIN_API_LEVEL
11#define IMAGER_MIN_API_LEVEL IMAGER_API_LEVEL
12#endif
13
92bda632 14#define PERL_INITIALIZE_IMAGER_CALLBACKS \
d1f5892c
TC
15 do { \
16 imager_function_ext_table = INT2PTR(im_ext_funcs *, SvIV(get_sv(PERL_FUNCTION_TABLE_NAME, 1))); \
17 if (!imager_function_ext_table) \
18 croak("Imager API function table not found!"); \
19 if (imager_function_ext_table->version != IMAGER_API_VERSION) \
20 croak("Imager API version incorrect"); \
21 if (imager_function_ext_table->level < IMAGER_MIN_API_LEVEL) \
22 croak("API level %d below minimum of %d", imager_function_ext_table->level, IMAGER_MIN_API_LEVEL); \
23 } while (0)
92bda632
TC
24
25/* just for use here */
26#define im_extt imager_function_ext_table
27
e310e5f9
TC
28#ifdef IMAGER_DEBUG_MALLOC
29
30#define mymalloc(size) ((im_extt->f_mymalloc_file_line)((size), __FILE__, __LINE__))
31#define myrealloc(ptr, size) ((im_extt->f_myrealloc_file_line)((ptr), (size), __FILE__, __LINE__))
32#define myfree(ptr) ((im_extt->f_myfree_file_line)((ptr), __FILE__, __LINE__))
33
34#else
35
92bda632
TC
36#define mymalloc(size) ((im_extt->f_mymalloc)(size))
37#define myfree(size) ((im_extt->f_myfree)(size))
38#define myrealloc(block, newsize) ((im_extt->f_myrealloc)((block), (newsize)))
39
e310e5f9
TC
40#endif
41
92bda632
TC
42#define i_img_8_new(xsize, ysize, channels) ((im_extt->f_i_img_8_new)((xsize), (ysize), (channels)))
43#define i_img_16_new(xsize, ysize, channels) ((im_extt->f_i_img_16_new)((xsize), (ysize), (channels)))
44#define i_img_double_new(xsize, ysize, channels) ((im_extt->f_i_img_double_new)((xsize), (ysize), (channels)))
45#define i_img_pal_new(xsize, ysize, channels, maxpal) ((im_extt->f_i_img_pal_new)((xsize), (ysize), (channels), (maxpal)))
46
47#define i_img_destroy(im) ((im_extt->f_i_img_destroy)(im))
48#define i_sametype(im, xsize, ysize) ((im_extt->f_i_sametype)((im), (xsize), (ysize)))
49#define i_sametype_chans(im, xsize, ysize, channels) ((im_extt->f_i_sametype_chans)((im), (xsize), (ysize), (channels)))
50#define i_img_info(im, info) ((im_extt->f_i_img_info)((im), (info)))
51
52#ifndef IMAGER_DIRECT_IMAGE_CALLS
53#define IMAGER_DIRECT_IMAGE_CALLS 1
54#endif
55
56#if IMAGER_DIRECT_IMAGE_CALLS
57#define i_ppix(im, x, y, val) (((im)->i_f_ppix)((im), (x), (y), (val)))
58#define i_gpix(im, x, y, val) (((im)->i_f_gpix)((im), (x), (y), (val)))
59#define i_ppixf(im, x, y, val) (((im)->i_f_ppixf)((im), (x), (y), (val)))
60#define i_gpixf(im, x, y, val) (((im)->i_f_gpixf)((im), (x), (y), (val)))
61#define i_plin(im, l, r, y, val) (((im)->i_f_plin)(im, l, r, y, val))
62#define i_glin(im, l, r, y, val) (((im)->i_f_glin)(im, l, r, y, val))
63#define i_plinf(im, l, r, y, val) (((im)->i_f_plinf)(im, l, r, y, val))
64#define i_glinf(im, l, r, y, val) (((im)->i_f_glinf)(im, l, r, y, val))
65
66#define i_gsamp(im, l, r, y, samps, chans, count) \
67 (((im)->i_f_gsamp)((im), (l), (r), (y), (samps), (chans), (count)))
68#define i_gsampf(im, l, r, y, samps, chans, count) \
69 (((im)->i_f_gsampf)((im), (l), (r), (y), (samps), (chans), (count)))
70
71#define i_findcolor(im, color, entry) \
72 (((im)->i_f_findcolor) ? ((im)->i_f_findcolor)((im), (color), (entry)) : 0)
73
74#define i_gpal(im, l, r, y, vals) \
75 (((im)->i_f_gpal) ? ((im)->i_f_gpal)((im), (l), (r), (y), (vals)) : 0)
76#define i_ppal(im, l, r, y, vals) \
77 (((im)->i_f_ppal) ? ((im)->i_f_ppal)((im), (l), (r), (y), (vals)) : 0)
78#define i_addcolors(im, colors, count) \
79 (((im)->i_f_addcolors) ? ((im)->i_f_addcolors)((im), (colors), (count)) : -1)
80#define i_getcolors(im, index, color, count) \
81 (((im)->i_f_getcolors) ? \
82 ((im)->i_f_getcolors)((im), (index), (color), (count)) : 0)
83#define i_setcolors(im, index, color, count) \
84 (((im)->i_f_setcolors) ? \
85 ((im)->i_f_setcolors)((im), (index), (color), (count)) : 0)
86#define i_colorcount(im) \
87 (((im)->i_f_colorcount) ? ((im)->i_f_colorcount)(im) : -1)
88#define i_maxcolors(im) \
89 (((im)->i_f_maxcolors) ? ((im)->i_f_maxcolors)(im) : -1)
90#define i_findcolor(im, color, entry) \
91 (((im)->i_f_findcolor) ? ((im)->i_f_findcolor)((im), (color), (entry)) : 0)
92#else
93#define i_ppix(im, x, y, val) ((im_extt->f_i_ppix)((im), (x), (y), (val)))
94#define i_gpix(im, x, y, val) ((im_extt->f_i_gpix)((im), (x), (y), (val)))
95#define i_ppixf(im, x, y, val) ((im_extt->f_i_ppixf)((im), (x), (y), (val)))
96#define i_gpixf(im, x, y, val) ((im_extt->f_i_gpixf)((im), (x), (y), (val)))
97#define i_plin(im, l, r, y, val) ((im_extt->f_i_plin)((im), (l), (r), (y), (val)))
98#define i_glin(im, l, r, y, val) ((im_extt->f_i_glin)((im), (l), (r), (y), (val)))
99#define i_plinf(im, l, r, y, val) ((im_extt->f_i_plinf)((im), (l), (r), (y), (val)))
100#define i_glinf(im, l, r, y, val) ((im_extt->f_i_glinf)((im), (l), (r), (y), (val)))
101#define i_gsamp(im, l, r, y, samps, chans, count) \
102 ((im_extt->f_i_gsamp)((im), (l), (r), (y), (samps), (chans), (count)))
103#define i_gsampf(im, l, r, y, samps, chans, count) \
104 ((im_extt->f_i_gsampf)((im), (l), (r), (y), (samps), (chans), (count)))
105
106#endif
107
108#define i_new_fill_solid(c, combine) ((im_extt->f_i_new_fill_solid)((c), (combine)))
109#define i_new_fill_solidf(c, combine) ((im_extt->f_i_new_fill_solidf)((c), (combine)))
110#define i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy) \
111 ((im_extt->f_i_new_fill_hatch)((fg), (bg), (combine), (hatch), (cust_hatch), (dx), (dy)))
112#define i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy) \
113 ((im_extt->f_i_new_fill_hatchf)((fg), (bg), (combine), (hatch), (cust_hatch), (dx), (dy)))
114#define i_new_fill_image(im, matrix, xoff, yoff, combine) \
115 ((im_extt->f_i_new_fill_image)((im), (matrix), (xoff), (yoff), (combine)))
116#define i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, count, segs) \
117 ((im_extt->f_i_new_fill_fount)((xa), (ya), (xb), (yb), (type), (repeat), (combine), (super_sample), (ssample_param), (count), (segs)))
118#define i_fill_destroy(fill) ((im_extt->f_i_fill_destroy)(fill))
119
120#define i_quant_makemap(quant, imgs, count) \
121 ((im_extt->f_i_quant_makemap)((quant), (imgs), (count)))
122#define i_quant_translate(quant, img) \
123 ((im_extt->f_i_quant_translate)((quant), (img)))
124#define i_quant_transparent(quant, indices, img, trans_index) \
125 ((im_extt->f_i_quant_transparent)((quant), (indices), (img), (trans_index)))
126
127#define i_clear_error() ((im_extt->f_i_clear_error)())
128#define i_push_error(code, msg) ((im_extt->f_i_push_error)((code), (msg)))
129#define i_push_errorf (im_extt->f_i_push_errorf)
130#define i_push_errorvf(code, fmt, list) \
131 ((im_extt->f_i_push_errorvf)((code), (fmt), (list)))
132
133#define i_tags_new(tags) ((im_extt->f_i_tags_new)(tags))
134#define i_tags_set(tags, name, data, size) \
135 ((im_extt->f_i_tags_set)((tags), (name), (data), (size)))
136#define i_tags_setn(tags, name, idata) \
137 ((im_extt->f_i_tags_setn)((tags), (name), (idata)))
138#define i_tags_destroy(tags) ((im_extt->f_i_tags_destroy)(tags))
139#define i_tags_find(tags, name, start, entry) \
140 ((im_extt->f_i_tags_find)((tags), (name), (start), (entry)))
141#define i_tags_findn(tags, code, start, entry) \
142 ((im_extt->f_i_tags_findn)((tags), (code), (start), (entry)))
143#define i_tags_delete(tags, entry) \
144 ((im_extt->f_i_tags_delete)((tags), (entry)))
145#define i_tags_delbyname(tags, name) \
146 ((im_extt->f_i_tags_delbyname)((tags), (name)))
147#define i_tags_delbycode(tags, code) \
148 ((im_extt->f_i_tags_delbycode)((tags), (code)))
149#define i_tags_get_float(tags, name, code, value) \
150 ((im_extt->f_i_tags_get_float)((tags), (name), (code), (value)))
151#define i_tags_set_float(tags, name, code, value) \
152 ((im_extt->f_i_tags_set_float)((tags), (name), (code), (value)))
153#define i_tags_set_float2(tags, name, code, value, places) \
154 ((im_extt->f_i_tags_set_float2)((tags), (name), (code), (value), (places)))
155#define i_tags_get_int(tags, name, code, value) \
156 ((im_extt->f_i_tags_get_int)((tags), (name), (code), (value)))
157#define i_tags_get_string(tags, name, code, value, value_size) \
158 ((im_extt->f_i_tags_get_string)((tags), (name), (code), (value), (value_size)))
159#define i_tags_get_color(tags, name, code, value) \
160 ((im_extt->f_i_tags_get_color)((tags), (name), (code), (value)))
161#define i_tags_set_color(tags, name, code, value) \
162 ((im_extt->f_i_tags_set_color)((tags), (name), (code), (value)))
163
164#define i_box(im, x1, y1, x2, y2, val) ((im_extt->f_i_box)((im), (x1), (y1), (x2), (y2), (val)))
165#define i_box_filled(im, x1, y1, x2, y2, val) ((im_extt->f_i_box_filled)((im), (x1), (y1), (x2), (y2), (val)))
166#define i_box_cfill(im, x1, y1, x2, y2, fill) ((im_extt->f_i_box_cfill)((im), (x1), (y1), (x2), (y2), (fill)))
167#define i_line(im, x1, y1, x2, y2, val, endp) ((im_extt->f_i_line)((im), (x1), (y1), (x2), (y2), (val), (endp)))
168#define i_line_aa(im, x1, y1, x2, y2, val, endp) ((im_extt->f_i_line_aa)((im), (x1), (y1), (x2), (y2), (val), (endp)))
169#define i_arc(im, x, y, rad, d1, d2, val) ((im_extt->f_i_arc)((im), (x), (y), (rad), (d1), (d2), (val)))
170#define i_arc_aa(im, x, y, rad, d1, d2, val) ((im_extt->f_i_arc_aa)((im), (x), (y), (rad), (d1), (d2), (val)))
171#define i_arc_cfill(im, x, y, rad, d1, d2, fill) ((im_extt->f_i_arc_cfill)((im), (x), (y), (rad), (d1), (d2), (fill)))
172#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)))
173#define i_circle_aa(im, x, y, rad, val) ((im_extt->f_i_circle_aa)((im), (x), (y), (rad), (val)))
174#define i_flood_fill(im, seedx, seedy, dcol) ((im_extt->f_i_flood_fill)((im), (seedx), (seedy), (dcol)))
175#define i_flood_cfill(im, seedx, seedy, fill) ((im_extt->f_i_flood_cfill)((im), (seedx), (seedy), (fill)))
176
177#define i_copyto(im, src, x1, y1, x2, y2, tx, ty) \
178 ((im_extt->f_i_copyto)((im), (src), (x1), (y1), (x2), (y2), (tx), (ty)))
179#define i_copyto_trans(im, src, x1, y1, x2, y2, tx, ty, trans) \
180 ((im_extt->f_i_copyto_trans)((im), (src), (x1), (y1), (x2), (y2), (tx), (ty), (trans)))
181#define i_copy(im) ((im_extt->f_i_copy)(im))
182#define i_rubthru(im, src, tx, ty, src_minx, src_miny, src_maxx, src_maxy) \
183 ((im_extt->f_i_rubthru)((im), (src), (tx), (ty), (src_minx), (src_miny), (src_maxx), (src_maxy)))
184
185#endif