]> git.imager.perl.org - imager.git/blame - imext.c
- fix spelling errors patched by Debian (please report the issues you
[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,
d5477d3d
TC
107
108 /* IMAGER_API_LEVEL 3 functions */
109 i_img_setmask,
110 i_img_getmask,
111 i_img_getchannels,
112 i_img_get_width,
113 i_img_get_height,
114 i_lhead,
bd8052a6
TC
115 i_loog,
116
117 /* IMAGER_API_LEVEL 4 functions */
118 i_img_alloc,
119 i_img_init,
92bda632
TC
120 };
121
122/* in general these functions aren't called by Imager internally, but
123 only via the pointers above, since faster macros that call the
124 image vtable pointers are used.
125
126 () are used around the function names to prevent macro replacement
127 on the function names.
128*/
129
130/*
131=item i_ppix(im, x, y, color)
132
133=category Drawing
134
135Sets the pixel at (x,y) to I<color>.
136
137Returns 0 if the pixel was drawn, or -1 if not.
138
139Does no alpha blending, just copies the channels from the supplied
140color to the image.
141
142=cut
143*/
144
145int
97ac0a96 146(i_ppix)(i_img *im, int x, int y, const i_color *val) {
92bda632
TC
147 return i_ppix(im, x, y, val);
148}
149
150/*
151=item i_gpix(im, x, y, color)
152
153=category Drawing
154
155Retrieves the I<color> of the pixel (x,y).
156
157Returns 0 if the pixel was retrieved, or -1 if not.
158
159=cut
160*/
161
162int
163(i_gpix)(i_img *im,int x,int y,i_color *val) {
164 return i_gpix(im, x, y, val);
165}
166
167/*
168=item i_ppixf(im, x, y, fcolor)
169
170=category Drawing
171
172Sets the pixel at (x,y) to the floating point color I<fcolor>.
173
174Returns 0 if the pixel was drawn, or -1 if not.
175
176Does no alpha blending, just copies the channels from the supplied
177color to the image.
178
179=cut
180*/
181int
97ac0a96 182(i_ppixf)(i_img *im, int x, int y, const i_fcolor *val) {
92bda632
TC
183 return i_ppixf(im, x, y, val);
184}
185
186/*
187=item i_gpixf(im, x, y, fcolor)
188
189=category Drawing
190
191Retrieves the color of the pixel (x,y) as a floating point color into
192I<fcolor>.
193
194Returns 0 if the pixel was retrieved, or -1 if not.
195
196=cut
197*/
198
199int
200(i_gpixf)(i_img *im,int x,int y,i_fcolor *val) {
201 return i_gpixf(im, x, y, val);
202}
203
204/*
205=item i_plin(im, l, r, y, colors)
206
207=category Drawing
208
209Sets (r-l) pixels starting from (l,y) using (r-l) values from
210I<colors>.
211
212Returns the number of pixels set.
213
214=cut
215*/
216
217int
97ac0a96 218(i_plin)(i_img *im, int l, int r, int y, const i_color *vals) {
92bda632
TC
219 return i_plin(im, l, r, y, vals);
220}
221
222/*
223=item i_glin(im, l, r, y, colors)
224
225=category Drawing
226
227Retrieves (r-l) pixels starting from (l,y) into I<colors>.
228
229Returns the number of pixels retrieved.
230
231=cut
232*/
233
234int
235(i_glin)(i_img *im, int l, int r, int y, i_color *vals) {
236 return i_glin(im, l, r, y, vals);
237}
238
239/*
240=item i_plinf(im, l, r, fcolors)
241
242=category Drawing
243
244Sets (r-l) pixels starting from (l,y) using (r-l) floating point
245colors from I<colors>.
246
247Returns the number of pixels set.
248
249=cut
250*/
251
252int
97ac0a96 253(i_plinf)(i_img *im, int l, int r, int y, const i_fcolor *vals) {
92bda632
TC
254 return i_plinf(im, l, r, y, vals);
255}
256
257/*
258=item i_glinf(im, l, r, y, colors)
259
260=category Drawing
261
262Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating
263point colors.
264
265Returns the number of pixels retrieved.
266
267=cut
268*/
269
270int
271(i_glinf)(i_img *im, int l, int r, int y, i_fcolor *vals) {
272 return i_glinf(im, l, r, y, vals);
273}
274
275/*
276=item i_gsamp(im, l, r, y, samp, chans, chan_count)
277
278=category Drawing
279
280Reads sample values from im for the horizontal line (l, y) to (r-1,y)
281for the channels specified by chans, an array of int with chan_count
282elements.
283
284If chans is NULL then the first chan_count channels are retrieved for
285each pixel.
286
287Returns the number of samples read (which should be (r-l) *
288chan_count)
289
290=cut
291*/
292int
293(i_gsamp)(i_img *im, int l, int r, int y, i_sample_t *samp,
294 const int *chans, int chan_count) {
295 return i_gsamp(im, l, r, y, samp, chans, chan_count);
296}
297
298/*
299=item i_gsampf(im, l, r, y, samp, chans, chan_count)
300
301=category Drawing
302
303Reads floating point sample values from im for the horizontal line (l,
304y) to (r-1,y) for the channels specified by chans, an array of int
305with chan_count elements.
306
307If chans is NULL then the first chan_count channels are retrieved for
308each pixel.
309
310Returns the number of samples read (which should be (r-l) *
311chan_count)
312
313=cut
314*/
315int
316(i_gsampf)(i_img *im, int l, int r, int y, i_fsample_t *samp,
317 const int *chans, int chan_count) {
318 return i_gsampf(im, l, r, y, samp, chans, chan_count);
319}
320
321/*
322=item i_gpal(im, x, r, y, indexes)
323
324=category Drawing
325
326Reads palette indexes for the horizontal line (x, y) to (r-1, y) into
327indexes.
328
329Returns the number of indexes read.
330
331Always returns 0 for direct color images.
332
333=cut
334*/
335int
336(i_gpal)(i_img *im, int x, int r, int y, i_palidx *vals) {
337 return i_gpal(im, x, r, y, vals);
338}
339
340/*
341=item i_ppal(im, x, r, y, indexes)
342
343=category Drawing
344
345Writes palette indexes for the horizontal line (x, y) to (r-1, y) from
346indexes.
347
348Returns the number of indexes written.
349
350Always returns 0 for direct color images.
351
352=cut
353*/
354int
97ac0a96 355(i_ppal)(i_img *im, int x, int r, int y, const i_palidx *vals) {
92bda632
TC
356 return i_ppal(im, x, r, y, vals);
357}
358
359/*
360=item i_addcolors(im, colors, count)
361
362=category Paletted images
363
364Adds colors to the image's palette.
365
366On success returns the index of the lowest color added.
367
368On failure returns -1.
369
370Always fails for direct color images.
371
372=cut
373*/
374
375int
97ac0a96 376(i_addcolors)(i_img *im, const i_color *colors, int count) {
92bda632
TC
377 return i_addcolors(im, colors, count);
378}
379
380/*
381=item i_getcolors(im, index, colors, count)
382
383=category Paletted images
384
385Retrieves I<count> colors starting from I<index> in the image's
386palette.
387
388On success stores the colors into I<colors> and returns true.
389
390On failure returns false.
391
392Always fails for direct color images.
393
394Fails if there are less than I<index>+I<count> colors in the image's
395palette.
396
397=cut
398*/
399
400int
401(i_getcolors)(i_img *im, int i, i_color *colors, int count) {
402 return i_getcolors(im, i, colors, count);
403}
404
405/*
406=item i_colorcount(im)
407
408=category Paletted images
409
410Returns the number of colors in the image's palette.
411
412Returns -1 for direct images.
413
414=cut
415*/
416
417int
418(i_colorcount)(i_img *im) {
419 return i_colorcount(im);
420}
421
422/*
423=item i_maxcolors(im)
424
425=category Paletted images
426
427Returns the maximum number of colors the palette can hold for the
428image.
429
430Returns -1 for direct color images.
431
432=cut
433*/
434
435int
436(i_maxcolors)(i_img *im) {
437 return i_maxcolors(im);
438}
439
440/*
441=item i_findcolor(im, color, &entry)
442
443=category Paletted images
444
445Searches the images palette for the given color.
446
447On success sets *I<entry> to the index of the color, and returns true.
448
449On failure returns false.
450
451Always fails on direct color images.
452
453=cut
454*/
455int
97ac0a96 456(i_findcolor)(i_img *im, const i_color *color, i_palidx *entry) {
92bda632
TC
457 return i_findcolor(im, color, entry);
458}
459
460/*
461=item i_setcolors(im, index, colors, count)
462
463=category Paletted images
464
465Sets I<count> colors starting from I<index> in the image's palette.
466
467On sucess returns true.
468
469On failure returns false.
470
471The image must have at least I<index>+I<count> colors in it's palette
472for this to succeed.
473
474Always fails on direct color images.
475
476=cut
477*/
478int
97ac0a96 479(i_setcolors)(i_img *im, int index, const i_color *colors, int count) {
92bda632
TC
480 return i_setcolors(im, index, colors, count);
481}
482