distribute Imager::LargeSamples
[imager.git] / imext.c
CommitLineData
92bda632
TC
1#include "imexttypes.h"
2#include "imager.h"
3
4/*
5 DON'T ADD CASTS TO THESE
6*/
7im_ext_funcs imager_function_table =
8 {
d1f5892c
TC
9 IMAGER_API_VERSION,
10 IMAGER_API_LEVEL,
11
92bda632
TC
12 mymalloc,
13 myfree,
14 myrealloc,
15
e310e5f9
TC
16 mymalloc_file_line,
17 myfree_file_line,
18 myrealloc_file_line,
19
92bda632
TC
20 i_img_8_new,
21 i_img_16_new,
22 i_img_double_new,
23 i_img_pal_new,
24 i_img_destroy,
25 i_sametype,
26 i_sametype_chans,
27 i_img_info,
28
29 i_ppix,
30 i_gpix,
31 i_ppixf,
32 i_gpixf,
33 i_plin,
34 i_glin,
35 i_plinf,
36 i_glinf,
37 i_gsamp,
38 i_gsampf,
39 i_gpal,
40 i_ppal,
41 i_addcolors,
42 i_getcolors,
43 i_colorcount,
44 i_maxcolors,
45 i_findcolor,
46 i_setcolors,
47
48 i_new_fill_solid,
49 i_new_fill_solidf,
50 i_new_fill_hatch,
51 i_new_fill_hatchf,
52 i_new_fill_image,
53 i_new_fill_fount,
54 i_fill_destroy,
55
56 i_quant_makemap,
57 i_quant_translate,
58 i_quant_transparent,
59
60 i_clear_error,
61 i_push_error,
62 i_push_errorf,
63 i_push_errorvf,
64
65 i_tags_new,
66 i_tags_set,
67 i_tags_setn,
68 i_tags_destroy,
69 i_tags_find,
70 i_tags_findn,
71 i_tags_delete,
72 i_tags_delbyname,
73 i_tags_delbycode,
74 i_tags_get_float,
75 i_tags_set_float,
76 i_tags_set_float2,
77 i_tags_get_int,
78 i_tags_get_string,
79 i_tags_get_color,
80 i_tags_set_color,
81
82 i_box,
83 i_box_filled,
84 i_box_cfill,
85 i_line,
86 i_line_aa,
87 i_arc,
88 i_arc_aa,
89 i_arc_cfill,
90 i_arc_aa_cfill,
91 i_circle_aa,
92 i_flood_fill,
93 i_flood_cfill,
94
95 i_copyto,
96 i_copyto_trans,
97 i_copy,
98 i_rubthru,
2b405c9e
TC
99
100 /* IMAGER_API_LEVEL 2 functions */
101 i_set_image_file_limits,
102 i_get_image_file_limits,
103 i_int_check_image_file_limits,
3efb0915
TC
104
105 i_flood_fill_border,
106 i_flood_cfill_border,
92bda632
TC
107 };
108
109/* in general these functions aren't called by Imager internally, but
110 only via the pointers above, since faster macros that call the
111 image vtable pointers are used.
112
113 () are used around the function names to prevent macro replacement
114 on the function names.
115*/
116
117/*
118=item i_ppix(im, x, y, color)
119
120=category Drawing
121
122Sets the pixel at (x,y) to I<color>.
123
124Returns 0 if the pixel was drawn, or -1 if not.
125
126Does no alpha blending, just copies the channels from the supplied
127color to the image.
128
129=cut
130*/
131
132int
97ac0a96 133(i_ppix)(i_img *im, int x, int y, const i_color *val) {
92bda632
TC
134 return i_ppix(im, x, y, val);
135}
136
137/*
138=item i_gpix(im, x, y, color)
139
140=category Drawing
141
142Retrieves the I<color> of the pixel (x,y).
143
144Returns 0 if the pixel was retrieved, or -1 if not.
145
146=cut
147*/
148
149int
150(i_gpix)(i_img *im,int x,int y,i_color *val) {
151 return i_gpix(im, x, y, val);
152}
153
154/*
155=item i_ppixf(im, x, y, fcolor)
156
157=category Drawing
158
159Sets the pixel at (x,y) to the floating point color I<fcolor>.
160
161Returns 0 if the pixel was drawn, or -1 if not.
162
163Does no alpha blending, just copies the channels from the supplied
164color to the image.
165
166=cut
167*/
168int
97ac0a96 169(i_ppixf)(i_img *im, int x, int y, const i_fcolor *val) {
92bda632
TC
170 return i_ppixf(im, x, y, val);
171}
172
173/*
174=item i_gpixf(im, x, y, fcolor)
175
176=category Drawing
177
178Retrieves the color of the pixel (x,y) as a floating point color into
179I<fcolor>.
180
181Returns 0 if the pixel was retrieved, or -1 if not.
182
183=cut
184*/
185
186int
187(i_gpixf)(i_img *im,int x,int y,i_fcolor *val) {
188 return i_gpixf(im, x, y, val);
189}
190
191/*
192=item i_plin(im, l, r, y, colors)
193
194=category Drawing
195
196Sets (r-l) pixels starting from (l,y) using (r-l) values from
197I<colors>.
198
199Returns the number of pixels set.
200
201=cut
202*/
203
204int
97ac0a96 205(i_plin)(i_img *im, int l, int r, int y, const i_color *vals) {
92bda632
TC
206 return i_plin(im, l, r, y, vals);
207}
208
209/*
210=item i_glin(im, l, r, y, colors)
211
212=category Drawing
213
214Retrieves (r-l) pixels starting from (l,y) into I<colors>.
215
216Returns the number of pixels retrieved.
217
218=cut
219*/
220
221int
222(i_glin)(i_img *im, int l, int r, int y, i_color *vals) {
223 return i_glin(im, l, r, y, vals);
224}
225
226/*
227=item i_plinf(im, l, r, fcolors)
228
229=category Drawing
230
231Sets (r-l) pixels starting from (l,y) using (r-l) floating point
232colors from I<colors>.
233
234Returns the number of pixels set.
235
236=cut
237*/
238
239int
97ac0a96 240(i_plinf)(i_img *im, int l, int r, int y, const i_fcolor *vals) {
92bda632
TC
241 return i_plinf(im, l, r, y, vals);
242}
243
244/*
245=item i_glinf(im, l, r, y, colors)
246
247=category Drawing
248
249Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating
250point colors.
251
252Returns the number of pixels retrieved.
253
254=cut
255*/
256
257int
258(i_glinf)(i_img *im, int l, int r, int y, i_fcolor *vals) {
259 return i_glinf(im, l, r, y, vals);
260}
261
262/*
263=item i_gsamp(im, l, r, y, samp, chans, chan_count)
264
265=category Drawing
266
267Reads sample values from im for the horizontal line (l, y) to (r-1,y)
268for the channels specified by chans, an array of int with chan_count
269elements.
270
271If chans is NULL then the first chan_count channels are retrieved for
272each pixel.
273
274Returns the number of samples read (which should be (r-l) *
275chan_count)
276
277=cut
278*/
279int
280(i_gsamp)(i_img *im, int l, int r, int y, i_sample_t *samp,
281 const int *chans, int chan_count) {
282 return i_gsamp(im, l, r, y, samp, chans, chan_count);
283}
284
285/*
286=item i_gsampf(im, l, r, y, samp, chans, chan_count)
287
288=category Drawing
289
290Reads floating point sample values from im for the horizontal line (l,
291y) to (r-1,y) for the channels specified by chans, an array of int
292with chan_count elements.
293
294If chans is NULL then the first chan_count channels are retrieved for
295each pixel.
296
297Returns the number of samples read (which should be (r-l) *
298chan_count)
299
300=cut
301*/
302int
303(i_gsampf)(i_img *im, int l, int r, int y, i_fsample_t *samp,
304 const int *chans, int chan_count) {
305 return i_gsampf(im, l, r, y, samp, chans, chan_count);
306}
307
308/*
309=item i_gpal(im, x, r, y, indexes)
310
311=category Drawing
312
313Reads palette indexes for the horizontal line (x, y) to (r-1, y) into
314indexes.
315
316Returns the number of indexes read.
317
318Always returns 0 for direct color images.
319
320=cut
321*/
322int
323(i_gpal)(i_img *im, int x, int r, int y, i_palidx *vals) {
324 return i_gpal(im, x, r, y, vals);
325}
326
327/*
328=item i_ppal(im, x, r, y, indexes)
329
330=category Drawing
331
332Writes palette indexes for the horizontal line (x, y) to (r-1, y) from
333indexes.
334
335Returns the number of indexes written.
336
337Always returns 0 for direct color images.
338
339=cut
340*/
341int
97ac0a96 342(i_ppal)(i_img *im, int x, int r, int y, const i_palidx *vals) {
92bda632
TC
343 return i_ppal(im, x, r, y, vals);
344}
345
346/*
347=item i_addcolors(im, colors, count)
348
349=category Paletted images
350
351Adds colors to the image's palette.
352
353On success returns the index of the lowest color added.
354
355On failure returns -1.
356
357Always fails for direct color images.
358
359=cut
360*/
361
362int
97ac0a96 363(i_addcolors)(i_img *im, const i_color *colors, int count) {
92bda632
TC
364 return i_addcolors(im, colors, count);
365}
366
367/*
368=item i_getcolors(im, index, colors, count)
369
370=category Paletted images
371
372Retrieves I<count> colors starting from I<index> in the image's
373palette.
374
375On success stores the colors into I<colors> and returns true.
376
377On failure returns false.
378
379Always fails for direct color images.
380
381Fails if there are less than I<index>+I<count> colors in the image's
382palette.
383
384=cut
385*/
386
387int
388(i_getcolors)(i_img *im, int i, i_color *colors, int count) {
389 return i_getcolors(im, i, colors, count);
390}
391
392/*
393=item i_colorcount(im)
394
395=category Paletted images
396
397Returns the number of colors in the image's palette.
398
399Returns -1 for direct images.
400
401=cut
402*/
403
404int
405(i_colorcount)(i_img *im) {
406 return i_colorcount(im);
407}
408
409/*
410=item i_maxcolors(im)
411
412=category Paletted images
413
414Returns the maximum number of colors the palette can hold for the
415image.
416
417Returns -1 for direct color images.
418
419=cut
420*/
421
422int
423(i_maxcolors)(i_img *im) {
424 return i_maxcolors(im);
425}
426
427/*
428=item i_findcolor(im, color, &entry)
429
430=category Paletted images
431
432Searches the images palette for the given color.
433
434On success sets *I<entry> to the index of the color, and returns true.
435
436On failure returns false.
437
438Always fails on direct color images.
439
440=cut
441*/
442int
97ac0a96 443(i_findcolor)(i_img *im, const i_color *color, i_palidx *entry) {
92bda632
TC
444 return i_findcolor(im, color, entry);
445}
446
447/*
448=item i_setcolors(im, index, colors, count)
449
450=category Paletted images
451
452Sets I<count> colors starting from I<index> in the image's palette.
453
454On sucess returns true.
455
456On failure returns false.
457
458The image must have at least I<index>+I<count> colors in it's palette
459for this to succeed.
460
461Always fails on direct color images.
462
463=cut
464*/
465int
97ac0a96 466(i_setcolors)(i_img *im, int index, const i_color *colors, int count) {
92bda632
TC
467 return i_setcolors(im, index, colors, count);
468}
469