]>
Commit | Line | Data |
---|---|---|
92bda632 TC |
1 | #include "imexttypes.h" |
2 | #include "imager.h" | |
50c75381 | 3 | #include "imio.h" |
75e155e1 | 4 | #include "imexif.h" |
92bda632 | 5 | |
44d86483 | 6 | static im_context_t get_context(void); |
eac41a26 TC |
7 | static i_img *mathom_i_img_8_new(i_img_dim, i_img_dim, int); |
8 | static i_img *mathom_i_img_16_new(i_img_dim, i_img_dim, int); | |
9 | static i_img *mathom_i_img_double_new(i_img_dim, i_img_dim, int); | |
10 | static i_img *mathom_i_img_pal_new(i_img_dim, i_img_dim, int, int); | |
11 | static void mathom_i_clear_error(void); | |
12 | static void mathom_i_push_error(int, const char *); | |
13 | static void mathom_i_push_errorvf(int, const char *, va_list); | |
14 | static int mathom_i_set_image_file_limits(i_img_dim, i_img_dim, size_t); | |
15 | static int mathom_i_get_image_file_limits(i_img_dim*, i_img_dim*, size_t*); | |
16 | static int | |
17 | mathom_i_int_check_image_file_limits(i_img_dim, i_img_dim, int, size_t); | |
18 | static i_img *mathom_i_img_alloc(void); | |
19 | static void mathom_i_img_init(i_img *); | |
20 | static i_io_glue_t *mathom_io_new_fd(int); | |
21 | static i_io_glue_t *mathom_io_new_bufchain(void); | |
22 | static i_io_glue_t * | |
23 | mathom_io_new_buffer(const char *data, size_t, i_io_closebufp_t, void *); | |
24 | static i_io_glue_t * | |
25 | mathom_io_new_cb(void *, i_io_readl_t, i_io_writel_t, i_io_seekl_t, | |
26 | i_io_closel_t, i_io_destroyl_t); | |
44d86483 | 27 | |
92bda632 TC |
28 | /* |
29 | DON'T ADD CASTS TO THESE | |
30 | */ | |
31 | im_ext_funcs imager_function_table = | |
32 | { | |
d1f5892c TC |
33 | IMAGER_API_VERSION, |
34 | IMAGER_API_LEVEL, | |
35 | ||
92bda632 TC |
36 | mymalloc, |
37 | myfree, | |
38 | myrealloc, | |
39 | ||
e310e5f9 TC |
40 | mymalloc_file_line, |
41 | myfree_file_line, | |
42 | myrealloc_file_line, | |
43 | ||
eac41a26 TC |
44 | mathom_i_img_8_new, |
45 | mathom_i_img_16_new, | |
46 | mathom_i_img_double_new, | |
47 | mathom_i_img_pal_new, | |
92bda632 TC |
48 | i_img_destroy, |
49 | i_sametype, | |
50 | i_sametype_chans, | |
51 | i_img_info, | |
52 | ||
53 | i_ppix, | |
54 | i_gpix, | |
55 | i_ppixf, | |
56 | i_gpixf, | |
57 | i_plin, | |
58 | i_glin, | |
59 | i_plinf, | |
60 | i_glinf, | |
61 | i_gsamp, | |
62 | i_gsampf, | |
63 | i_gpal, | |
64 | i_ppal, | |
65 | i_addcolors, | |
66 | i_getcolors, | |
67 | i_colorcount, | |
68 | i_maxcolors, | |
69 | i_findcolor, | |
70 | i_setcolors, | |
71 | ||
72 | i_new_fill_solid, | |
73 | i_new_fill_solidf, | |
74 | i_new_fill_hatch, | |
75 | i_new_fill_hatchf, | |
76 | i_new_fill_image, | |
77 | i_new_fill_fount, | |
78 | i_fill_destroy, | |
79 | ||
80 | i_quant_makemap, | |
81 | i_quant_translate, | |
82 | i_quant_transparent, | |
83 | ||
eac41a26 TC |
84 | mathom_i_clear_error, |
85 | mathom_i_push_error, | |
92bda632 | 86 | i_push_errorf, |
eac41a26 | 87 | mathom_i_push_errorvf, |
92bda632 TC |
88 | |
89 | i_tags_new, | |
90 | i_tags_set, | |
91 | i_tags_setn, | |
92 | i_tags_destroy, | |
93 | i_tags_find, | |
94 | i_tags_findn, | |
95 | i_tags_delete, | |
96 | i_tags_delbyname, | |
97 | i_tags_delbycode, | |
98 | i_tags_get_float, | |
99 | i_tags_set_float, | |
100 | i_tags_set_float2, | |
101 | i_tags_get_int, | |
102 | i_tags_get_string, | |
103 | i_tags_get_color, | |
104 | i_tags_set_color, | |
105 | ||
106 | i_box, | |
107 | i_box_filled, | |
108 | i_box_cfill, | |
109 | i_line, | |
110 | i_line_aa, | |
111 | i_arc, | |
112 | i_arc_aa, | |
113 | i_arc_cfill, | |
114 | i_arc_aa_cfill, | |
115 | i_circle_aa, | |
116 | i_flood_fill, | |
117 | i_flood_cfill, | |
118 | ||
119 | i_copyto, | |
120 | i_copyto_trans, | |
121 | i_copy, | |
122 | i_rubthru, | |
2b405c9e TC |
123 | |
124 | /* IMAGER_API_LEVEL 2 functions */ | |
eac41a26 TC |
125 | mathom_i_set_image_file_limits, |
126 | mathom_i_get_image_file_limits, | |
127 | mathom_i_int_check_image_file_limits, | |
3efb0915 TC |
128 | |
129 | i_flood_fill_border, | |
130 | i_flood_cfill_border, | |
d5477d3d TC |
131 | |
132 | /* IMAGER_API_LEVEL 3 functions */ | |
133 | i_img_setmask, | |
134 | i_img_getmask, | |
135 | i_img_getchannels, | |
136 | i_img_get_width, | |
137 | i_img_get_height, | |
138 | i_lhead, | |
bd8052a6 TC |
139 | i_loog, |
140 | ||
141 | /* IMAGER_API_LEVEL 4 functions */ | |
eac41a26 TC |
142 | mathom_i_img_alloc, |
143 | mathom_i_img_init, | |
e5ee047b TC |
144 | |
145 | /* IMAGER_API_LEVEL 5 functions */ | |
797a9f9c TC |
146 | i_img_is_monochrome, |
147 | i_gsamp_bg, | |
148 | i_gsampf_bg, | |
149 | i_get_file_background, | |
718b8c97 | 150 | i_get_file_backgroundf, |
50c75381 TC |
151 | i_utf8_advance, |
152 | i_render_new, | |
153 | i_render_delete, | |
154 | i_render_color, | |
155 | i_render_fill, | |
156 | i_render_line, | |
6d5c85a2 TC |
157 | i_render_linef, |
158 | ||
159 | /* level 6 */ | |
160 | i_io_getc_imp, | |
161 | i_io_peekc_imp, | |
162 | i_io_peekn, | |
163 | i_io_putc_imp, | |
164 | i_io_read, | |
165 | i_io_write, | |
166 | i_io_seek, | |
167 | i_io_flush, | |
168 | i_io_close, | |
169 | i_io_set_buffered, | |
170 | i_io_gets, | |
eac41a26 TC |
171 | mathom_io_new_fd, |
172 | mathom_io_new_bufchain, | |
173 | mathom_io_new_buffer, | |
174 | mathom_io_new_cb, | |
6d5c85a2 | 175 | io_slurp, |
44d86483 TC |
176 | io_glue_destroy, |
177 | ||
c9786b6c | 178 | /* level 8 */ |
eac41a26 TC |
179 | im_img_8_new, |
180 | im_img_16_new, | |
181 | im_img_double_new, | |
182 | im_img_pal_new, | |
183 | im_clear_error, | |
184 | im_push_error, | |
185 | im_push_errorvf, | |
c9786b6c | 186 | im_push_errorf, |
eac41a26 TC |
187 | im_set_image_file_limits, |
188 | im_get_image_file_limits, | |
189 | im_int_check_image_file_limits, | |
190 | im_img_alloc, | |
191 | im_img_init, | |
192 | im_io_new_fd, | |
193 | im_io_new_bufchain, | |
194 | im_io_new_buffer, | |
195 | im_io_new_cb, | |
196 | get_context, | |
c9786b6c TC |
197 | im_lhead, |
198 | im_loog, | |
199 | im_context_refinc, | |
8b30e240 | 200 | im_context_refdec, |
24c9233d TC |
201 | im_errors, |
202 | i_mutex_new, | |
203 | i_mutex_destroy, | |
204 | i_mutex_lock, | |
fc02e376 TC |
205 | i_mutex_unlock, |
206 | im_context_slot_new, | |
207 | im_context_slot_set, | |
0d80f37e TC |
208 | im_context_slot_get, |
209 | ||
210 | /* level 9 */ | |
211 | i_poly_poly_aa, | |
212 | i_poly_poly_aa_cfill, | |
213 | i_poly_aa_m, | |
35db02fc TC |
214 | i_poly_aa_cfill_m, |
215 | ||
35db02fc TC |
216 | i_img_alpha_channel, |
217 | i_img_color_model, | |
75e155e1 TC |
218 | i_img_color_channels, |
219 | ||
220 | /* level 10 */ | |
221 | im_decode_exif | |
222 | ||
223 | /* level 11 */ | |
92bda632 TC |
224 | }; |
225 | ||
226 | /* in general these functions aren't called by Imager internally, but | |
227 | only via the pointers above, since faster macros that call the | |
228 | image vtable pointers are used. | |
229 | ||
230 | () are used around the function names to prevent macro replacement | |
231 | on the function names. | |
232 | */ | |
233 | ||
234 | /* | |
235 | =item i_ppix(im, x, y, color) | |
236 | ||
237 | =category Drawing | |
238 | ||
239 | Sets the pixel at (x,y) to I<color>. | |
240 | ||
241 | Returns 0 if the pixel was drawn, or -1 if not. | |
242 | ||
243 | Does no alpha blending, just copies the channels from the supplied | |
244 | color to the image. | |
245 | ||
246 | =cut | |
247 | */ | |
248 | ||
249 | int | |
8d14daab | 250 | (i_ppix)(i_img *im, i_img_dim x, i_img_dim y, const i_color *val) { |
92bda632 TC |
251 | return i_ppix(im, x, y, val); |
252 | } | |
253 | ||
254 | /* | |
5715f7c3 | 255 | =item i_gpix(im, C<x>, C<y>, C<color>) |
92bda632 TC |
256 | |
257 | =category Drawing | |
258 | ||
5715f7c3 | 259 | Retrieves the C<color> of the pixel (x,y). |
92bda632 TC |
260 | |
261 | Returns 0 if the pixel was retrieved, or -1 if not. | |
262 | ||
263 | =cut | |
264 | */ | |
265 | ||
266 | int | |
8d14daab | 267 | (i_gpix)(i_img *im,i_img_dim x,i_img_dim y,i_color *val) { |
92bda632 TC |
268 | return i_gpix(im, x, y, val); |
269 | } | |
270 | ||
271 | /* | |
5715f7c3 | 272 | =item i_ppixf(im, C<x>, C<y>, C<fcolor>) |
92bda632 TC |
273 | |
274 | =category Drawing | |
275 | ||
5715f7c3 | 276 | Sets the pixel at (C<x>,C<y>) to the floating point color C<fcolor>. |
92bda632 TC |
277 | |
278 | Returns 0 if the pixel was drawn, or -1 if not. | |
279 | ||
280 | Does no alpha blending, just copies the channels from the supplied | |
281 | color to the image. | |
282 | ||
283 | =cut | |
284 | */ | |
285 | int | |
8d14daab | 286 | (i_ppixf)(i_img *im, i_img_dim x, i_img_dim y, const i_fcolor *val) { |
92bda632 TC |
287 | return i_ppixf(im, x, y, val); |
288 | } | |
289 | ||
290 | /* | |
5715f7c3 | 291 | =item i_gpixf(im, C<x>, C<y>, C<fcolor>) |
92bda632 TC |
292 | |
293 | =category Drawing | |
294 | ||
295 | Retrieves the color of the pixel (x,y) as a floating point color into | |
5715f7c3 | 296 | C<fcolor>. |
92bda632 TC |
297 | |
298 | Returns 0 if the pixel was retrieved, or -1 if not. | |
299 | ||
300 | =cut | |
301 | */ | |
302 | ||
303 | int | |
8d14daab | 304 | (i_gpixf)(i_img *im,i_img_dim x,i_img_dim y,i_fcolor *val) { |
92bda632 TC |
305 | return i_gpixf(im, x, y, val); |
306 | } | |
307 | ||
308 | /* | |
309 | =item i_plin(im, l, r, y, colors) | |
310 | ||
311 | =category Drawing | |
312 | ||
313 | Sets (r-l) pixels starting from (l,y) using (r-l) values from | |
314 | I<colors>. | |
315 | ||
316 | Returns the number of pixels set. | |
317 | ||
318 | =cut | |
319 | */ | |
320 | ||
8d14daab TC |
321 | i_img_dim |
322 | (i_plin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_color *vals) { | |
92bda632 TC |
323 | return i_plin(im, l, r, y, vals); |
324 | } | |
325 | ||
326 | /* | |
327 | =item i_glin(im, l, r, y, colors) | |
328 | ||
329 | =category Drawing | |
330 | ||
331 | Retrieves (r-l) pixels starting from (l,y) into I<colors>. | |
332 | ||
333 | Returns the number of pixels retrieved. | |
334 | ||
335 | =cut | |
336 | */ | |
337 | ||
8d14daab TC |
338 | i_img_dim |
339 | (i_glin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_color *vals) { | |
92bda632 TC |
340 | return i_glin(im, l, r, y, vals); |
341 | } | |
342 | ||
343 | /* | |
5715f7c3 | 344 | =item i_plinf(im, C<left>, C<right>, C<fcolors>) |
92bda632 TC |
345 | |
346 | =category Drawing | |
347 | ||
5715f7c3 TC |
348 | Sets (right-left) pixels starting from (left,y) using (right-left) |
349 | floating point colors from C<fcolors>. | |
92bda632 TC |
350 | |
351 | Returns the number of pixels set. | |
352 | ||
353 | =cut | |
354 | */ | |
355 | ||
8d14daab TC |
356 | i_img_dim |
357 | (i_plinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_fcolor *vals) { | |
92bda632 TC |
358 | return i_plinf(im, l, r, y, vals); |
359 | } | |
360 | ||
361 | /* | |
362 | =item i_glinf(im, l, r, y, colors) | |
363 | ||
364 | =category Drawing | |
365 | ||
366 | Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating | |
367 | point colors. | |
368 | ||
369 | Returns the number of pixels retrieved. | |
370 | ||
371 | =cut | |
372 | */ | |
373 | ||
8d14daab TC |
374 | i_img_dim |
375 | (i_glinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fcolor *vals) { | |
92bda632 TC |
376 | return i_glinf(im, l, r, y, vals); |
377 | } | |
378 | ||
379 | /* | |
5715f7c3 | 380 | =item i_gsamp(im, left, right, y, samples, channels, channel_count) |
92bda632 TC |
381 | |
382 | =category Drawing | |
383 | ||
5715f7c3 TC |
384 | Reads sample values from C<im> for the horizontal line (left, y) to |
385 | (right-1,y) for the channels specified by C<channels>, an array of int | |
386 | with C<channel_count> elements. | |
92bda632 | 387 | |
5715f7c3 | 388 | If channels is NULL then the first channels_count channels are retrieved for |
92bda632 TC |
389 | each pixel. |
390 | ||
5715f7c3 TC |
391 | Returns the number of samples read (which should be (right-left) * |
392 | channel_count) | |
92bda632 TC |
393 | |
394 | =cut | |
395 | */ | |
8d14daab TC |
396 | i_img_dim |
397 | (i_gsamp)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_sample_t *samp, | |
92bda632 TC |
398 | const int *chans, int chan_count) { |
399 | return i_gsamp(im, l, r, y, samp, chans, chan_count); | |
400 | } | |
401 | ||
402 | /* | |
5715f7c3 | 403 | =item i_gsampf(im, left, right, y, samples, channels, channel_count) |
92bda632 TC |
404 | |
405 | =category Drawing | |
406 | ||
5715f7c3 TC |
407 | Reads floating point sample values from C<im> for the horizontal line |
408 | (left, y) to (right-1,y) for the channels specified by C<channels>, an | |
409 | array of int with channel_count elements. | |
92bda632 | 410 | |
5715f7c3 TC |
411 | If C<channels> is NULL then the first C<channel_count> channels are |
412 | retrieved for each pixel. | |
92bda632 | 413 | |
5715f7c3 TC |
414 | Returns the number of samples read (which should be (C<right>-C<left>) |
415 | * C<channel_count>) | |
92bda632 TC |
416 | |
417 | =cut | |
418 | */ | |
8d14daab TC |
419 | i_img_dim |
420 | (i_gsampf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samp, | |
92bda632 TC |
421 | const int *chans, int chan_count) { |
422 | return i_gsampf(im, l, r, y, samp, chans, chan_count); | |
423 | } | |
424 | ||
48095bd4 TC |
425 | /* |
426 | =item i_gsamp_bits(im, left, right, y, samples, channels, channel_count, bits) | |
427 | =category Drawing | |
428 | ||
429 | Reads integer samples scaled to C<bits> bits of precision into the | |
430 | C<unsigned int> array C<samples>. | |
431 | ||
432 | Expect this to be slow unless C<< bits == im->bits >>. | |
433 | ||
434 | Returns the number of samples copied, or -1 on error. | |
435 | ||
436 | Not all image types implement this method. | |
437 | ||
438 | Pushes errors, but does not call C<i_clear_error()>. | |
439 | ||
440 | =cut | |
441 | */ | |
442 | ||
443 | /* | |
444 | =item i_psamp_bits(im, left, right, y, samples, channels, channel_count, bits) | |
445 | =category Drawing | |
446 | ||
447 | Writes integer samples scaled to C<bits> bits of precision from the | |
448 | C<unsigned int> array C<samples>. | |
449 | ||
450 | Expect this to be slow unless C<< bits == im->bits >>. | |
451 | ||
452 | Returns the number of samples copied, or -1 on error. | |
453 | ||
454 | Not all image types implement this method. | |
455 | ||
456 | Pushes errors, but does not call C<i_clear_error()>. | |
457 | ||
458 | =cut | |
459 | */ | |
460 | ||
92bda632 | 461 | /* |
5715f7c3 | 462 | =item i_gpal(im, left, right, y, indexes) |
92bda632 TC |
463 | |
464 | =category Drawing | |
465 | ||
5715f7c3 TC |
466 | Reads palette indexes for the horizontal line (left, y) to (right-1, |
467 | y) into C<indexes>. | |
92bda632 TC |
468 | |
469 | Returns the number of indexes read. | |
470 | ||
471 | Always returns 0 for direct color images. | |
472 | ||
473 | =cut | |
474 | */ | |
8d14daab TC |
475 | i_img_dim |
476 | (i_gpal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, i_palidx *vals) { | |
92bda632 TC |
477 | return i_gpal(im, x, r, y, vals); |
478 | } | |
479 | ||
480 | /* | |
5715f7c3 | 481 | =item i_ppal(im, left, right, y, indexes) |
92bda632 TC |
482 | |
483 | =category Drawing | |
484 | ||
5715f7c3 TC |
485 | Writes palette indexes for the horizontal line (left, y) to (right-1, |
486 | y) from C<indexes>. | |
92bda632 TC |
487 | |
488 | Returns the number of indexes written. | |
489 | ||
490 | Always returns 0 for direct color images. | |
491 | ||
492 | =cut | |
493 | */ | |
8d14daab TC |
494 | i_img_dim |
495 | (i_ppal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, const i_palidx *vals) { | |
92bda632 TC |
496 | return i_ppal(im, x, r, y, vals); |
497 | } | |
498 | ||
499 | /* | |
500 | =item i_addcolors(im, colors, count) | |
501 | ||
502 | =category Paletted images | |
503 | ||
504 | Adds colors to the image's palette. | |
505 | ||
506 | On success returns the index of the lowest color added. | |
507 | ||
508 | On failure returns -1. | |
509 | ||
510 | Always fails for direct color images. | |
511 | ||
512 | =cut | |
513 | */ | |
514 | ||
515 | int | |
97ac0a96 | 516 | (i_addcolors)(i_img *im, const i_color *colors, int count) { |
92bda632 TC |
517 | return i_addcolors(im, colors, count); |
518 | } | |
519 | ||
520 | /* | |
521 | =item i_getcolors(im, index, colors, count) | |
522 | ||
523 | =category Paletted images | |
524 | ||
525 | Retrieves I<count> colors starting from I<index> in the image's | |
526 | palette. | |
527 | ||
528 | On success stores the colors into I<colors> and returns true. | |
529 | ||
530 | On failure returns false. | |
531 | ||
532 | Always fails for direct color images. | |
533 | ||
534 | Fails if there are less than I<index>+I<count> colors in the image's | |
535 | palette. | |
536 | ||
537 | =cut | |
538 | */ | |
539 | ||
540 | int | |
541 | (i_getcolors)(i_img *im, int i, i_color *colors, int count) { | |
542 | return i_getcolors(im, i, colors, count); | |
543 | } | |
544 | ||
545 | /* | |
546 | =item i_colorcount(im) | |
547 | ||
548 | =category Paletted images | |
549 | ||
550 | Returns the number of colors in the image's palette. | |
551 | ||
552 | Returns -1 for direct images. | |
553 | ||
554 | =cut | |
555 | */ | |
556 | ||
557 | int | |
558 | (i_colorcount)(i_img *im) { | |
559 | return i_colorcount(im); | |
560 | } | |
561 | ||
562 | /* | |
563 | =item i_maxcolors(im) | |
564 | ||
565 | =category Paletted images | |
566 | ||
567 | Returns the maximum number of colors the palette can hold for the | |
568 | image. | |
569 | ||
570 | Returns -1 for direct color images. | |
571 | ||
572 | =cut | |
573 | */ | |
574 | ||
575 | int | |
576 | (i_maxcolors)(i_img *im) { | |
577 | return i_maxcolors(im); | |
578 | } | |
579 | ||
580 | /* | |
581 | =item i_findcolor(im, color, &entry) | |
582 | ||
583 | =category Paletted images | |
584 | ||
585 | Searches the images palette for the given color. | |
586 | ||
587 | On success sets *I<entry> to the index of the color, and returns true. | |
588 | ||
589 | On failure returns false. | |
590 | ||
591 | Always fails on direct color images. | |
592 | ||
593 | =cut | |
594 | */ | |
595 | int | |
97ac0a96 | 596 | (i_findcolor)(i_img *im, const i_color *color, i_palidx *entry) { |
92bda632 TC |
597 | return i_findcolor(im, color, entry); |
598 | } | |
599 | ||
600 | /* | |
601 | =item i_setcolors(im, index, colors, count) | |
602 | ||
603 | =category Paletted images | |
604 | ||
605 | Sets I<count> colors starting from I<index> in the image's palette. | |
606 | ||
5715f7c3 | 607 | On success returns true. |
92bda632 TC |
608 | |
609 | On failure returns false. | |
610 | ||
611 | The image must have at least I<index>+I<count> colors in it's palette | |
612 | for this to succeed. | |
613 | ||
614 | Always fails on direct color images. | |
615 | ||
616 | =cut | |
617 | */ | |
618 | int | |
97ac0a96 | 619 | (i_setcolors)(i_img *im, int index, const i_color *colors, int count) { |
92bda632 TC |
620 | return i_setcolors(im, index, colors, count); |
621 | } | |
622 | ||
44d86483 TC |
623 | /* |
624 | =item im_get_context() | |
625 | ||
626 | Retrieve the context object for the current thread. | |
627 | ||
628 | Inside Imager itself this is just a function pointer, which the | |
abffffed | 629 | F<Imager.xs> BOOT handler initializes for use within perl. If you're |
44d86483 TC |
630 | taking the Imager code and embedding it elsewhere you need to |
631 | initialize the C<im_get_context> pointer at some point. | |
632 | ||
633 | =cut | |
634 | */ | |
635 | ||
636 | static im_context_t | |
637 | get_context(void) { | |
638 | return im_get_context(); | |
639 | } | |
eac41a26 TC |
640 | |
641 | static i_img * | |
642 | mathom_i_img_8_new(i_img_dim xsize, i_img_dim ysize, int channels) { | |
643 | return i_img_8_new(xsize, ysize, channels); | |
644 | } | |
645 | ||
646 | static i_img * | |
647 | mathom_i_img_16_new(i_img_dim xsize, i_img_dim ysize, int channels) { | |
648 | return i_img_16_new(xsize, ysize, channels); | |
649 | } | |
650 | ||
651 | static i_img * | |
652 | mathom_i_img_double_new(i_img_dim xsize, i_img_dim ysize, int channels) { | |
653 | return i_img_double_new(xsize, ysize, channels); | |
654 | } | |
655 | ||
656 | static i_img * | |
657 | mathom_i_img_pal_new(i_img_dim xsize, i_img_dim ysize, int channels, | |
658 | int maxpal) { | |
659 | return i_img_pal_new(xsize, ysize, channels, maxpal); | |
660 | } | |
661 | ||
662 | static void | |
663 | mathom_i_clear_error(void) { | |
664 | i_clear_error(); | |
665 | } | |
666 | ||
667 | static void | |
668 | mathom_i_push_error(int code, const char *msg) { | |
669 | i_push_error(code, msg); | |
670 | } | |
671 | ||
672 | static void | |
673 | mathom_i_push_errorvf(int code, const char *fmt, va_list args) { | |
674 | i_push_errorvf(code, fmt, args); | |
675 | } | |
676 | ||
677 | static int | |
678 | mathom_i_set_image_file_limits(i_img_dim max_width, i_img_dim max_height, | |
679 | size_t max_bytes) { | |
680 | return i_set_image_file_limits(max_width, max_height, max_bytes); | |
681 | } | |
682 | ||
683 | static int | |
684 | mathom_i_get_image_file_limits(i_img_dim *pmax_width, i_img_dim *pmax_height, | |
685 | size_t *pmax_bytes) { | |
686 | return i_get_image_file_limits(pmax_width, pmax_height, pmax_bytes); | |
687 | } | |
688 | ||
689 | static int | |
690 | mathom_i_int_check_image_file_limits(i_img_dim width, i_img_dim height, | |
691 | int channels, size_t sample_size) { | |
692 | return i_int_check_image_file_limits(width, height, channels, sample_size); | |
693 | } | |
694 | ||
695 | static i_img * | |
696 | mathom_i_img_alloc(void) { | |
697 | return i_img_alloc(); | |
698 | } | |
699 | ||
700 | static void | |
701 | mathom_i_img_init(i_img *im) { | |
702 | i_img_init(im); | |
703 | } | |
704 | ||
705 | static i_io_glue_t * | |
706 | mathom_io_new_fd(int fd) { | |
707 | return io_new_fd(fd); | |
708 | } | |
709 | static i_io_glue_t * | |
710 | mathom_io_new_bufchain(void) { | |
711 | return io_new_bufchain(); | |
712 | } | |
713 | ||
714 | static i_io_glue_t * | |
715 | mathom_io_new_buffer(const char *data, size_t size, i_io_closebufp_t closefp, | |
716 | void *close_data) { | |
717 | return io_new_buffer(data, size, closefp, close_data); | |
718 | } | |
719 | ||
720 | static i_io_glue_t * | |
721 | mathom_io_new_cb(void *p, i_io_readl_t readcb, i_io_writel_t writecb, | |
722 | i_io_seekl_t seekcb, i_io_closel_t closecb, | |
723 | i_io_destroyl_t destroycb) { | |
724 | return io_new_cb(p, readcb, writecb, seekcb, closecb, destroycb); | |
725 | } |