Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 553 lines (401 sloc) 10.48 kb
92bda63 - start of external Imager API access:
Tony Cook authored
1 #include "imexttypes.h"
2 #include "imager.h"
50c7538 Move freetype 2 support into its own module
Tony Cook authored
3 #include "imio.h"
92bda63 - start of external Imager API access:
Tony Cook authored
4
5 /*
6 DON'T ADD CASTS TO THESE
7 */
8 im_ext_funcs imager_function_table =
9 {
d1f5892 - added version/level to the API function table structure
Tony Cook authored
10 IMAGER_API_VERSION,
11 IMAGER_API_LEVEL,
12
92bda63 - start of external Imager API access:
Tony Cook authored
13 mymalloc,
14 myfree,
15 myrealloc,
16
e310e5f - more memory allocation integer overflow auditing
Tony Cook authored
17 mymalloc_file_line,
18 myfree_file_line,
19 myrealloc_file_line,
20
d03fd5a @tonycoz revert threading changes, they aren't ready for the mainline yet
authored
21 i_img_8_new,
22 i_img_16_new,
23 i_img_double_new,
24 i_img_pal_new,
92bda63 - start of external Imager API access:
Tony Cook authored
25 i_img_destroy,
26 i_sametype,
27 i_sametype_chans,
28 i_img_info,
29
30 i_ppix,
31 i_gpix,
32 i_ppixf,
33 i_gpixf,
34 i_plin,
35 i_glin,
36 i_plinf,
37 i_glinf,
38 i_gsamp,
39 i_gsampf,
40 i_gpal,
41 i_ppal,
42 i_addcolors,
43 i_getcolors,
44 i_colorcount,
45 i_maxcolors,
46 i_findcolor,
47 i_setcolors,
48
49 i_new_fill_solid,
50 i_new_fill_solidf,
51 i_new_fill_hatch,
52 i_new_fill_hatchf,
53 i_new_fill_image,
54 i_new_fill_fount,
55 i_fill_destroy,
56
57 i_quant_makemap,
58 i_quant_translate,
59 i_quant_transparent,
60
d03fd5a @tonycoz revert threading changes, they aren't ready for the mainline yet
authored
61 i_clear_error,
62 i_push_error,
92bda63 - start of external Imager API access:
Tony Cook authored
63 i_push_errorf,
d03fd5a @tonycoz revert threading changes, they aren't ready for the mainline yet
authored
64 i_push_errorvf,
92bda63 - start of external Imager API access:
Tony Cook authored
65
66 i_tags_new,
67 i_tags_set,
68 i_tags_setn,
69 i_tags_destroy,
70 i_tags_find,
71 i_tags_findn,
72 i_tags_delete,
73 i_tags_delbyname,
74 i_tags_delbycode,
75 i_tags_get_float,
76 i_tags_set_float,
77 i_tags_set_float2,
78 i_tags_get_int,
79 i_tags_get_string,
80 i_tags_get_color,
81 i_tags_set_color,
82
83 i_box,
84 i_box_filled,
85 i_box_cfill,
86 i_line,
87 i_line_aa,
88 i_arc,
89 i_arc_aa,
90 i_arc_cfill,
91 i_arc_aa_cfill,
92 i_circle_aa,
93 i_flood_fill,
94 i_flood_cfill,
95
96 i_copyto,
97 i_copyto_trans,
98 i_copy,
99 i_rubthru,
2b405c9 add support for file write plugins
Tony Cook authored
100
101 /* IMAGER_API_LEVEL 2 functions */
d03fd5a @tonycoz revert threading changes, they aren't ready for the mainline yet
authored
102 i_set_image_file_limits,
103 i_get_image_file_limits,
104 i_int_check_image_file_limits,
3efb091 implement a flood_fill that stops at a given color rather than filling
Tony Cook authored
105
106 i_flood_fill_border,
107 i_flood_cfill_border,
d5477d3 - Finished/rewrote Arnar's old SGI RGB file format support, so Imager
Tony Cook authored
108
109 /* IMAGER_API_LEVEL 3 functions */
110 i_img_setmask,
111 i_img_getmask,
112 i_img_getchannels,
113 i_img_get_width,
114 i_img_get_height,
115 i_lhead,
bd8052a merge in tiff re-work branch
Tony Cook authored
116 i_loog,
117
118 /* IMAGER_API_LEVEL 4 functions */
d03fd5a @tonycoz revert threading changes, they aren't ready for the mainline yet
authored
119 i_img_alloc,
120 i_img_init,
e5ee047 move TIFF into its own module
Tony Cook authored
121
122 /* IMAGER_API_LEVEL 5 functions */
797a9f9 move JPEG into it's own module
Tony Cook authored
123 i_img_is_monochrome,
124 i_gsamp_bg,
125 i_gsampf_bg,
126 i_get_file_background,
718b8c9 move win32 font support in a new directory, and use Imager::Probe
Tony Cook authored
127 i_get_file_backgroundf,
50c7538 Move freetype 2 support into its own module
Tony Cook authored
128 i_utf8_advance,
129 i_render_new,
130 i_render_delete,
131 i_render_color,
132 i_render_fill,
133 i_render_line,
6d5c85a @tonycoz Merge the I/O buffering branch
authored
134 i_render_linef,
135
136 /* level 6 */
137 i_io_getc_imp,
138 i_io_peekc_imp,
139 i_io_peekn,
140 i_io_putc_imp,
141 i_io_read,
142 i_io_write,
143 i_io_seek,
144 i_io_flush,
145 i_io_close,
146 i_io_set_buffered,
147 i_io_gets,
d03fd5a @tonycoz revert threading changes, they aren't ready for the mainline yet
authored
148 io_new_fd,
149 io_new_bufchain,
150 io_new_buffer,
151 io_new_cb,
6d5c85a @tonycoz Merge the I/O buffering branch
authored
152 io_slurp,
d03fd5a @tonycoz revert threading changes, they aren't ready for the mainline yet
authored
153 io_glue_destroy
92bda63 - start of external Imager API access:
Tony Cook authored
154 };
155
156 /* in general these functions aren't called by Imager internally, but
157 only via the pointers above, since faster macros that call the
158 image vtable pointers are used.
159
160 () are used around the function names to prevent macro replacement
161 on the function names.
162 */
163
164 /*
165 =item i_ppix(im, x, y, color)
166
167 =category Drawing
168
169 Sets the pixel at (x,y) to I<color>.
170
171 Returns 0 if the pixel was drawn, or -1 if not.
172
173 Does no alpha blending, just copies the channels from the supplied
174 color to the image.
175
176 =cut
177 */
178
179 int
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
180 (i_ppix)(i_img *im, i_img_dim x, i_img_dim y, const i_color *val) {
92bda63 - start of external Imager API access:
Tony Cook authored
181 return i_ppix(im, x, y, val);
182 }
183
184 /*
5715f7c huge spelling update and spell checking patch
Tony Cook authored
185 =item i_gpix(im, C<x>, C<y>, C<color>)
92bda63 - start of external Imager API access:
Tony Cook authored
186
187 =category Drawing
188
5715f7c huge spelling update and spell checking patch
Tony Cook authored
189 Retrieves the C<color> of the pixel (x,y).
92bda63 - start of external Imager API access:
Tony Cook authored
190
191 Returns 0 if the pixel was retrieved, or -1 if not.
192
193 =cut
194 */
195
196 int
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
197 (i_gpix)(i_img *im,i_img_dim x,i_img_dim y,i_color *val) {
92bda63 - start of external Imager API access:
Tony Cook authored
198 return i_gpix(im, x, y, val);
199 }
200
201 /*
5715f7c huge spelling update and spell checking patch
Tony Cook authored
202 =item i_ppixf(im, C<x>, C<y>, C<fcolor>)
92bda63 - start of external Imager API access:
Tony Cook authored
203
204 =category Drawing
205
5715f7c huge spelling update and spell checking patch
Tony Cook authored
206 Sets the pixel at (C<x>,C<y>) to the floating point color C<fcolor>.
92bda63 - start of external Imager API access:
Tony Cook authored
207
208 Returns 0 if the pixel was drawn, or -1 if not.
209
210 Does no alpha blending, just copies the channels from the supplied
211 color to the image.
212
213 =cut
214 */
215 int
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
216 (i_ppixf)(i_img *im, i_img_dim x, i_img_dim y, const i_fcolor *val) {
92bda63 - start of external Imager API access:
Tony Cook authored
217 return i_ppixf(im, x, y, val);
218 }
219
220 /*
5715f7c huge spelling update and spell checking patch
Tony Cook authored
221 =item i_gpixf(im, C<x>, C<y>, C<fcolor>)
92bda63 - start of external Imager API access:
Tony Cook authored
222
223 =category Drawing
224
225 Retrieves the color of the pixel (x,y) as a floating point color into
5715f7c huge spelling update and spell checking patch
Tony Cook authored
226 C<fcolor>.
92bda63 - start of external Imager API access:
Tony Cook authored
227
228 Returns 0 if the pixel was retrieved, or -1 if not.
229
230 =cut
231 */
232
233 int
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
234 (i_gpixf)(i_img *im,i_img_dim x,i_img_dim y,i_fcolor *val) {
92bda63 - start of external Imager API access:
Tony Cook authored
235 return i_gpixf(im, x, y, val);
236 }
237
238 /*
239 =item i_plin(im, l, r, y, colors)
240
241 =category Drawing
242
243 Sets (r-l) pixels starting from (l,y) using (r-l) values from
244 I<colors>.
245
246 Returns the number of pixels set.
247
248 =cut
249 */
250
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
251 i_img_dim
252 (i_plin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_color *vals) {
92bda63 - start of external Imager API access:
Tony Cook authored
253 return i_plin(im, l, r, y, vals);
254 }
255
256 /*
257 =item i_glin(im, l, r, y, colors)
258
259 =category Drawing
260
261 Retrieves (r-l) pixels starting from (l,y) into I<colors>.
262
263 Returns the number of pixels retrieved.
264
265 =cut
266 */
267
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
268 i_img_dim
269 (i_glin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_color *vals) {
92bda63 - start of external Imager API access:
Tony Cook authored
270 return i_glin(im, l, r, y, vals);
271 }
272
273 /*
5715f7c huge spelling update and spell checking patch
Tony Cook authored
274 =item i_plinf(im, C<left>, C<right>, C<fcolors>)
92bda63 - start of external Imager API access:
Tony Cook authored
275
276 =category Drawing
277
5715f7c huge spelling update and spell checking patch
Tony Cook authored
278 Sets (right-left) pixels starting from (left,y) using (right-left)
279 floating point colors from C<fcolors>.
92bda63 - start of external Imager API access:
Tony Cook authored
280
281 Returns the number of pixels set.
282
283 =cut
284 */
285
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
286 i_img_dim
287 (i_plinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_fcolor *vals) {
92bda63 - start of external Imager API access:
Tony Cook authored
288 return i_plinf(im, l, r, y, vals);
289 }
290
291 /*
292 =item i_glinf(im, l, r, y, colors)
293
294 =category Drawing
295
296 Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating
297 point colors.
298
299 Returns the number of pixels retrieved.
300
301 =cut
302 */
303
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
304 i_img_dim
305 (i_glinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fcolor *vals) {
92bda63 - start of external Imager API access:
Tony Cook authored
306 return i_glinf(im, l, r, y, vals);
307 }
308
309 /*
5715f7c huge spelling update and spell checking patch
Tony Cook authored
310 =item i_gsamp(im, left, right, y, samples, channels, channel_count)
92bda63 - start of external Imager API access:
Tony Cook authored
311
312 =category Drawing
313
5715f7c huge spelling update and spell checking patch
Tony Cook authored
314 Reads sample values from C<im> for the horizontal line (left, y) to
315 (right-1,y) for the channels specified by C<channels>, an array of int
316 with C<channel_count> elements.
92bda63 - start of external Imager API access:
Tony Cook authored
317
5715f7c huge spelling update and spell checking patch
Tony Cook authored
318 If channels is NULL then the first channels_count channels are retrieved for
92bda63 - start of external Imager API access:
Tony Cook authored
319 each pixel.
320
5715f7c huge spelling update and spell checking patch
Tony Cook authored
321 Returns the number of samples read (which should be (right-left) *
322 channel_count)
92bda63 - start of external Imager API access:
Tony Cook authored
323
324 =cut
325 */
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
326 i_img_dim
327 (i_gsamp)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_sample_t *samp,
92bda63 - start of external Imager API access:
Tony Cook authored
328 const int *chans, int chan_count) {
329 return i_gsamp(im, l, r, y, samp, chans, chan_count);
330 }
331
332 /*
5715f7c huge spelling update and spell checking patch
Tony Cook authored
333 =item i_gsampf(im, left, right, y, samples, channels, channel_count)
92bda63 - start of external Imager API access:
Tony Cook authored
334
335 =category Drawing
336
5715f7c huge spelling update and spell checking patch
Tony Cook authored
337 Reads floating point sample values from C<im> for the horizontal line
338 (left, y) to (right-1,y) for the channels specified by C<channels>, an
339 array of int with channel_count elements.
92bda63 - start of external Imager API access:
Tony Cook authored
340
5715f7c huge spelling update and spell checking patch
Tony Cook authored
341 If C<channels> is NULL then the first C<channel_count> channels are
342 retrieved for each pixel.
92bda63 - start of external Imager API access:
Tony Cook authored
343
5715f7c huge spelling update and spell checking patch
Tony Cook authored
344 Returns the number of samples read (which should be (C<right>-C<left>)
345 * C<channel_count>)
92bda63 - start of external Imager API access:
Tony Cook authored
346
347 =cut
348 */
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
349 i_img_dim
350 (i_gsampf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samp,
92bda63 - start of external Imager API access:
Tony Cook authored
351 const int *chans, int chan_count) {
352 return i_gsampf(im, l, r, y, samp, chans, chan_count);
353 }
354
355 /*
48095bd @tonycoz [rt #68815] document i_psamp_bits() and i_gsamp_bits()
authored
356 =item i_gsamp_bits(im, left, right, y, samples, channels, channel_count, bits)
357 =category Drawing
358
359 Reads integer samples scaled to C<bits> bits of precision into the
360 C<unsigned int> array C<samples>.
361
362 Expect this to be slow unless C<< bits == im->bits >>.
363
364 Returns the number of samples copied, or -1 on error.
365
366 Not all image types implement this method.
367
368 Pushes errors, but does not call C<i_clear_error()>.
369
370 =cut
371 */
372
373 /*
374 =item i_psamp_bits(im, left, right, y, samples, channels, channel_count, bits)
375 =category Drawing
376
377 Writes integer samples scaled to C<bits> bits of precision from the
378 C<unsigned int> array C<samples>.
379
380 Expect this to be slow unless C<< bits == im->bits >>.
381
382 Returns the number of samples copied, or -1 on error.
383
384 Not all image types implement this method.
385
386 Pushes errors, but does not call C<i_clear_error()>.
387
388 =cut
389 */
390
391 /*
5715f7c huge spelling update and spell checking patch
Tony Cook authored
392 =item i_gpal(im, left, right, y, indexes)
92bda63 - start of external Imager API access:
Tony Cook authored
393
394 =category Drawing
395
5715f7c huge spelling update and spell checking patch
Tony Cook authored
396 Reads palette indexes for the horizontal line (left, y) to (right-1,
397 y) into C<indexes>.
92bda63 - start of external Imager API access:
Tony Cook authored
398
399 Returns the number of indexes read.
400
401 Always returns 0 for direct color images.
402
403 =cut
404 */
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
405 i_img_dim
406 (i_gpal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, i_palidx *vals) {
92bda63 - start of external Imager API access:
Tony Cook authored
407 return i_gpal(im, x, r, y, vals);
408 }
409
410 /*
5715f7c huge spelling update and spell checking patch
Tony Cook authored
411 =item i_ppal(im, left, right, y, indexes)
92bda63 - start of external Imager API access:
Tony Cook authored
412
413 =category Drawing
414
5715f7c huge spelling update and spell checking patch
Tony Cook authored
415 Writes palette indexes for the horizontal line (left, y) to (right-1,
416 y) from C<indexes>.
92bda63 - start of external Imager API access:
Tony Cook authored
417
418 Returns the number of indexes written.
419
420 Always returns 0 for direct color images.
421
422 =cut
423 */
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
424 i_img_dim
425 (i_ppal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, const i_palidx *vals) {
92bda63 - start of external Imager API access:
Tony Cook authored
426 return i_ppal(im, x, r, y, vals);
427 }
428
429 /*
430 =item i_addcolors(im, colors, count)
431
432 =category Paletted images
433
434 Adds colors to the image's palette.
435
436 On success returns the index of the lowest color added.
437
438 On failure returns -1.
439
440 Always fails for direct color images.
441
442 =cut
443 */
444
445 int
97ac0a9 - constify the Imager API
Tony Cook authored
446 (i_addcolors)(i_img *im, const i_color *colors, int count) {
92bda63 - start of external Imager API access:
Tony Cook authored
447 return i_addcolors(im, colors, count);
448 }
449
450 /*
451 =item i_getcolors(im, index, colors, count)
452
453 =category Paletted images
454
455 Retrieves I<count> colors starting from I<index> in the image's
456 palette.
457
458 On success stores the colors into I<colors> and returns true.
459
460 On failure returns false.
461
462 Always fails for direct color images.
463
464 Fails if there are less than I<index>+I<count> colors in the image's
465 palette.
466
467 =cut
468 */
469
470 int
471 (i_getcolors)(i_img *im, int i, i_color *colors, int count) {
472 return i_getcolors(im, i, colors, count);
473 }
474
475 /*
476 =item i_colorcount(im)
477
478 =category Paletted images
479
480 Returns the number of colors in the image's palette.
481
482 Returns -1 for direct images.
483
484 =cut
485 */
486
487 int
488 (i_colorcount)(i_img *im) {
489 return i_colorcount(im);
490 }
491
492 /*
493 =item i_maxcolors(im)
494
495 =category Paletted images
496
497 Returns the maximum number of colors the palette can hold for the
498 image.
499
500 Returns -1 for direct color images.
501
502 =cut
503 */
504
505 int
506 (i_maxcolors)(i_img *im) {
507 return i_maxcolors(im);
508 }
509
510 /*
511 =item i_findcolor(im, color, &entry)
512
513 =category Paletted images
514
515 Searches the images palette for the given color.
516
517 On success sets *I<entry> to the index of the color, and returns true.
518
519 On failure returns false.
520
521 Always fails on direct color images.
522
523 =cut
524 */
525 int
97ac0a9 - constify the Imager API
Tony Cook authored
526 (i_findcolor)(i_img *im, const i_color *color, i_palidx *entry) {
92bda63 - start of external Imager API access:
Tony Cook authored
527 return i_findcolor(im, color, entry);
528 }
529
530 /*
531 =item i_setcolors(im, index, colors, count)
532
533 =category Paletted images
534
535 Sets I<count> colors starting from I<index> in the image's palette.
536
5715f7c huge spelling update and spell checking patch
Tony Cook authored
537 On success returns true.
92bda63 - start of external Imager API access:
Tony Cook authored
538
539 On failure returns false.
540
541 The image must have at least I<index>+I<count> colors in it's palette
542 for this to succeed.
543
544 Always fails on direct color images.
545
546 =cut
547 */
548 int
97ac0a9 - constify the Imager API
Tony Cook authored
549 (i_setcolors)(i_img *im, int index, const i_color *colors, int count) {
92bda63 - start of external Imager API access:
Tony Cook authored
550 return i_setcolors(im, index, colors, count);
551 }
552
Something went wrong with that request. Please try again.