/usr/lib/perl5/Imager/interface.pod is in libimager-perl 0.98+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | =head1 NAME
Imager::interface.pod - describes the C level virtual image interface
=head1 SYNOPSIS
=head1 DESCRIPTION
The Imager virtual interface aims to allow image types to be created
for special purposes, both to allow consistent access to images with
different sample sizes, and organizations, but also to allow creation
of synthesized or virtual images.
This is a C level interface rather than Perl.
=head2 Existing Images
As of this writing we have the following concrete image types:
=over
=item *
8-bit/sample direct images
=item *
16-bit/sample direct images
=item *
double/sample direct images
=item *
8-bit/sample 8-bit/index paletted images
=back
Currently there is only one virtual image type:
=over
=item *
masked images, where a mask image can control write access to an
underlying image.
=back
Other possible concrete images include:
=over
=item *
"bitmaps", 1 bit/sample images (perhaps limited to a single channel)
=item *
16-bit/index paletted images
=back
Some other possible virtual images:
=for stopwords GIMP Photoshop
=over
=item *
image alpha combining, where the combining function can be specified
(see the layer modes in graphical editors like the GIMP or Photoshop.
=back
=head1 THE INTERFACE
Each image type needs to define a number of functions which implement
the image operations.
The image structure includes information describes the image, which
can be used to determine the structure of the image:
=over
=item *
C<channels> - the number of samples kept for each pixel in the image.
For paletted images the samples are kept for each entry in the
palette.
=item *
C<xsize>, C<ysize> - the dimensions of the image in pixels.
=item *
C<bytes> - the number of bytes of data kept for the image. Zero for
virtual images. Does not include the space required for the palette
for paletted images.
=item *
C<ch_mask> - controls which samples will be written to for direct
images.
=item *
C<bits> - the number of bits kept for each sample. There are enum
values i_8_bits, i_16_bits and i_double_bits (64).
=item *
C<type> - the type of image, either i_direct_type or i_palette_type.
Direct images keep the samples for every pixel image, while
i_palette_type images keep an index into a color table for each pixel.
=item *
C<virtual> - whether the image keeps any pixel data. If this is
non-zero then C<idata> points to image data, otherwise it points to
implementation defined data, though C<ext_data> is more likely to be
used for that.
=item *
C<idata> - image data. If the image is 8-bit direct, non-virtual,
then this consists of each sample of the image stored one after
another, otherwise it is implementation defined.
=item *
C<tags> - will be used to store meta-data for an image, eg. tags from
a TIFF file, or animation information from a GIF file. This should be
initialized with a call to i_tags_new() in your image constructor if
creating a new image type.
=item *
C<ext_data> - for internal use of image types. This is not released
by the standard i_img_exorcise() function. If you create a new image
type and want to store a pointer to allocated memory here you should
point i_f_destroy at a function that will release the data.
=back
If a caller has no knowledge of the internal format of an image, the
caller must call the appropriate image function pointer. Imager
provides macros that wrap these functions, so it isn't necessary to
call them directly.
Many functions have a similar function with an 'f' suffix, these take
or return samples specified with floating point values rather than
8-bit integers (unsigned char). Floating point samples are returned
in the range 0 to 1 inclusive.
=over
=item i_f_ppix(im,x,y,color)
=item i_f_ppixf(im,x,y,fcolor)
stores the specified color at pixel (x,y) in the image. If the pixel
can be stored return 0, otherwise -1. An image type may choose to
return 0 under some circumstances, eg. writing to a masked area of an
image. The C<color> or C<fcolor> always contains the actual samples to be
written, rather than a palette index.
=item i_f_plin(im,l,r,y,colors)
=item i_f_plinf(im,l,r,y,fcolors)
stores (r-l) pixels at positions (l,y) ... (r-1, y) from the array
specified by C<colors> (or C<fcolors>). Returns the number of pixels
written to. If l is negative it will return 0. If C<< r > im->xsize
>> then only C<< (im->xsize - l) >> will be written.
=item i_f_gpix(im,x,y,color)
=item i_f_gpixf(im,x,y,fcolor)
retrieves a single pixel from position (x,y). This returns the
samples rather than the index for paletted images.
=item i_f_glin(im,l,r,y,colors)
=item i_f_glinf(im,l,r,y,fcolors)
retrieves (r-l) pixels from positions (l, y) through (r-1, y) into the
array specified by colors. Returns the number of pixels retrieved.
If l < 0 no pixels are retrieved. If C<< r > im->xsize >> then pixels
C<< (l, y) >> ... C<< (im->xsize-1, y) >> are retrieved. Retrieves
the samples rather than the color indexes for paletted images.
=item i_f_gsamp(im,l,r,y,samples,chans,chan_count)
=item i_f_gsampf(im,l,r,y,fsamples,chans,chan_count)
Retrieves samples from channels specified by C<chans> (for length
C<chan_count>) from pixels at positions (l,y) ... (r-1, y). If
C<chans> is NULL then samples from channels 0 ... C<chan_count-1> will
be retrieved. Returns the number of sample retrieved (I<not> the
number of channels). If a channel in C<chans> is not present in the
image or l < 0, returns 0. If C<< r > im->xsize >>, then the samples
from C<(l,y)> ... C<< (im->xsize-1, y) >> are returned.
=back
The following are for images where type == i_palette_type only.
=over
=item i_f_gpal(im,l,r,y,vals)
Retrieves color indexes from the image for pixels (l, y) ... (r-1, y)
into C<vals>. Returns the number of indexes retrieved.
=item i_f_ppal(im,l,r,y,vals)
Stores color indexes into the image for pixels (l, y) ... (r-1, y)
from C<vals>. Returns the number of indexes retrieved. If indexes are
outside the range of the images palette, then you may have problems
reading those pixels with i_gpix() or i_glin().
=item i_f_addcolors(im,colors,count)
Adds the count colors to the image's palette. Returns the index of
the first color added, or -1 if there is not enough space for count
colors.
=item i_f_getcolors(im,index,colors,count)
Retrieves count colors from the image's palette starting from entry
index in the palette. Returns non-zero on success.
=item i_f_colorcount(im)
Returns the number of colors in the image's palette. Returns -1 if
this is not a paletted image.
=item i_f_maxcolors(im)
Returns the maximum number of colors that can fit in the image's
palette. Returns -1 if this is not a paletted image.
=item i_f_findcolor(im,color,entry)
Searches the image's palette for the specified color, setting *entry
to the index and returning non-zero. Returns zero if the color is not
found.
=item i_f_setcolors_t(im,index,colors,count)
Sets count colors starting from index in the image from the array
colors. The colors to be set must already have entries in the image's
palette. Returns non-zero on success.
=back
Finally, the i_f_destroy function pointer can be set which is called
when the image is destroyed. This can be used to release memory
pointed to by ext_data or release any other resources.
When writing to a paletted image with i_ppix() or i_plin() and the
color you are writing doesn't exist in the image, then it's possible
that the image will be internally converted to a direct image with the
same number of channels.
=head1 TOOLS
Several functions have been written to simplify creating new image types.
These tools are available by including F<imagei.h>.
=head2 Floating point wrappers
These functions implement the floating point sample versions of each
interface function in terms of the integer sample version.
These are:
=over
=item i_ppixf_fp
=item i_gpixf_fp
=item i_plinf_fp
=item i_glinf_fp
=item i_gsampf_fp
=back
=head2 Forwarding functions
These functions are used in virtual images where the call should
simply be forwarded to the underlying image. The underlying image is
assumed to be the first pointer in a structure pointed at by ext_data.
If this is not the case then these functions will just crash :)
=over
=item i_addcolors_forward
=item i_getcolors_forward
=item i_colorcount_forward
=item i_maxcolors_forward
=item i_findcolor_forward
=item i_setcolors_forward
=back
=head2 Sample macros
C<imagei.h> defines several macros for converting samples between
different sizes.
Each macro is of the form C<Sample>I<size>C<To>I<size> where I<size> is one
of 8, 16, or F (for floating-point samples).
=over
=item SampleFTo16(sample)
=item Sample16ToF(sample)
=item SampleFTo8(sample)
=item Sample8ToF(sample)
=item Sample16To8(num)
=item Sample8To16(num)
=back
=head1 AUTHOR
Tony Cook <tonyc@cpan.org>, Arnar M. Hrafnkelsson
=cut
|