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