1 #include "imexttypes.h"
5 static im_context_t get_context(void);
8 DON'T ADD CASTS TO THESE
10 im_ext_funcs imager_function_table =
103 /* IMAGER_API_LEVEL 2 functions */
104 im_set_image_file_limits,
105 im_get_image_file_limits,
106 im_int_check_image_file_limits,
109 i_flood_cfill_border,
111 /* IMAGER_API_LEVEL 3 functions */
120 /* IMAGER_API_LEVEL 4 functions */
124 /* IMAGER_API_LEVEL 5 functions */
128 i_get_file_background,
129 i_get_file_backgroundf,
174 /* in general these functions aren't called by Imager internally, but
175 only via the pointers above, since faster macros that call the
176 image vtable pointers are used.
178 () are used around the function names to prevent macro replacement
179 on the function names.
183 =item i_ppix(im, x, y, color)
187 Sets the pixel at (x,y) to I<color>.
189 Returns 0 if the pixel was drawn, or -1 if not.
191 Does no alpha blending, just copies the channels from the supplied
198 (i_ppix)(i_img *im, i_img_dim x, i_img_dim y, const i_color *val) {
199 return i_ppix(im, x, y, val);
203 =item i_gpix(im, C<x>, C<y>, C<color>)
207 Retrieves the C<color> of the pixel (x,y).
209 Returns 0 if the pixel was retrieved, or -1 if not.
215 (i_gpix)(i_img *im,i_img_dim x,i_img_dim y,i_color *val) {
216 return i_gpix(im, x, y, val);
220 =item i_ppixf(im, C<x>, C<y>, C<fcolor>)
224 Sets the pixel at (C<x>,C<y>) to the floating point color C<fcolor>.
226 Returns 0 if the pixel was drawn, or -1 if not.
228 Does no alpha blending, just copies the channels from the supplied
234 (i_ppixf)(i_img *im, i_img_dim x, i_img_dim y, const i_fcolor *val) {
235 return i_ppixf(im, x, y, val);
239 =item i_gpixf(im, C<x>, C<y>, C<fcolor>)
243 Retrieves the color of the pixel (x,y) as a floating point color into
246 Returns 0 if the pixel was retrieved, or -1 if not.
252 (i_gpixf)(i_img *im,i_img_dim x,i_img_dim y,i_fcolor *val) {
253 return i_gpixf(im, x, y, val);
257 =item i_plin(im, l, r, y, colors)
261 Sets (r-l) pixels starting from (l,y) using (r-l) values from
264 Returns the number of pixels set.
270 (i_plin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_color *vals) {
271 return i_plin(im, l, r, y, vals);
275 =item i_glin(im, l, r, y, colors)
279 Retrieves (r-l) pixels starting from (l,y) into I<colors>.
281 Returns the number of pixels retrieved.
287 (i_glin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_color *vals) {
288 return i_glin(im, l, r, y, vals);
292 =item i_plinf(im, C<left>, C<right>, C<fcolors>)
296 Sets (right-left) pixels starting from (left,y) using (right-left)
297 floating point colors from C<fcolors>.
299 Returns the number of pixels set.
305 (i_plinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_fcolor *vals) {
306 return i_plinf(im, l, r, y, vals);
310 =item i_glinf(im, l, r, y, colors)
314 Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating
317 Returns the number of pixels retrieved.
323 (i_glinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fcolor *vals) {
324 return i_glinf(im, l, r, y, vals);
328 =item i_gsamp(im, left, right, y, samples, channels, channel_count)
332 Reads sample values from C<im> for the horizontal line (left, y) to
333 (right-1,y) for the channels specified by C<channels>, an array of int
334 with C<channel_count> elements.
336 If channels is NULL then the first channels_count channels are retrieved for
339 Returns the number of samples read (which should be (right-left) *
345 (i_gsamp)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_sample_t *samp,
346 const int *chans, int chan_count) {
347 return i_gsamp(im, l, r, y, samp, chans, chan_count);
351 =item i_gsampf(im, left, right, y, samples, channels, channel_count)
355 Reads floating point sample values from C<im> for the horizontal line
356 (left, y) to (right-1,y) for the channels specified by C<channels>, an
357 array of int with channel_count elements.
359 If C<channels> is NULL then the first C<channel_count> channels are
360 retrieved for each pixel.
362 Returns the number of samples read (which should be (C<right>-C<left>)
368 (i_gsampf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samp,
369 const int *chans, int chan_count) {
370 return i_gsampf(im, l, r, y, samp, chans, chan_count);
374 =item i_gsamp_bits(im, left, right, y, samples, channels, channel_count, bits)
377 Reads integer samples scaled to C<bits> bits of precision into the
378 C<unsigned int> array C<samples>.
380 Expect this to be slow unless C<< bits == im->bits >>.
382 Returns the number of samples copied, or -1 on error.
384 Not all image types implement this method.
386 Pushes errors, but does not call C<i_clear_error()>.
392 =item i_psamp_bits(im, left, right, y, samples, channels, channel_count, bits)
395 Writes integer samples scaled to C<bits> bits of precision from the
396 C<unsigned int> array C<samples>.
398 Expect this to be slow unless C<< bits == im->bits >>.
400 Returns the number of samples copied, or -1 on error.
402 Not all image types implement this method.
404 Pushes errors, but does not call C<i_clear_error()>.
410 =item i_gpal(im, left, right, y, indexes)
414 Reads palette indexes for the horizontal line (left, y) to (right-1,
417 Returns the number of indexes read.
419 Always returns 0 for direct color images.
424 (i_gpal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, i_palidx *vals) {
425 return i_gpal(im, x, r, y, vals);
429 =item i_ppal(im, left, right, y, indexes)
433 Writes palette indexes for the horizontal line (left, y) to (right-1,
436 Returns the number of indexes written.
438 Always returns 0 for direct color images.
443 (i_ppal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, const i_palidx *vals) {
444 return i_ppal(im, x, r, y, vals);
448 =item i_addcolors(im, colors, count)
450 =category Paletted images
452 Adds colors to the image's palette.
454 On success returns the index of the lowest color added.
456 On failure returns -1.
458 Always fails for direct color images.
464 (i_addcolors)(i_img *im, const i_color *colors, int count) {
465 return i_addcolors(im, colors, count);
469 =item i_getcolors(im, index, colors, count)
471 =category Paletted images
473 Retrieves I<count> colors starting from I<index> in the image's
476 On success stores the colors into I<colors> and returns true.
478 On failure returns false.
480 Always fails for direct color images.
482 Fails if there are less than I<index>+I<count> colors in the image's
489 (i_getcolors)(i_img *im, int i, i_color *colors, int count) {
490 return i_getcolors(im, i, colors, count);
494 =item i_colorcount(im)
496 =category Paletted images
498 Returns the number of colors in the image's palette.
500 Returns -1 for direct images.
506 (i_colorcount)(i_img *im) {
507 return i_colorcount(im);
511 =item i_maxcolors(im)
513 =category Paletted images
515 Returns the maximum number of colors the palette can hold for the
518 Returns -1 for direct color images.
524 (i_maxcolors)(i_img *im) {
525 return i_maxcolors(im);
529 =item i_findcolor(im, color, &entry)
531 =category Paletted images
533 Searches the images palette for the given color.
535 On success sets *I<entry> to the index of the color, and returns true.
537 On failure returns false.
539 Always fails on direct color images.
544 (i_findcolor)(i_img *im, const i_color *color, i_palidx *entry) {
545 return i_findcolor(im, color, entry);
549 =item i_setcolors(im, index, colors, count)
551 =category Paletted images
553 Sets I<count> colors starting from I<index> in the image's palette.
555 On success returns true.
557 On failure returns false.
559 The image must have at least I<index>+I<count> colors in it's palette
562 Always fails on direct color images.
567 (i_setcolors)(i_img *im, int index, const i_color *colors, int count) {
568 return i_setcolors(im, index, colors, count);
572 =item im_get_context()
574 Retrieve the context object for the current thread.
576 Inside Imager itself this is just a function pointer, which the
577 F<Imager.xs> BOOT handler initializes for use within perl. If you're
578 taking the Imager code and embedding it elsewhere you need to
579 initialize the C<im_get_context> pointer at some point.
586 return im_get_context();