Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 251 lines (211 sloc) 13.846 kb
92bda63 - start of external Imager API access:
Tony Cook authored
1 #ifndef IMAGER_IMEXT_H_
2 #define IMAGER_IMEXT_H_
3
4 #include "imexttypes.h"
bea65b1 - the hardinvert filter no-longer inverts the alpha channel.
Tony Cook authored
5 #include "immacros.h"
92bda63 - start of external Imager API access:
Tony Cook authored
6
7 extern im_ext_funcs *imager_function_ext_table;
8
9 #define DEFINE_IMAGER_CALLBACKS im_ext_funcs *imager_function_ext_table
10
d1f5892 - added version/level to the API function table structure
Tony Cook authored
11 #ifndef IMAGER_MIN_API_LEVEL
12 #define IMAGER_MIN_API_LEVEL IMAGER_API_LEVEL
13 #endif
14
38742a1 @tonycoz [rt #77173] improve error reporting on an API version mismatch
authored
15 #define PERL_INITIALIZE_IMAGER_CALLBACKS_NAME(name) \
d1f5892 - added version/level to the API function table structure
Tony Cook authored
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!"); \
af7d3ef @tonycoz report the mismatched version numbers if the Imager API version doesn't ...
authored
20 if (imager_function_ext_table->version != IMAGER_API_VERSION) { \
38742a1 @tonycoz [rt #77173] improve error reporting on an API version mismatch
authored
21 croak("Imager API version incorrect loaded %d vs expected %d in %s", \
22 imager_function_ext_table->version, IMAGER_API_VERSION, (name)); \
af7d3ef @tonycoz report the mismatched version numbers if the Imager API version doesn't ...
authored
23 } \
d1f5892 - added version/level to the API function table structure
Tony Cook authored
24 if (imager_function_ext_table->level < IMAGER_MIN_API_LEVEL) \
38742a1 @tonycoz [rt #77173] improve error reporting on an API version mismatch
authored
25 croak("API level %d below minimum of %d in %s", imager_function_ext_table->level, IMAGER_MIN_API_LEVEL, (name)); \
d1f5892 - added version/level to the API function table structure
Tony Cook authored
26 } while (0)
92bda63 - start of external Imager API access:
Tony Cook authored
27
38742a1 @tonycoz [rt #77173] improve error reporting on an API version mismatch
authored
28 #define PERL_INITIALIZE_IMAGER_CALLBACKS PERL_INITIALIZE_IMAGER_CALLBACKS_NAME(__FILE__)
29
92bda63 - start of external Imager API access:
Tony Cook authored
30 /* just for use here */
31 #define im_extt imager_function_ext_table
32
a609859 @tonycoz WIP, it compiles
authored
33 #define im_get_context() ((im_extt->f_im_get_context)())
7866a04 @tonycoz add some context dependent functions to the API
authored
34 #define im_context_refinc(ctx, where) ((im_extt->f_im_context_refinc)((ctx), (where)))
35 #define im_context_refdec(ctx, where) ((im_extt->f_im_context_refdec)((ctx), (where)))
a609859 @tonycoz WIP, it compiles
authored
36
e310e5f - more memory allocation integer overflow auditing
Tony Cook authored
37 #ifdef IMAGER_DEBUG_MALLOC
38
39 #define mymalloc(size) ((im_extt->f_mymalloc_file_line)((size), __FILE__, __LINE__))
40 #define myrealloc(ptr, size) ((im_extt->f_myrealloc_file_line)((ptr), (size), __FILE__, __LINE__))
41 #define myfree(ptr) ((im_extt->f_myfree_file_line)((ptr), __FILE__, __LINE__))
42
43 #else
44
92bda63 - start of external Imager API access:
Tony Cook authored
45 #define mymalloc(size) ((im_extt->f_mymalloc)(size))
46 #define myfree(size) ((im_extt->f_myfree)(size))
47 #define myrealloc(block, newsize) ((im_extt->f_myrealloc)((block), (newsize)))
48
e310e5f - more memory allocation integer overflow auditing
Tony Cook authored
49 #endif
50
a609859 @tonycoz WIP, it compiles
authored
51 #define im_img_8_new(ctx, xsize, ysize, channels) ((im_extt->f_im_img_8_new)((ctx), (xsize), (ysize), (channels)))
52 #define im_img_16_new(ctx, xsize, ysize, channels) ((im_extt->f_im_img_16_new)((ctx), (xsize), (ysize), (channels)))
53 #define im_img_double_new(ctx, xsize, ysize, channels) ((im_extt->f_im_img_double_new)((ctx), (xsize), (ysize), (channels)))
54 #define im_img_pal_new(ctx, xsize, ysize, channels, maxpal) ((im_extt->f_im_img_pal_new)((ctx), (xsize), (ysize), (channels), (maxpal)))
92bda63 - start of external Imager API access:
Tony Cook authored
55
56 #define i_img_destroy(im) ((im_extt->f_i_img_destroy)(im))
57 #define i_sametype(im, xsize, ysize) ((im_extt->f_i_sametype)((im), (xsize), (ysize)))
58 #define i_sametype_chans(im, xsize, ysize, channels) ((im_extt->f_i_sametype_chans)((im), (xsize), (ysize), (channels)))
59 #define i_img_info(im, info) ((im_extt->f_i_img_info)((im), (info)))
60
61 #ifndef IMAGER_DIRECT_IMAGE_CALLS
62 #define IMAGER_DIRECT_IMAGE_CALLS 1
63 #endif
64
542a7a4 @tonycoz WIP, OMG it works
authored
65 #if !IMAGER_DIRECT_IMAGE_CALLS
92bda63 - start of external Imager API access:
Tony Cook authored
66
67 #define i_ppix(im, x, y, val) ((im_extt->f_i_ppix)((im), (x), (y), (val)))
68 #define i_gpix(im, x, y, val) ((im_extt->f_i_gpix)((im), (x), (y), (val)))
69 #define i_ppixf(im, x, y, val) ((im_extt->f_i_ppixf)((im), (x), (y), (val)))
70 #define i_gpixf(im, x, y, val) ((im_extt->f_i_gpixf)((im), (x), (y), (val)))
71 #define i_plin(im, l, r, y, val) ((im_extt->f_i_plin)((im), (l), (r), (y), (val)))
72 #define i_glin(im, l, r, y, val) ((im_extt->f_i_glin)((im), (l), (r), (y), (val)))
73 #define i_plinf(im, l, r, y, val) ((im_extt->f_i_plinf)((im), (l), (r), (y), (val)))
74 #define i_glinf(im, l, r, y, val) ((im_extt->f_i_glinf)((im), (l), (r), (y), (val)))
75 #define i_gsamp(im, l, r, y, samps, chans, count) \
76 ((im_extt->f_i_gsamp)((im), (l), (r), (y), (samps), (chans), (count)))
77 #define i_gsampf(im, l, r, y, samps, chans, count) \
78 ((im_extt->f_i_gsampf)((im), (l), (r), (y), (samps), (chans), (count)))
79
80 #endif
81
e5ee047 move TIFF into its own module
Tony Cook authored
82 #define i_gsamp_bits(im, l, r, y, samps, chans, count, bits) \
83 (((im)->i_f_gsamp_bits) ? ((im)->i_f_gsamp_bits)((im), (l), (r), (y), (samps), (chans), (count), (bits)) : -1)
84 #define i_psamp_bits(im, l, r, y, samps, chans, count, bits) \
85 (((im)->i_f_psamp_bits) ? ((im)->i_f_psamp_bits)((im), (l), (r), (y), (samps), (chans), (count), (bits)) : -1)
86
92bda63 - start of external Imager API access:
Tony Cook authored
87 #define i_new_fill_solid(c, combine) ((im_extt->f_i_new_fill_solid)((c), (combine)))
88 #define i_new_fill_solidf(c, combine) ((im_extt->f_i_new_fill_solidf)((c), (combine)))
89 #define i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy) \
90 ((im_extt->f_i_new_fill_hatch)((fg), (bg), (combine), (hatch), (cust_hatch), (dx), (dy)))
91 #define i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy) \
92 ((im_extt->f_i_new_fill_hatchf)((fg), (bg), (combine), (hatch), (cust_hatch), (dx), (dy)))
93 #define i_new_fill_image(im, matrix, xoff, yoff, combine) \
94 ((im_extt->f_i_new_fill_image)((im), (matrix), (xoff), (yoff), (combine)))
95 #define i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, count, segs) \
96 ((im_extt->f_i_new_fill_fount)((xa), (ya), (xb), (yb), (type), (repeat), (combine), (super_sample), (ssample_param), (count), (segs)))
97 #define i_fill_destroy(fill) ((im_extt->f_i_fill_destroy)(fill))
98
99 #define i_quant_makemap(quant, imgs, count) \
100 ((im_extt->f_i_quant_makemap)((quant), (imgs), (count)))
101 #define i_quant_translate(quant, img) \
102 ((im_extt->f_i_quant_translate)((quant), (img)))
103 #define i_quant_transparent(quant, indices, img, trans_index) \
104 ((im_extt->f_i_quant_transparent)((quant), (indices), (img), (trans_index)))
105
a609859 @tonycoz WIP, it compiles
authored
106 #define im_clear_error(ctx) ((im_extt->f_im_clear_error)(ctx))
107 #define im_push_error(ctx, code, msg) ((im_extt->f_im_push_error)((ctx), (code), (msg)))
92bda63 - start of external Imager API access:
Tony Cook authored
108 #define i_push_errorf (im_extt->f_i_push_errorf)
a609859 @tonycoz WIP, it compiles
authored
109 #define im_push_errorvf(ctx, code, fmt, list) \
110 ((im_extt->f_im_push_errorvf)((ctx), (code), (fmt), (list)))
92bda63 - start of external Imager API access:
Tony Cook authored
111
112 #define i_tags_new(tags) ((im_extt->f_i_tags_new)(tags))
113 #define i_tags_set(tags, name, data, size) \
114 ((im_extt->f_i_tags_set)((tags), (name), (data), (size)))
115 #define i_tags_setn(tags, name, idata) \
116 ((im_extt->f_i_tags_setn)((tags), (name), (idata)))
117 #define i_tags_destroy(tags) ((im_extt->f_i_tags_destroy)(tags))
118 #define i_tags_find(tags, name, start, entry) \
119 ((im_extt->f_i_tags_find)((tags), (name), (start), (entry)))
120 #define i_tags_findn(tags, code, start, entry) \
121 ((im_extt->f_i_tags_findn)((tags), (code), (start), (entry)))
122 #define i_tags_delete(tags, entry) \
123 ((im_extt->f_i_tags_delete)((tags), (entry)))
124 #define i_tags_delbyname(tags, name) \
125 ((im_extt->f_i_tags_delbyname)((tags), (name)))
126 #define i_tags_delbycode(tags, code) \
127 ((im_extt->f_i_tags_delbycode)((tags), (code)))
128 #define i_tags_get_float(tags, name, code, value) \
129 ((im_extt->f_i_tags_get_float)((tags), (name), (code), (value)))
130 #define i_tags_set_float(tags, name, code, value) \
131 ((im_extt->f_i_tags_set_float)((tags), (name), (code), (value)))
132 #define i_tags_set_float2(tags, name, code, value, places) \
133 ((im_extt->f_i_tags_set_float2)((tags), (name), (code), (value), (places)))
134 #define i_tags_get_int(tags, name, code, value) \
135 ((im_extt->f_i_tags_get_int)((tags), (name), (code), (value)))
136 #define i_tags_get_string(tags, name, code, value, value_size) \
137 ((im_extt->f_i_tags_get_string)((tags), (name), (code), (value), (value_size)))
138 #define i_tags_get_color(tags, name, code, value) \
139 ((im_extt->f_i_tags_get_color)((tags), (name), (code), (value)))
140 #define i_tags_set_color(tags, name, code, value) \
141 ((im_extt->f_i_tags_set_color)((tags), (name), (code), (value)))
142
143 #define i_box(im, x1, y1, x2, y2, val) ((im_extt->f_i_box)((im), (x1), (y1), (x2), (y2), (val)))
144 #define i_box_filled(im, x1, y1, x2, y2, val) ((im_extt->f_i_box_filled)((im), (x1), (y1), (x2), (y2), (val)))
145 #define i_box_cfill(im, x1, y1, x2, y2, fill) ((im_extt->f_i_box_cfill)((im), (x1), (y1), (x2), (y2), (fill)))
146 #define i_line(im, x1, y1, x2, y2, val, endp) ((im_extt->f_i_line)((im), (x1), (y1), (x2), (y2), (val), (endp)))
147 #define i_line_aa(im, x1, y1, x2, y2, val, endp) ((im_extt->f_i_line_aa)((im), (x1), (y1), (x2), (y2), (val), (endp)))
148 #define i_arc(im, x, y, rad, d1, d2, val) ((im_extt->f_i_arc)((im), (x), (y), (rad), (d1), (d2), (val)))
149 #define i_arc_aa(im, x, y, rad, d1, d2, val) ((im_extt->f_i_arc_aa)((im), (x), (y), (rad), (d1), (d2), (val)))
150 #define i_arc_cfill(im, x, y, rad, d1, d2, fill) ((im_extt->f_i_arc_cfill)((im), (x), (y), (rad), (d1), (d2), (fill)))
151 #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)))
152 #define i_circle_aa(im, x, y, rad, val) ((im_extt->f_i_circle_aa)((im), (x), (y), (rad), (val)))
153 #define i_flood_fill(im, seedx, seedy, dcol) ((im_extt->f_i_flood_fill)((im), (seedx), (seedy), (dcol)))
154 #define i_flood_cfill(im, seedx, seedy, fill) ((im_extt->f_i_flood_cfill)((im), (seedx), (seedy), (fill)))
3efb091 implement a flood_fill that stops at a given color rather than filling
Tony Cook authored
155 #define i_flood_fill_border(im, seedx, seedy, dcol, border) ((im_extt->f_i_flood_fill_border)((im), (seedx), (seedy), (dcol), (border)))
156 #define i_flood_cfill_border(im, seedx, seedy, fill, border) ((im_extt->f_i_flood_cfill_border)((im), (seedx), (seedy), (fill), (border)))
92bda63 - start of external Imager API access:
Tony Cook authored
157
158 #define i_copyto(im, src, x1, y1, x2, y2, tx, ty) \
159 ((im_extt->f_i_copyto)((im), (src), (x1), (y1), (x2), (y2), (tx), (ty)))
160 #define i_copyto_trans(im, src, x1, y1, x2, y2, tx, ty, trans) \
161 ((im_extt->f_i_copyto_trans)((im), (src), (x1), (y1), (x2), (y2), (tx), (ty), (trans)))
162 #define i_copy(im) ((im_extt->f_i_copy)(im))
163 #define i_rubthru(im, src, tx, ty, src_minx, src_miny, src_maxx, src_maxy) \
164 ((im_extt->f_i_rubthru)((im), (src), (tx), (ty), (src_minx), (src_miny), (src_maxx), (src_maxy)))
165
a609859 @tonycoz WIP, it compiles
authored
166 #define im_set_image_file_limits(ctx, max_width, max_height, max_bytes) \
167 ((im_extt->f_im_set_image_file_limits)((max_width), (max_height), (max_bytes)))
168 #define im_get_image_file_limits(ctx, pmax_width, pmax_height, pmax_bytes) \
169 ((im_extt->f_im_get_image_file_limits)((ctx), (pmax_width), (pmax_height), (pmax_bytes)))
170 #define im_int_check_image_file_limits(ctx, width, height, channels, sample_size) \
171 ((im_extt->f_im_int_check_image_file_limits)((ctx), (width), (height), (channels), (sample_size)))
2b405c9 add support for file write plugins
Tony Cook authored
172
d5477d3 - Finished/rewrote Arnar's old SGI RGB file format support, so Imager
Tony Cook authored
173 #define i_img_setmask(img, mask) ((im_extt->f_i_img_setmask)((img), (mask)))
174 #define i_img_getmask(img) ((im_extt->f_i_img_getmask)(img))
175 #define i_img_getchannels(img) ((im_extt->f_i_img_getchannels)(img))
176 #define i_img_get_width(img) ((im_extt->f_i_img_get_width)(img))
177 #define i_img_get_height(img) ((im_extt->f_i_img_get_height)(img))
178 #define i_lhead(file, line) ((im_extt->f_i_lhead)((file), (line)))
179 #define i_loog (im_extt->f_i_loog)
7866a04 @tonycoz add some context dependent functions to the API
authored
180 #define im_lhead(ctx, file, line) ((im_extt->f_im_lhead)((ctx), (file), (line)))
181 #define im_loog (im_extt->f_im_loog)
d5477d3 - Finished/rewrote Arnar's old SGI RGB file format support, so Imager
Tony Cook authored
182
a609859 @tonycoz WIP, it compiles
authored
183 #define im_img_alloc(ctx) ((im_extt->f_im_img_alloc)(ctx))
184 #define im_img_init(ctx, img) ((im_extt->fm_i_img_init)((ctx), (img)))
bd8052a merge in tiff re-work branch
Tony Cook authored
185
e5ee047 move TIFF into its own module
Tony Cook authored
186 #define i_img_is_monochrome(img, zero_is_white) ((im_extt->f_i_img_is_monochrome)((img), (zero_is_white)))
187
797a9f9 move JPEG into it's own module
Tony Cook authored
188 #define i_gsamp_bg(im, l, r, y, samples, out_channels, bg) \
189 ((im_extt->f_i_gsamp_bg)((im), (l), (r), (y), (samples), (out_channels), (bg)))
190 #define i_gsampf_bg(im, l, r, y, samples, out_channels, bg) \
191 ((im_extt->f_i_gsampf_bg)((im), (l), (r), (y), (samples), (out_channels), (bg)))
192 #define i_get_file_background(im, bg) \
193 ((im_extt->f_i_get_file_background)((im), (bg)))
194 #define i_get_file_backgroundf(im, bg) \
195 ((im_extt->f_i_get_file_backgroundf)((im), (bg)))
196
718b8c9 move win32 font support in a new directory, and use Imager::Probe
Tony Cook authored
197 #define i_utf8_advance(p, s) ((im_extt->f_i_utf8_advance)((p), (s)))
198
50c7538 Move freetype 2 support into its own module
Tony Cook authored
199 #define i_render_new(im, width) ((im_extt->f_i_render_new)((im), (width)))
200 #define i_render_delete(r) ((im_extt->f_i_render_delete)(r))
201 #define i_render_color(r, x, y, width, src, color) \
202 ((im_extt->f_i_render_color)((r), (x), (y), (width), (src), (color)))
203 #define i_render_fill(r, x, y, width, src, fill) \
204 ((im_extt->f_i_render_fill)((r), (x), (y), (width), (src), (fill)))
205 #define i_render_line(r, x, y, width, src, line, combine) \
206 ((im_extt->f_i_render_line)((r), (x), (y), (width), (src), (line), (combine)))
207 #define i_render_linef(r, x, y, width, src, line, combine) \
208 ((im_extt->f_i_render_linef)((r), (x), (y), (width), (src), (line), (combine)))
209
6d5c85a @tonycoz Merge the I/O buffering branch
authored
210 #define i_io_getc_imp (im_extt->f_i_io_getc_imp)
211 #define i_io_peekc_imp (im_extt->f_i_io_peekc_imp)
212 #define i_io_peekn (im_extt->f_i_io_peekn)
213 #define i_io_putc_imp (im_extt->f_i_io_putc_imp)
214 #define i_io_read (im_extt->f_i_io_read)
215 #define i_io_write (im_extt->f_i_io_write)
216 #define i_io_seek (im_extt->f_i_io_seek)
217 #define i_io_flush (im_extt->f_i_io_flush)
218 #define i_io_close (im_extt->f_i_io_close)
219 #define i_io_set_buffered (im_extt->f_i_io_set_buffered)
220 #define i_io_gets (im_extt->f_i_io_gets)
8728397 @tonycoz update I/O layers to accept a context on creation
authored
221 #define im_io_new_fd(ctx, fd) ((im_extt->f_im_io_new_fd)(ctx, fd))
222 #define im_io_new_bufchain(ctx) ((im_extt->f_im_io_new_bufchain)(ctx))
223 #define im_io_new_buffer(ctx, data, len, closecb, closedata) \
224 ((im_extt->f_im_io_new_buffer)((ctx), (data), (len), (closecb), (closedata)))
225 #define im_io_new_cb(ctx, p, readcb, writecb, seekcb, closecb, destroycb) \
226 ((im_extt->f_im_io_new_cb)((ctx), (p), (readcb), (writecb), (seekcb), (closecb), (destroycb)))
6d5c85a @tonycoz Merge the I/O buffering branch
authored
227 #define io_slurp(ig, datap) ((im_extt->f_io_slurp)((ig), (datap)))
228 #define io_glue_destroy(ig) ((im_extt->f_io_glue_destroy)(ig))
229
bcf8804 @tonycoz add mutex functions to the API
authored
230 #define i_mutex_new() ((im_extt->f_i_mutex_new)())
231 #define i_mutex_destroy(m) ((im_extt->f_i_mutex_destroy)(m))
232 #define i_mutex_lock(m) ((im_extt->f_i_mutex_lock)(m))
233 #define i_mutex_unlock(m) ((im_extt->f_i_mutex_unlock)(m))
234
53d2c76 @tonycoz add the context slot APIs
authored
235 #define im_context_slot_new(destructor) ((im_extt->f_im_context_slot_new)(destructor))
236 #define im_context_slot_get(ctx, slot) ((im_extt->f_im_context_slot_get)((ctx), (slot)))
237 #define im_context_slot_set(ctx, slot, value) ((im_extt->f_im_context_slot_set)((ctx), (slot), (value)))
238
7866a04 @tonycoz add some context dependent functions to the API
authored
239 #define im_push_errorf (im_extt->f_im_push_errorf)
240
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
241 #ifdef IMAGER_LOG
7866a04 @tonycoz add some context dependent functions to the API
authored
242 #ifndef IMAGER_NO_CONTEXT
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
243 #define mm_log(x) { i_lhead(__FILE__,__LINE__); i_loog x; }
7866a04 @tonycoz add some context dependent functions to the API
authored
244 #endif
245 #define im_log(x) { im_lhead(aIMCTX, __FILE__,__LINE__); im_loog x; }
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
246 #else
247 #define mm_log(x)
248 #endif
249
92bda63 - start of external Imager API access:
Tony Cook authored
250 #endif
Something went wrong with that request. Please try again.