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