1 Do not edit this file, it is generated automatically by apidocs.perl
2 from Imager's source files.
4 Each function description has a comment listing the source file where
5 you can find the documentation.
9 Imager::APIRef - Imager's C API.
14 color.rgba.red = 255; color.rgba.green = 0; color.rgba.blue = 255;
15 i_fill_t *fill = i_new_fill_...(...);
19 i_arc(im, 50, 50, 20, 45, 135, &color);
20 i_arc_aa(im, 50, 50, 35, 90, 135, &color);
21 i_arc_aa_cfill(im, 50, 50, 35, 90, 135, fill);
22 i_arc_cfill(im, 50, 50, 35, 90, 135, fill);
23 i_box(im, 0, 0, im->xsize-1, im->ysize-1, &color).
24 i_box_cfill(im, 0, 0, im->xsize-1, im->ysize-1, fill);
25 i_box_filled(im, 0, 0, im->xsize-1, im->ysize-1, &color);
26 i_circle_aa(im, 50, 50, 45, &color);
27 i_flood_cfill(im, 50, 50, fill);
28 i_flood_cfill_border(im, 50, 50, fill, border);
29 i_flood_fill(im, 50, 50, &color);
30 i_flood_fill_border(im, 50, 50, &color, &border);
35 i_get_image_file_limits(&width, &height, &bytes)
36 i_i_int_check_image_file_limits(width, height, channels, sizeof(i_sample_t))
37 i_set_image_file_limits(500, 500, 1000000);
40 fill = i_new_fill_fount(0, 0, 100, 100, i_ft_linear, i_ft_linear,
41 i_fr_triangle, 0, i_fts_grid, 9, 1, segs);
61 =item i_arc(im, x, y, rad, d1, d2, color)
64 Fills an arc centered at (x,y) with radius I<rad> covering the range
65 of angles in degrees from d1 to d2, with the color.
71 =item i_arc_aa(im, x, y, rad, d1, d2, color)
74 Antialias fills an arc centered at (x,y) with radius I<rad> covering
75 the range of angles in degrees from d1 to d2, with the color.
81 =item i_arc_aa_cfill(im, x, y, rad, d1, d2, fill)
84 Antialias fills an arc centered at (x,y) with radius I<rad> covering
85 the range of angles in degrees from d1 to d2, with the fill object.
91 =item i_arc_cfill(im, x, y, rad, d1, d2, fill)
94 Fills an arc centered at (x,y) with radius I<rad> covering the range
95 of angles in degrees from d1 to d2, with the fill object.
101 =item i_box(im, x1, y1, x2, y2, color)
104 Outlines the box from (x1,y1) to (x2,y2) inclusive with I<color>.
110 =item i_box_cfill(im, x1, y1, x2, y2, fill)
113 Fills the box from (x1,y1) to (x2,y2) inclusive with fill.
119 =item i_box_filled(im, x1, y1, x2, y2, color)
122 Fills the box from (x1,y1) to (x2,y2) inclusive with color.
128 =item i_circle_aa(im, x, y, rad, color)
131 Antialias fills a circle centered at (x,y) for radius I<rad> with
138 =item i_flood_cfill(im, seedx, seedy, fill)
141 Flood fills the 4-connected region starting from the point (seedx,
144 Returns false if (seedx, seedy) are outside the image.
150 =item i_flood_cfill_border(im, seedx, seedy, fill, border)
153 Flood fills the 4-connected region starting from the point (seedx,
154 seedy) with I<fill>, the fill stops when it reaches pixels of color
157 Returns false if (seedx, seedy) are outside the image.
163 =item i_flood_fill(im, seedx, seedy, color)
166 Flood fills the 4-connected region starting from the point (seedx,
167 seedy) with I<color>.
169 Returns false if (seedx, seedy) are outside the image.
175 =item i_flood_fill_border(im, seedx, seedy, color, border)
178 Flood fills the 4-connected region starting from the point (seedx,
179 seedy) with I<color>, fill stops when the fill reaches a pixels with
182 Returns false if (seedx, seedy) are outside the image.
188 =item i_glin(im, l, r, y, colors)
191 Retrieves (r-l) pixels starting from (l,y) into I<colors>.
193 Returns the number of pixels retrieved.
199 =item i_glinf(im, l, r, y, colors)
202 Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating
205 Returns the number of pixels retrieved.
211 =item i_gpal(im, x, r, y, indexes)
214 Reads palette indexes for the horizontal line (x, y) to (r-1, y) into
217 Returns the number of indexes read.
219 Always returns 0 for direct color images.
225 =item i_gpix(im, x, y, color)
228 Retrieves the I<color> of the pixel (x,y).
230 Returns 0 if the pixel was retrieved, or -1 if not.
236 =item i_gpixf(im, x, y, fcolor)
239 Retrieves the color of the pixel (x,y) as a floating point color into
242 Returns 0 if the pixel was retrieved, or -1 if not.
248 =item i_gsamp(im, l, r, y, samp, chans, chan_count)
251 Reads sample values from im for the horizontal line (l, y) to (r-1,y)
252 for the channels specified by chans, an array of int with chan_count
255 If chans is NULL then the first chan_count channels are retrieved for
258 Returns the number of samples read (which should be (r-l) *
265 =item i_gsampf(im, l, r, y, samp, chans, chan_count)
268 Reads floating point sample values from im for the horizontal line (l,
269 y) to (r-1,y) for the channels specified by chans, an array of int
270 with chan_count elements.
272 If chans is NULL then the first chan_count channels are retrieved for
275 Returns the number of samples read (which should be (r-l) *
282 =item i_line(im, x1, y1, x2, y2, val, endp)
285 Draw a line to image using bresenhams linedrawing algorithm
287 im - image to draw to
288 x1 - starting x coordinate
289 y1 - starting x coordinate
290 x2 - starting x coordinate
291 y2 - starting x coordinate
292 val - color to write to image
293 endp - endpoint flag (boolean)
299 =item i_line_aa(im, x1, x2, y1, y2, color, endp)
302 Antialias draws a line from (x1,y1) to (x2, y2) in color.
304 The point (x2, y2) is drawn only if endp is set.
310 =item i_plin(im, l, r, y, colors)
313 Sets (r-l) pixels starting from (l,y) using (r-l) values from
316 Returns the number of pixels set.
322 =item i_plinf(im, l, r, fcolors)
325 Sets (r-l) pixels starting from (l,y) using (r-l) floating point
326 colors from I<colors>.
328 Returns the number of pixels set.
334 =item i_ppal(im, x, r, y, indexes)
337 Writes palette indexes for the horizontal line (x, y) to (r-1, y) from
340 Returns the number of indexes written.
342 Always returns 0 for direct color images.
348 =item i_ppix(im, x, y, color)
351 Sets the pixel at (x,y) to I<color>.
353 Returns 0 if the pixel was drawn, or -1 if not.
355 Does no alpha blending, just copies the channels from the supplied
362 =item i_ppixf(im, x, y, fcolor)
365 Sets the pixel at (x,y) to the floating point color I<fcolor>.
367 Returns 0 if the pixel was drawn, or -1 if not.
369 Does no alpha blending, just copies the channels from the supplied
379 =head2 Error handling
383 =item i_clear_error()
386 Clears the error stack.
388 Called by any imager function before doing any other processing.
394 =item i_push_error(int code, char const *msg)
397 Called by an imager function to push an error message onto the stack.
399 No message is pushed if the stack is full (since this means someone
400 forgot to call i_clear_error(), or that a function that doesn't do
401 error handling is calling function that does.).
407 =item i_push_errorf(int code, char const *fmt, ...)
410 A version of i_push_error() that does printf() like formating.
416 =item i_push_errorvf(int code, char const *fmt, va_list ap)
419 Intended for use by higher level functions, takes a varargs pointer
420 and a format to produce the finally pushed error message.
433 =item i_get_image_file_limits(&width, &height, &bytes)
436 Retrieves the file limits set by i_set_image_file_limits().
442 =item i_int_check_image_file_limits(width, height, channels, sample_size)
445 Checks the size of a file in memory against the configured image file
448 This also range checks the values to those permitted by Imager and
449 checks for overflows in calculating the size.
451 Returns non-zero if the file is within limits.
453 This function is intended to be called by image file read functions.
459 =item i_set_image_file_limits(width, height, bytes)
462 Set limits on the sizes of images read by Imager.
464 Setting a limit to 0 means that limit is ignored.
466 Negative limits result in failure.
468 Returns non-zero on success.
481 =item i_fill_destroy(fill)
484 Call to destroy any fill object.
490 =item i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, count, segs)
494 Creates a new general fill which fills with a fountain fill.
500 =item i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy)
503 Creates a new hatched fill with the fg color used for the 1 bits in
504 the hatch and bg for the 0 bits. If combine is non-zero alpha values
507 If cust_hatch is non-NULL it should be a pointer to 8 bytes of the
508 hash definition, with the high-bits to the left.
510 If cust_hatch is NULL then one of the standard hatches is used.
512 (dx, dy) are an offset into the hatch which can be used to unalign adjoining areas, or to align the origin of a hatch with the the side of a filled area.
518 =item i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy)
521 Creates a new hatched fill with the fg color used for the 1 bits in
522 the hatch and bg for the 0 bits. If combine is non-zero alpha values
525 If cust_hatch is non-NULL it should be a pointer to 8 bytes of the
526 hash definition, with the high-bits to the left.
528 If cust_hatch is NULL then one of the standard hatches is used.
530 (dx, dy) are an offset into the hatch which can be used to unalign adjoining areas, or to align the origin of a hatch with the the side of a filled area.
536 =item i_new_fill_image(im, matrix, xoff, yoff, combine)
539 Create an image based fill.
541 matrix is an array of 9 doubles representing a transformation matrix.
543 xoff and yoff are the offset into the image to start filling from.
549 =item i_new_fill_solid(color, combine)
552 Create a solid fill based on an 8-bit color.
554 If combine is non-zero then alpha values will be combined.
560 =item i_new_fill_solidf(color, combine)
563 Create a solid fill based on a float color.
565 If combine is non-zero then alpha values will be combined.
581 Creates a new image that is a copy of src.
583 Tags are not copied, only the image data.
591 =item i_copyto(dest, src, x1, y1, x2, y2, tx, ty)
594 Copies image data from the area (x1,y1)-[x2,y2] in the source image to
595 a rectangle the same size with it's top-left corner at (tx,ty) in the
598 If x1 > x2 or y1 > y2 then the corresponding co-ordinates are swapped.
604 =item i_copyto_trans(im, src, x1, y1, x2, y2, tx, ty, trans)
607 (x1,y1) (x2,y2) specifies the region to copy (in the source coordinates)
608 (tx,ty) specifies the upper left corner for the target image.
609 pass NULL in trans for non transparent i_colors.
615 =item i_img_destroy(im)
618 Destroy image and free data via exorcise.
626 =item i_img_info(im, info)
629 Return image information
632 info - pointer to array to return data
634 info is an array of 4 integers with the following values:
639 info[3] - channel mask
645 =item i_rubthru(im, src, tx, ty, src_minx, src_miny, src_maxx, src_maxy )
648 Takes the sub image I<src[src_minx, src_maxx)[src_miny, src_maxy)> and
649 overlays it at (I<tx>,I<ty>) on the image object.
651 The alpha channel of each pixel in I<src> is used to control how much
652 the existing colour in I<im> is replaced, if it is 255 then the colour
653 is completely replaced, if it is 0 then the original colour is left
658 From: File rubthru.im
663 =head2 Image creation
667 =item i_img_16_new(x, y, ch)
670 Create a new 16-bit/sample image.
672 Returns the image on success, or NULL on failure.
678 =item i_img_8_new(x, y, ch)
681 Creates a new image object I<x> pixels wide, and I<y> pixels high with
688 =item i_img_double_new(int x, int y, int ch)
691 Creates a new double per sample image.
695 From: File imgdouble.c
697 =item i_img_pal_new(x, y, channels, maxpal)
700 Creates a new paletted image of the supplied dimensions.
702 Returns a new image or NULL on failure.
708 =item i_sametype(i_img *im, int xsize, int ysize)
711 Returns an image of the same type (sample size, channels, paletted/direct).
713 For paletted images the palette is copied from the source.
719 =item i_sametype_chans(i_img *im, int xsize, int ysize, int channels)
722 Returns an image of the same type (sample size).
724 For paletted images the equivalent direct type is returned.
733 =head2 Image quantization
737 =item i_quant_makemap(quant, imgs, count)
740 Analyzes the I<count> images in I<imgs> according to the rules in
741 I<quant> to build a color map (optimal or not depending on
748 =item i_quant_translate(quant, img)
751 Quantize the image given the palette in quant.
753 On success returns a pointer to a memory block of img->xsize *
754 img->ysize i_palidx entries.
756 On failure returns NULL.
758 You should call myfree() on the returned block when you're done with
761 This function will fail if the supplied palette contains no colors.
767 =item i_quant_transparent(quant, data, img, trans_index)
770 Dither the alpha channel on I<img> into the palette indexes in
771 I<data>. Pixels to be transparent are replaced with I<trans_pixel>.
773 The method used depends on the tr_* members of quant.
782 =head2 Paletted images
786 =item i_addcolors(im, colors, count)
789 Adds colors to the image's palette.
791 On success returns the index of the lowest color added.
793 On failure returns -1.
795 Always fails for direct color images.
801 =item i_colorcount(im)
804 Returns the number of colors in the image's palette.
806 Returns -1 for direct images.
812 =item i_findcolor(im, color, &entry)
815 Searches the images palette for the given color.
817 On success sets *I<entry> to the index of the color, and returns true.
819 On failure returns false.
821 Always fails on direct color images.
827 =item i_getcolors(im, index, colors, count)
830 Retrieves I<count> colors starting from I<index> in the image's
833 On success stores the colors into I<colors> and returns true.
835 On failure returns false.
837 Always fails for direct color images.
839 Fails if there are less than I<index>+I<count> colors in the image's
846 =item i_maxcolors(im)
849 Returns the maximum number of colors the palette can hold for the
852 Returns -1 for direct color images.
858 =item i_setcolors(im, index, colors, count)
861 Sets I<count> colors starting from I<index> in the image's palette.
863 On sucess returns true.
865 On failure returns false.
867 The image must have at least I<index>+I<count> colors in it's palette
870 Always fails on direct color images.
883 =item i_tags_delbycode(tags, code)
886 Delete any tags with the given code.
888 Returns the number of tags deleted.
894 =item i_tags_delbyname(tags, name)
897 Delete any tags with the given name.
899 Returns the number of tags deleted.
905 =item i_tags_delete(tags, index)
908 Delete a tag by index.
910 Returns true on success.
916 =item i_tags_destroy(tags)
919 Destroys the given tags structure. Called by i_img_destroy().
925 =item i_tags_find(tags, name, start, &entry)
928 Searchs for a tag of the given I<name> starting from index I<start>.
930 On success returns true and sets *I<entry>.
932 On failure returns false.
938 =item i_tags_findn(tags, code, start, &entry)
941 Searchs for a tag of the given I<code> starting from index I<start>.
943 On success returns true and sets *I<entry>.
945 On failure returns false.
951 =item i_tags_get_color(tags, name, code, &value)
954 Retrieve a tag specified by name or code as color.
956 On success sets the i_color *I<value> to the color and returns true.
958 On failure returns false.
964 =item i_tags_get_float(tags, name, code, value)
967 Retrieves a tag as a floating point value.
969 If the tag has a string value then that is parsed as a floating point
970 number, otherwise the integer value of the tag is used.
972 On success sets *I<value> and returns true.
974 On failure returns false.
980 =item i_tags_get_int(tags, name, code, &value)
983 Retrieve a tag specified by name or code as an integer.
985 On success sets the int *I<value> to the integer and returns true.
987 On failure returns false.
993 =item i_tags_get_string(tags, name, code, value, value_size)
996 Retrieves a tag by name or code as a string.
998 On success copies the string to value for a max of value_size and
1001 On failure returns false.
1003 value_size must be at least large enough for a string representation
1006 The copied value is always NUL terminated.
1012 =item i_tags_new(i_img_tags *tags)
1015 Initialize a tags structure. Should not be used if the tags structure
1016 has been previously used.
1018 This should be called tags member of an i_img object on creation (in
1019 i_img_*_new() functions).
1021 To destroy the contents use i_tags_destroy()
1027 =item i_tags_set(tags, name, data, size)
1030 Sets the given tag to the string I<data>
1036 =item i_tags_set_color(tags, name, code, &value)
1039 Stores the given color as a tag with the given name and code.
1045 =item i_tags_set_float(tags, name, code, value)
1048 Equivalent to i_tags_set_float2(tags, name, code, value, 30).
1054 =item i_tags_set_float2(tags, name, code, value, places)
1057 Sets the tag with the given name and code to the given floating point
1060 Since tags are strings or ints, we convert the value to a string before
1061 storage at the precision specified by C<places>.
1067 =item i_tags_setn(tags, name, idata)
1070 Sets the given tag to the integer I<idata>
1082 Tony Cook <tony@imager.perl.org>
1086 Imager, Imager::ExtUtils, Imager::Inline