3 Imager::API - Imager's C API - introduction.
10 DEFINE_IMAGER_CALLBACKS;
12 MODULE = Your::Module PACKAGE = Your::Module
17 PERL_INITIALIZE_IMAGER_CALLBACKS;
22 The API allows you to access Imager functions at the C level from XS
25 The intent is to allow users to:
31 write C code that does Imager operations the user might do from Perl,
32 but faster, for example, the Imager::CountColor example.
36 write C code that implements an application specific version of some
37 core Imager object, for example, Imager::SDL.
41 write C code that hooks into Imagers existing methods, such as filter
42 or file format handlers.
46 See L<Imager::Inline> for information on using Imager's Inline::C
55 don't return an object you received as a parameter - this will cause
56 the object to be freed twice.
62 The API makes the following types visible:
68 i_img - used to represent an image
72 i_color - used to represent a color with up to 8 bits per sample.
76 i_fcolor - used to represent a color with a double per sample.
80 i_fill_t - an abstract fill
84 At this point there is no consolidated font object type, and hence the
85 font functions are not visible through Imager's API.
89 This contains the dimensions of the image (xsize, ysize, channels),
90 image metadata (ch_mask, bits, type, virtual), potentially image data
91 (idata) and the a function table, with pointers to functions to
92 perform various low level image operations.
94 The only time you should directly write to any value in this type is
95 if you're implementing your own image type.
97 The typemap includes typenames Imager and Imager::ImgRaw as typedefs
100 For incoming parameters the typemap will accept either Imager or
101 Imager::ImgRaw objects.
103 For return values the typemap will produce a full Imager object for an
104 Imager return type and a raw image object for an Imager::ImgRaw return
107 =head2 i_color - 8-bit color
109 Represents an 8-bit per sample color. This is a union containing
110 several different structs for access to components of a color:
116 gray - single member gray_color.
120 rgb - r, g, b members.
124 rgba - r, g, b, a members.
128 channels - array of channels.
132 Use Imager::Color for parameter and return value types.
134 =head2 i_fcolor - floating point color
136 Similar to i_color except that each component is a double instead of
139 Use Imager::Color::Float for parameter and return value types.
141 =head2 i_fill_t - fill objects
143 Abstract type containing pointers called to perform low level fill
146 Unless you're defining your own fill objects you should treat this as
149 Use Imager::FillHandle for parameter and return value types. At the
150 Perl level this is stored in the C<fill> member of the Perl level
153 =head1 Create an XS module using the Imager API
161 and bootstrap your XS code - see L<XSLoader> or L<DynaLoader>.
165 You'll need the following in your XS source:
171 include the Imager external API header, and the perl interface header:
178 create the variables used to hold the callback table:
180 DEFINE_IMAGER_CALLBACKS;
184 initialize the callback table in your BOOT code:
187 PERL_INITIALIZE_IMAGER_CALLBACKS;
193 In any other source files where you want to access the Imager API,
200 include the Imager external API header:
208 If you're creating an XS module that depends on Imager's API your
209 Makefile.PL will need to do the following:
215 C<use Imager::ExtUtils;>
219 include Imager's include directory in INC:
221 INC => Imager::ExtUtils->includes
225 use Imager's typemap:
227 TYPEMAPS => [ Imager::ExtUtils->typemap ]
231 include Imager 0.48 as a PREREQ_PM:
242 Tony Cook <tony@imager.perl.org>
246 Imager, Imager::ExtUtils, Imager::APIRef, Imager::Inline