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,
160 /* in general these functions aren't called by Imager internally, but
161 only via the pointers above, since faster macros that call the
162 image vtable pointers are used.
164 () are used around the function names to prevent macro replacement
165 on the function names.
169 =item i_ppix(im, x, y, color)
173 Sets the pixel at (x,y) to I<color>.
175 Returns 0 if the pixel was drawn, or -1 if not.
177 Does no alpha blending, just copies the channels from the supplied
184 (i_ppix)(i_img *im, i_img_dim x, i_img_dim y, const i_color *val) {
185 return i_ppix(im, x, y, val);
189 =item i_gpix(im, C<x>, C<y>, C<color>)
193 Retrieves the C<color> of the pixel (x,y).
195 Returns 0 if the pixel was retrieved, or -1 if not.
201 (i_gpix)(i_img *im,i_img_dim x,i_img_dim y,i_color *val) {
202 return i_gpix(im, x, y, val);
206 =item i_ppixf(im, C<x>, C<y>, C<fcolor>)
210 Sets the pixel at (C<x>,C<y>) to the floating point color C<fcolor>.
212 Returns 0 if the pixel was drawn, or -1 if not.
214 Does no alpha blending, just copies the channels from the supplied
220 (i_ppixf)(i_img *im, i_img_dim x, i_img_dim y, const i_fcolor *val) {
221 return i_ppixf(im, x, y, val);
225 =item i_gpixf(im, C<x>, C<y>, C<fcolor>)
229 Retrieves the color of the pixel (x,y) as a floating point color into
232 Returns 0 if the pixel was retrieved, or -1 if not.
238 (i_gpixf)(i_img *im,i_img_dim x,i_img_dim y,i_fcolor *val) {
239 return i_gpixf(im, x, y, val);
243 =item i_plin(im, l, r, y, colors)
247 Sets (r-l) pixels starting from (l,y) using (r-l) values from
250 Returns the number of pixels set.
256 (i_plin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_color *vals) {
257 return i_plin(im, l, r, y, vals);
261 =item i_glin(im, l, r, y, colors)
265 Retrieves (r-l) pixels starting from (l,y) into I<colors>.
267 Returns the number of pixels retrieved.
273 (i_glin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_color *vals) {
274 return i_glin(im, l, r, y, vals);
278 =item i_plinf(im, C<left>, C<right>, C<fcolors>)
282 Sets (right-left) pixels starting from (left,y) using (right-left)
283 floating point colors from C<fcolors>.
285 Returns the number of pixels set.
291 (i_plinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_fcolor *vals) {
292 return i_plinf(im, l, r, y, vals);
296 =item i_glinf(im, l, r, y, colors)
300 Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating
303 Returns the number of pixels retrieved.
309 (i_glinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fcolor *vals) {
310 return i_glinf(im, l, r, y, vals);
314 =item i_gsamp(im, left, right, y, samples, channels, channel_count)
318 Reads sample values from C<im> for the horizontal line (left, y) to
319 (right-1,y) for the channels specified by C<channels>, an array of int
320 with C<channel_count> elements.
322 If channels is NULL then the first channels_count channels are retrieved for
325 Returns the number of samples read (which should be (right-left) *
331 (i_gsamp)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_sample_t *samp,
332 const int *chans, int chan_count) {
333 return i_gsamp(im, l, r, y, samp, chans, chan_count);
337 =item i_gsampf(im, left, right, y, samples, channels, channel_count)
341 Reads floating point sample values from C<im> for the horizontal line
342 (left, y) to (right-1,y) for the channels specified by C<channels>, an
343 array of int with channel_count elements.
345 If C<channels> is NULL then the first C<channel_count> channels are
346 retrieved for each pixel.
348 Returns the number of samples read (which should be (C<right>-C<left>)
354 (i_gsampf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samp,
355 const int *chans, int chan_count) {
356 return i_gsampf(im, l, r, y, samp, chans, chan_count);
360 =item i_gsamp_bits(im, left, right, y, samples, channels, channel_count, bits)
363 Reads integer samples scaled to C<bits> bits of precision into the
364 C<unsigned int> array C<samples>.
366 Expect this to be slow unless C<< bits == im->bits >>.
368 Returns the number of samples copied, or -1 on error.
370 Not all image types implement this method.
372 Pushes errors, but does not call C<i_clear_error()>.
378 =item i_psamp_bits(im, left, right, y, samples, channels, channel_count, bits)
381 Writes integer samples scaled to C<bits> bits of precision from the
382 C<unsigned int> array C<samples>.
384 Expect this to be slow unless C<< bits == im->bits >>.
386 Returns the number of samples copied, or -1 on error.
388 Not all image types implement this method.
390 Pushes errors, but does not call C<i_clear_error()>.
396 =item i_gpal(im, left, right, y, indexes)
400 Reads palette indexes for the horizontal line (left, y) to (right-1,
403 Returns the number of indexes read.
405 Always returns 0 for direct color images.
410 (i_gpal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, i_palidx *vals) {
411 return i_gpal(im, x, r, y, vals);
415 =item i_ppal(im, left, right, y, indexes)
419 Writes palette indexes for the horizontal line (left, y) to (right-1,
422 Returns the number of indexes written.
424 Always returns 0 for direct color images.
429 (i_ppal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, const i_palidx *vals) {
430 return i_ppal(im, x, r, y, vals);
434 =item i_addcolors(im, colors, count)
436 =category Paletted images
438 Adds colors to the image's palette.
440 On success returns the index of the lowest color added.
442 On failure returns -1.
444 Always fails for direct color images.
450 (i_addcolors)(i_img *im, const i_color *colors, int count) {
451 return i_addcolors(im, colors, count);
455 =item i_getcolors(im, index, colors, count)
457 =category Paletted images
459 Retrieves I<count> colors starting from I<index> in the image's
462 On success stores the colors into I<colors> and returns true.
464 On failure returns false.
466 Always fails for direct color images.
468 Fails if there are less than I<index>+I<count> colors in the image's
475 (i_getcolors)(i_img *im, int i, i_color *colors, int count) {
476 return i_getcolors(im, i, colors, count);
480 =item i_colorcount(im)
482 =category Paletted images
484 Returns the number of colors in the image's palette.
486 Returns -1 for direct images.
492 (i_colorcount)(i_img *im) {
493 return i_colorcount(im);
497 =item i_maxcolors(im)
499 =category Paletted images
501 Returns the maximum number of colors the palette can hold for the
504 Returns -1 for direct color images.
510 (i_maxcolors)(i_img *im) {
511 return i_maxcolors(im);
515 =item i_findcolor(im, color, &entry)
517 =category Paletted images
519 Searches the images palette for the given color.
521 On success sets *I<entry> to the index of the color, and returns true.
523 On failure returns false.
525 Always fails on direct color images.
530 (i_findcolor)(i_img *im, const i_color *color, i_palidx *entry) {
531 return i_findcolor(im, color, entry);
535 =item i_setcolors(im, index, colors, count)
537 =category Paletted images
539 Sets I<count> colors starting from I<index> in the image's palette.
541 On success returns true.
543 On failure returns false.
545 The image must have at least I<index>+I<count> colors in it's palette
548 Always fails on direct color images.
553 (i_setcolors)(i_img *im, int index, const i_color *colors, int count) {
554 return i_setcolors(im, index, colors, count);
558 =item im_get_context()
560 Retrieve the context object for the current thread.
562 Inside Imager itself this is just a function pointer, which the
563 Imager.xs BOOT handler initializes for use within perl. If you're
564 taking the Imager code and embedding it elsewhere you need to
565 initialize the C<im_get_context> pointer at some point.
572 return im_get_context();