| 1 |
Do not edit this file, it is generated automatically by apidocs.perl |
| 2 |
from Imager's source files. |
| 3 |
|
| 4 |
Each function description has a comment listing the source file where |
| 5 |
you can find the documentation. |
| 6 |
|
| 7 |
=head1 NAME |
| 8 |
|
| 9 |
Imager::APIRef - Imager's C API - reference. |
| 10 |
|
| 11 |
=head1 SYNOPSIS |
| 12 |
|
| 13 |
i_color color; |
| 14 |
color.rgba.r = 255; color.rgba.g = 0; color.rgba.b = 255; |
| 15 |
double x[] = { ... }; |
| 16 |
double y[] = { ... }; |
| 17 |
i_polygon_t poly; |
| 18 |
poly.count = sizeof(x) / sizeof(*x); |
| 19 |
poly.x = x; |
| 20 |
poly.y = y; |
| 21 |
|
| 22 |
|
| 23 |
# Blit tools |
| 24 |
|
| 25 |
# Data Types |
| 26 |
i_img *img; |
| 27 |
i_color black; |
| 28 |
black.rgba.r = black.rgba.g = black.rgba.b = black.rgba.a = 0; |
| 29 |
i_fill_t *fill; |
| 30 |
i_img_dim x, y; |
| 31 |
i_img_dim_u limit; |
| 32 |
printf("left %" i_DF "\n", i_DFc(x)); |
| 33 |
printf("point (" i_DFp ")\n", i_DFcp(x, y)); |
| 34 |
|
| 35 |
# Drawing |
| 36 |
i_arc(im, 50, 50, 20, 45, 135, &color); |
| 37 |
i_arc_cfill(im, 50, 50, 35, 90, 135, fill); |
| 38 |
i_arc_aa(im, 50, 50, 35, 90, 135, &color); |
| 39 |
i_arc_aa_cfill(im, 50, 50, 35, 90, 135, fill); |
| 40 |
i_circle_aa(im, 50, 50, 45, &color); |
| 41 |
i_box(im, 0, 0, im->xsize-1, im->ysize-1, &color). |
| 42 |
i_box_filled(im, 0, 0, im->xsize-1, im->ysize-1, &color); |
| 43 |
i_box_cfill(im, 0, 0, im->xsize-1, im->ysize-1, fill); |
| 44 |
i_flood_fill(im, 50, 50, &color); |
| 45 |
i_flood_cfill(im, 50, 50, fill); |
| 46 |
i_flood_fill_border(im, 50, 50, &color, &border); |
| 47 |
i_flood_cfill_border(im, 50, 50, fill, border); |
| 48 |
i_poly_poly_aa(im, 1, &poly, mode, color); |
| 49 |
i_poly_aa_m(im, count, x, y, mode, color); |
| 50 |
i_poly_poly_aa_cfill(im, 1, &poly, mode, fill); |
| 51 |
i_poly_aa_cfill(im, count, x, y, mode, fill); |
| 52 |
|
| 53 |
# Error handling |
| 54 |
im_clear_error(aIMCTX); |
| 55 |
i_clear_error(); |
| 56 |
i_push_error(0, "Yep, it's broken"); |
| 57 |
i_push_error(errno, "Error writing"); |
| 58 |
im_push_error(aIMCTX, 0, "Something is wrong"); |
| 59 |
va_args args; |
| 60 |
va_start(args, lastarg); |
| 61 |
im_push_errorvf(ctx, code, format, args); |
| 62 |
i_push_errorf(errno, "Cannot open file %s: %d", filename, errno); |
| 63 |
im_push_errorf(aIMCTX, errno, "Cannot open file %s: %d", filename, errno); |
| 64 |
|
| 65 |
# Files |
| 66 |
im_set_image_file_limits(aIMCTX, 500, 500, 1000000); |
| 67 |
i_set_image_file_limits(500, 500, 1000000); |
| 68 |
im_get_image_file_limits(aIMCTX, &width, &height, &bytes) |
| 69 |
i_get_image_file_limits(&width, &height, &bytes) |
| 70 |
im_int_check_image_file_limits(aIMCTX, width, height, channels, sizeof(i_sample_t)) |
| 71 |
i_int_check_image_file_limits(width, height, channels, sizeof(i_sample_t)) |
| 72 |
|
| 73 |
# Fills |
| 74 |
i_fill_t *fill = i_new_fill_solidf(&fcolor, combine); |
| 75 |
i_fill_t *fill = i_new_fill_solid(&color, combine); |
| 76 |
i_fill_t *fill = i_new_fill_hatch(&fg_color, &bg_color, combine, hatch, custom_hatch, dx, dy); |
| 77 |
i_fill_t *fill = i_new_fill_hatchf(&fg_fcolor, &bg_fcolor, combine, hatch, custom_hatch, dx, dy); |
| 78 |
i_fill_t *fill = i_new_fill_image(src_img, matrix, x_offset, y_offset, combine); |
| 79 |
fill = i_new_fill_fount(0, 0, 100, 100, i_ft_linear, i_ft_linear, |
| 80 |
i_fr_triangle, 0, i_fts_grid, 9, 1, segs); |
| 81 |
i_fill_destroy(fill); |
| 82 |
|
| 83 |
# I/O Layers |
| 84 |
ssize_t count = i_io_peekn(ig, buffer, sizeof(buffer)); |
| 85 |
ssize_t result = i_io_write(io, buffer, size) |
| 86 |
char buffer[BUFSIZ] |
| 87 |
ssize_t len = i_io_gets(buffer, sizeof(buffer), '\n'); |
| 88 |
io_glue_destroy(ig); |
| 89 |
|
| 90 |
# Image |
| 91 |
|
| 92 |
# Image creation/destruction |
| 93 |
i_img *img = i_sametype(src, width, height); |
| 94 |
i_img *img = i_sametype_chans(src, width, height, channels); |
| 95 |
i_img *img = im_img_16_new(aIMCTX, width, height, channels); |
| 96 |
i_img *img = i_img_16_new(width, height, channels); |
| 97 |
i_img *img = im_img_8_new(aIMCTX, width, height, channels); |
| 98 |
i_img *img = i_img_8_new(width, height, channels); |
| 99 |
i_img *img = im_img_double_new(aIMCTX, width, height, channels); |
| 100 |
i_img *img = i_img_double_new(width, height, channels); |
| 101 |
i_img *img = im_img_pal_new(aIMCTX, width, height, channels, max_palette_size) |
| 102 |
i_img *img = i_img_pal_new(width, height, channels, max_palette_size) |
| 103 |
i_img_destroy(img) |
| 104 |
|
| 105 |
# Image Implementation |
| 106 |
i_img *im = im_img_alloc(aIMCTX); |
| 107 |
i_img *im = i_img_alloc(); |
| 108 |
im_img_init(aIMCTX, im); |
| 109 |
i_img_init(im); |
| 110 |
|
| 111 |
# Image Information |
| 112 |
// only channel 0 writable |
| 113 |
i_img_setmask(img, 0x01); |
| 114 |
int mask = i_img_getmask(img); |
| 115 |
int channels = i_img_getchannels(img); |
| 116 |
i_img_dim width = i_img_get_width(im); |
| 117 |
i_img_dim height = i_img_get_height(im); |
| 118 |
i_color_model_t cm = i_img_color_model(im); |
| 119 |
int alpha_channel; |
| 120 |
int has_alpha = i_img_alpha_channel(im, &alpha_channel); |
| 121 |
int color_channels = i_img_color_channels(im); |
| 122 |
|
| 123 |
# Image quantization |
| 124 |
|
| 125 |
# Logging |
| 126 |
|
| 127 |
# mutex |
| 128 |
i_mutex_t mutex; |
| 129 |
|
| 130 |
# Mutex functions |
| 131 |
i_mutex_t m = i_mutex_new(); |
| 132 |
i_mutex_destroy(m); |
| 133 |
i_mutex_lock(m); |
| 134 |
i_mutex_unlock(m); |
| 135 |
|
| 136 |
# Paletted images |
| 137 |
|
| 138 |
# Tags |
| 139 |
i_tags_set(&img->tags, "i_comment", -1); |
| 140 |
i_tags_setn(&img->tags, "i_xres", 204); |
| 141 |
i_tags_setn(&img->tags, "i_yres", 196); |
| 142 |
|
| 143 |
=head1 DESCRIPTION |
| 144 |
|
| 145 |
=head2 Blit tools |
| 146 |
|
| 147 |
=over |
| 148 |
|
| 149 |
=item i_render_color(r, x, y, width, source, color) |
| 150 |
|
| 151 |
Render the given color with the coverage specified by C<source[0]> to |
| 152 |
C<source[width-1]>. |
| 153 |
|
| 154 |
Renders in normal combine mode. |
| 155 |
|
| 156 |
|
| 157 |
=for comment |
| 158 |
From: File render.im |
| 159 |
|
| 160 |
=item i_render_delete(r) |
| 161 |
|
| 162 |
Release an C<i_render> object. |
| 163 |
|
| 164 |
|
| 165 |
=for comment |
| 166 |
From: File render.im |
| 167 |
|
| 168 |
=item i_render_fill(r, x, y, width, source, fill) |
| 169 |
|
| 170 |
Render the given fill with the coverage in C<source[0]> through |
| 171 |
C<source[width-1]>. |
| 172 |
|
| 173 |
|
| 174 |
=for comment |
| 175 |
From: File render.im |
| 176 |
|
| 177 |
=item i_render_line(r, x, y, width, source, fill) |
| 178 |
|
| 179 |
Render the given fill with the coverage in C<source[0]> through |
| 180 |
C<source[width-1]>. |
| 181 |
|
| 182 |
|
| 183 |
=for comment |
| 184 |
From: File render.im |
| 185 |
|
| 186 |
=item i_render_linef(r, x, y, width, source, fill) |
| 187 |
|
| 188 |
Render the given fill with the coverage in C<source[0]> through |
| 189 |
C<source[width-1]>. |
| 190 |
|
| 191 |
|
| 192 |
=for comment |
| 193 |
From: File render.im |
| 194 |
|
| 195 |
=item i_render_new(im, width) |
| 196 |
|
| 197 |
Allocate a new C<i_render> object and initialize it. |
| 198 |
|
| 199 |
|
| 200 |
=for comment |
| 201 |
From: File render.im |
| 202 |
|
| 203 |
|
| 204 |
=back |
| 205 |
|
| 206 |
=head2 Data Types |
| 207 |
|
| 208 |
=over |
| 209 |
|
| 210 |
=item i_img |
| 211 |
|
| 212 |
i_img *img; |
| 213 |
|
| 214 |
This is Imager's image type. |
| 215 |
|
| 216 |
It contains the following members: |
| 217 |
|
| 218 |
=over |
| 219 |
|
| 220 |
=item * |
| 221 |
|
| 222 |
C<channels> - the number of channels in the image |
| 223 |
|
| 224 |
=item * |
| 225 |
|
| 226 |
C<xsize>, C<ysize> - the width and height of the image in pixels |
| 227 |
|
| 228 |
=item * |
| 229 |
|
| 230 |
C<bytes> - the number of bytes used to store the image data. Undefined |
| 231 |
where virtual is non-zero. |
| 232 |
|
| 233 |
=item * |
| 234 |
|
| 235 |
C<ch_mask> - a mask of writable channels. eg. if this is 6 then only |
| 236 |
channels 1 and 2 are writable. There may be bits set for which there |
| 237 |
are no channels in the image. |
| 238 |
|
| 239 |
=item * |
| 240 |
|
| 241 |
C<bits> - the number of bits stored per sample. Should be one of |
| 242 |
i_8_bits, i_16_bits, i_double_bits. |
| 243 |
|
| 244 |
=item * |
| 245 |
|
| 246 |
C<type> - either i_direct_type for direct color images, or i_palette_type |
| 247 |
for paletted images. |
| 248 |
|
| 249 |
=item * |
| 250 |
|
| 251 |
C<isvirtual> - if zero then this image is-self contained. If non-zero |
| 252 |
then this image could be an interface to some other implementation. |
| 253 |
|
| 254 |
=item * |
| 255 |
|
| 256 |
C<idata> - the image data. This should not be directly accessed. A new |
| 257 |
image implementation can use this to store its image data. |
| 258 |
i_img_destroy() will myfree() this pointer if it's non-null. |
| 259 |
|
| 260 |
=item * |
| 261 |
|
| 262 |
C<tags> - a structure storing the image's tags. This should only be |
| 263 |
accessed via the i_tags_*() functions. |
| 264 |
|
| 265 |
=item * |
| 266 |
|
| 267 |
C<ext_data> - a pointer for use internal to an image implementation. |
| 268 |
This should be freed by the image's destroy handler. |
| 269 |
|
| 270 |
=item * |
| 271 |
|
| 272 |
C<im_data> - data internal to Imager. This is initialized by |
| 273 |
i_img_init(). |
| 274 |
|
| 275 |
=item * |
| 276 |
|
| 277 |
i_f_ppix, i_f_ppixf, i_f_plin, i_f_plinf, i_f_gpix, i_f_gpixf, |
| 278 |
i_f_glin, i_f_glinf, i_f_gsamp, i_f_gampf - implementations for each |
| 279 |
of the required image functions. An image implementation should |
| 280 |
initialize these between calling i_img_alloc() and i_img_init(). |
| 281 |
|
| 282 |
=item * |
| 283 |
|
| 284 |
i_f_gpal, i_f_ppal, i_f_addcolors, i_f_getcolors, i_f_colorcount, |
| 285 |
i_f_maxcolors, i_f_findcolor, i_f_setcolors - implementations for each |
| 286 |
paletted image function. |
| 287 |
|
| 288 |
=item * |
| 289 |
|
| 290 |
i_f_destroy - custom image destruction function. This should be used |
| 291 |
to release memory if necessary. |
| 292 |
|
| 293 |
=item * |
| 294 |
|
| 295 |
i_f_gsamp_bits - implements i_gsamp_bits() for this image. |
| 296 |
|
| 297 |
=item * |
| 298 |
|
| 299 |
i_f_psamp_bits - implements i_psamp_bits() for this image. |
| 300 |
|
| 301 |
=item * |
| 302 |
|
| 303 |
i_f_psamp - implements psamp() for this image. |
| 304 |
|
| 305 |
=item * |
| 306 |
|
| 307 |
i_f_psampf - implements psamp() for this image. |
| 308 |
|
| 309 |
=item * |
| 310 |
|
| 311 |
C<im_data> - image specific data internal to Imager. |
| 312 |
|
| 313 |
=item * |
| 314 |
|
| 315 |
C<context> - the Imager API context this image belongs to. |
| 316 |
|
| 317 |
=back |
| 318 |
|
| 319 |
|
| 320 |
=for comment |
| 321 |
From: File imdatatypes.h |
| 322 |
|
| 323 |
=item i_color |
| 324 |
|
| 325 |
i_color black; |
| 326 |
black.rgba.r = black.rgba.g = black.rgba.b = black.rgba.a = 0; |
| 327 |
|
| 328 |
Type for 8-bit/sample color. |
| 329 |
|
| 330 |
Samples as per; |
| 331 |
|
| 332 |
i_color c; |
| 333 |
|
| 334 |
i_color is a union of: |
| 335 |
|
| 336 |
=over |
| 337 |
|
| 338 |
=item * |
| 339 |
|
| 340 |
gray - contains a single element gray_color, eg. C<c.gray.gray_color> |
| 341 |
|
| 342 |
=item * |
| 343 |
|
| 344 |
C<rgb> - contains three elements C<r>, C<g>, C<b>, eg. C<c.rgb.r> |
| 345 |
|
| 346 |
=item * |
| 347 |
|
| 348 |
C<rgba> - contains four elements C<r>, C<g>, C<b>, C<a>, eg. C<c.rgba.a> |
| 349 |
|
| 350 |
=item * |
| 351 |
|
| 352 |
C<cmyk> - contains four elements C<c>, C<m>, C<y>, C<k>, |
| 353 |
eg. C<c.cmyk.y>. Note that Imager never uses CMYK colors except when |
| 354 |
reading/writing files. |
| 355 |
|
| 356 |
=item * |
| 357 |
|
| 358 |
channels - an array of four channels, eg C<c.channels[2]>. |
| 359 |
|
| 360 |
=back |
| 361 |
|
| 362 |
|
| 363 |
=for comment |
| 364 |
From: File imdatatypes.h |
| 365 |
|
| 366 |
=item i_fcolor |
| 367 |
|
| 368 |
This is the double/sample color type. |
| 369 |
|
| 370 |
Its layout exactly corresponds to i_color. |
| 371 |
|
| 372 |
|
| 373 |
=for comment |
| 374 |
From: File imdatatypes.h |
| 375 |
|
| 376 |
=item i_fill_t |
| 377 |
|
| 378 |
i_fill_t *fill; |
| 379 |
|
| 380 |
This is the "abstract" base type for Imager's fill types. |
| 381 |
|
| 382 |
Unless you're implementing a new fill type you'll typically treat this |
| 383 |
as an opaque type. |
| 384 |
|
| 385 |
|
| 386 |
=for comment |
| 387 |
From: File imdatatypes.h |
| 388 |
|
| 389 |
=item i_poly_fill_mode_t |
| 390 |
|
| 391 |
Control how polygons are filled. Has the following values: |
| 392 |
|
| 393 |
=over |
| 394 |
|
| 395 |
=item * |
| 396 |
|
| 397 |
C<i_pfm_evenodd> - simple even-odd fills. |
| 398 |
|
| 399 |
=item * |
| 400 |
|
| 401 |
C<i_pfm_nonzero> - non-zero winding rule fills. |
| 402 |
|
| 403 |
=back |
| 404 |
|
| 405 |
|
| 406 |
=for comment |
| 407 |
From: File imdatatypes.h |
| 408 |
|
| 409 |
=item i_polygon_t |
| 410 |
|
| 411 |
Represents a polygon. Has the following members: |
| 412 |
|
| 413 |
=over |
| 414 |
|
| 415 |
=item * |
| 416 |
|
| 417 |
C<x>, C<y> - arrays of x and y locations of vertices. |
| 418 |
|
| 419 |
=item * |
| 420 |
|
| 421 |
C<count> - the number of entries in the C<x> and C<y> arrays. |
| 422 |
|
| 423 |
=back |
| 424 |
|
| 425 |
|
| 426 |
=for comment |
| 427 |
From: File imdatatypes.h |
| 428 |
|
| 429 |
=item im_context_t |
| 430 |
|
| 431 |
Imager's per-thread context. |
| 432 |
|
| 433 |
|
| 434 |
=for comment |
| 435 |
From: File imdatatypes.h |
| 436 |
|
| 437 |
=item im_slot_t |
| 438 |
|
| 439 |
Represents a slot in the context object. |
| 440 |
|
| 441 |
|
| 442 |
=for comment |
| 443 |
From: File imdatatypes.h |
| 444 |
|
| 445 |
=item i_img_dim |
| 446 |
|
| 447 |
i_img_dim x, y; |
| 448 |
|
| 449 |
A signed integer type that represents an image dimension or ordinate. |
| 450 |
|
| 451 |
May be larger than int on some platforms. |
| 452 |
|
| 453 |
|
| 454 |
=for comment |
| 455 |
From: File imdatatypes.h |
| 456 |
|
| 457 |
=item i_img_dim_u |
| 458 |
|
| 459 |
i_img_dim_u limit; |
| 460 |
|
| 461 |
An unsigned variant of L</i_img_dim>. |
| 462 |
|
| 463 |
|
| 464 |
=for comment |
| 465 |
From: File imdatatypes.h |
| 466 |
|
| 467 |
=item i_color_model_t |
| 468 |
|
| 469 |
Returned by L</i_img_color_model(im)> to indicate the color model of |
| 470 |
the image. |
| 471 |
|
| 472 |
An enumerated type with the following possible values: |
| 473 |
|
| 474 |
=over |
| 475 |
|
| 476 |
=item * |
| 477 |
|
| 478 |
C<icm_unknown> - the image has no usable color data. In future |
| 479 |
versions of Imager this will be returned in a few limited cases, |
| 480 |
eg. when the source image is CMYK and the user has requested no color |
| 481 |
translation is done. |
| 482 |
|
| 483 |
=item * |
| 484 |
|
| 485 |
C<icm_gray> - gray scale with no alpha channel. |
| 486 |
|
| 487 |
=item * |
| 488 |
|
| 489 |
C<icm_gray_alpha> - gray scale with an alpha channel. |
| 490 |
|
| 491 |
=item * |
| 492 |
|
| 493 |
C<icm_rgb> - RGB |
| 494 |
|
| 495 |
=item * |
| 496 |
|
| 497 |
C<icm_rgb_alpha> - RGB with an alpha channel. |
| 498 |
|
| 499 |
=back |
| 500 |
|
| 501 |
|
| 502 |
=for comment |
| 503 |
From: File imdatatypes.h |
| 504 |
|
| 505 |
=item i_DF |
| 506 |
|
| 507 |
printf("left %" i_DF "\n", i_DFc(x)); |
| 508 |
|
| 509 |
This is a constant string that can be used with functions like |
| 510 |
printf() to format i_img_dim values after they're been cast with i_DFc(). |
| 511 |
|
| 512 |
Does not include the leading C<%>. |
| 513 |
|
| 514 |
|
| 515 |
=for comment |
| 516 |
From: File imdatatypes.h |
| 517 |
|
| 518 |
=item i_DFc |
| 519 |
|
| 520 |
Cast an C<i_img_dim> value to a type for use with the i_DF format |
| 521 |
string. |
| 522 |
|
| 523 |
|
| 524 |
=for comment |
| 525 |
From: File imdatatypes.h |
| 526 |
|
| 527 |
=item i_DFcp |
| 528 |
|
| 529 |
Casts two C<i_img_dim> values for use with the i_DF (or i_DFp) format. |
| 530 |
|
| 531 |
|
| 532 |
=for comment |
| 533 |
From: File imdatatypes.h |
| 534 |
|
| 535 |
=item i_DFp |
| 536 |
|
| 537 |
printf("point (" i_DFp ")\n", i_DFcp(x, y)); |
| 538 |
|
| 539 |
Format a pair of C<i_img_dim> values. This format string I<does> |
| 540 |
include the leading C<%>. |
| 541 |
|
| 542 |
|
| 543 |
=for comment |
| 544 |
From: File imdatatypes.h |
| 545 |
|
| 546 |
|
| 547 |
=back |
| 548 |
|
| 549 |
=head2 Drawing |
| 550 |
|
| 551 |
=over |
| 552 |
|
| 553 |
=item i_arc(im, x, y, rad, d1, d2, color) |
| 554 |
|
| 555 |
|
| 556 |
i_arc(im, 50, 50, 20, 45, 135, &color); |
| 557 |
|
| 558 |
Fills an arc centered at (x,y) with radius I<rad> covering the range |
| 559 |
of angles in degrees from d1 to d2, with the color. |
| 560 |
|
| 561 |
|
| 562 |
=for comment |
| 563 |
From: File draw.c |
| 564 |
|
| 565 |
=item i_arc_aa(im, x, y, rad, d1, d2, color) |
| 566 |
|
| 567 |
|
| 568 |
i_arc_aa(im, 50, 50, 35, 90, 135, &color); |
| 569 |
|
| 570 |
Anti-alias fills an arc centered at (x,y) with radius I<rad> covering |
| 571 |
the range of angles in degrees from d1 to d2, with the color. |
| 572 |
|
| 573 |
|
| 574 |
=for comment |
| 575 |
From: File draw.c |
| 576 |
|
| 577 |
=item i_arc_aa_cfill(im, x, y, rad, d1, d2, fill) |
| 578 |
|
| 579 |
|
| 580 |
i_arc_aa_cfill(im, 50, 50, 35, 90, 135, fill); |
| 581 |
|
| 582 |
Anti-alias fills an arc centered at (x,y) with radius I<rad> covering |
| 583 |
the range of angles in degrees from d1 to d2, with the fill object. |
| 584 |
|
| 585 |
|
| 586 |
=for comment |
| 587 |
From: File draw.c |
| 588 |
|
| 589 |
=item i_arc_cfill(im, x, y, rad, d1, d2, fill) |
| 590 |
|
| 591 |
|
| 592 |
i_arc_cfill(im, 50, 50, 35, 90, 135, fill); |
| 593 |
|
| 594 |
Fills an arc centered at (x,y) with radius I<rad> covering the range |
| 595 |
of angles in degrees from d1 to d2, with the fill object. |
| 596 |
|
| 597 |
|
| 598 |
=for comment |
| 599 |
From: File draw.c |
| 600 |
|
| 601 |
=item i_box(im, x1, y1, x2, y2, color) |
| 602 |
|
| 603 |
|
| 604 |
i_box(im, 0, 0, im->xsize-1, im->ysize-1, &color). |
| 605 |
|
| 606 |
Outlines the box from (x1,y1) to (x2,y2) inclusive with I<color>. |
| 607 |
|
| 608 |
|
| 609 |
=for comment |
| 610 |
From: File draw.c |
| 611 |
|
| 612 |
=item i_box_cfill(im, x1, y1, x2, y2, fill) |
| 613 |
|
| 614 |
|
| 615 |
i_box_cfill(im, 0, 0, im->xsize-1, im->ysize-1, fill); |
| 616 |
|
| 617 |
Fills the box from (x1,y1) to (x2,y2) inclusive with fill. |
| 618 |
|
| 619 |
|
| 620 |
=for comment |
| 621 |
From: File draw.c |
| 622 |
|
| 623 |
=item i_box_filled(im, x1, y1, x2, y2, color) |
| 624 |
|
| 625 |
|
| 626 |
i_box_filled(im, 0, 0, im->xsize-1, im->ysize-1, &color); |
| 627 |
|
| 628 |
Fills the box from (x1,y1) to (x2,y2) inclusive with color. |
| 629 |
|
| 630 |
|
| 631 |
=for comment |
| 632 |
From: File draw.c |
| 633 |
|
| 634 |
=item i_circle_aa(im, x, y, rad, color) |
| 635 |
|
| 636 |
|
| 637 |
i_circle_aa(im, 50, 50, 45, &color); |
| 638 |
|
| 639 |
Anti-alias fills a circle centered at (x,y) for radius I<rad> with |
| 640 |
color. |
| 641 |
|
| 642 |
|
| 643 |
=for comment |
| 644 |
From: File draw.c |
| 645 |
|
| 646 |
=item i_flood_cfill(C<im>, C<seedx>, C<seedy>, C<fill>) |
| 647 |
|
| 648 |
|
| 649 |
i_flood_cfill(im, 50, 50, fill); |
| 650 |
|
| 651 |
Flood fills the 4-connected region starting from the point (C<seedx>, |
| 652 |
C<seedy>) with C<fill>. |
| 653 |
|
| 654 |
Returns false if (C<seedx>, C<seedy>) are outside the image. |
| 655 |
|
| 656 |
|
| 657 |
=for comment |
| 658 |
From: File draw.c |
| 659 |
|
| 660 |
=item i_flood_cfill_border(C<im>, C<seedx>, C<seedy>, C<fill>, C<border>) |
| 661 |
|
| 662 |
|
| 663 |
i_flood_cfill_border(im, 50, 50, fill, border); |
| 664 |
|
| 665 |
Flood fills the 4-connected region starting from the point (C<seedx>, |
| 666 |
C<seedy>) with C<fill>, the fill stops when it reaches pixels of color |
| 667 |
C<border>. |
| 668 |
|
| 669 |
Returns false if (C<seedx>, C<seedy>) are outside the image. |
| 670 |
|
| 671 |
|
| 672 |
=for comment |
| 673 |
From: File draw.c |
| 674 |
|
| 675 |
=item i_flood_fill(C<im>, C<seedx>, C<seedy>, C<color>) |
| 676 |
|
| 677 |
|
| 678 |
i_flood_fill(im, 50, 50, &color); |
| 679 |
|
| 680 |
Flood fills the 4-connected region starting from the point (C<seedx>, |
| 681 |
C<seedy>) with I<color>. |
| 682 |
|
| 683 |
Returns false if (C<seedx>, C<seedy>) are outside the image. |
| 684 |
|
| 685 |
|
| 686 |
=for comment |
| 687 |
From: File draw.c |
| 688 |
|
| 689 |
=item i_flood_fill_border(C<im>, C<seedx>, C<seedy>, C<color>, C<border>) |
| 690 |
|
| 691 |
|
| 692 |
i_flood_fill_border(im, 50, 50, &color, &border); |
| 693 |
|
| 694 |
Flood fills the 4-connected region starting from the point (C<seedx>, |
| 695 |
C<seedy>) with C<color>, fill stops when the fill reaches a pixels |
| 696 |
with color C<border>. |
| 697 |
|
| 698 |
Returns false if (C<seedx>, C<seedy>) are outside the image. |
| 699 |
|
| 700 |
|
| 701 |
=for comment |
| 702 |
From: File draw.c |
| 703 |
|
| 704 |
=item i_glin(im, l, r, y, colors) |
| 705 |
|
| 706 |
|
| 707 |
Retrieves (r-l) pixels starting from (l,y) into I<colors>. |
| 708 |
|
| 709 |
Returns the number of pixels retrieved. |
| 710 |
|
| 711 |
|
| 712 |
=for comment |
| 713 |
From: File imext.c |
| 714 |
|
| 715 |
=item i_glinf(im, l, r, y, colors) |
| 716 |
|
| 717 |
|
| 718 |
Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating |
| 719 |
point colors. |
| 720 |
|
| 721 |
Returns the number of pixels retrieved. |
| 722 |
|
| 723 |
|
| 724 |
=for comment |
| 725 |
From: File imext.c |
| 726 |
|
| 727 |
=item i_gpal(im, left, right, y, indexes) |
| 728 |
|
| 729 |
|
| 730 |
Reads palette indexes for the horizontal line (left, y) to (right-1, |
| 731 |
y) into C<indexes>. |
| 732 |
|
| 733 |
Returns the number of indexes read. |
| 734 |
|
| 735 |
Always returns 0 for direct color images. |
| 736 |
|
| 737 |
|
| 738 |
=for comment |
| 739 |
From: File imext.c |
| 740 |
|
| 741 |
=item i_gpix(im, C<x>, C<y>, C<color>) |
| 742 |
|
| 743 |
|
| 744 |
Retrieves the C<color> of the pixel (x,y). |
| 745 |
|
| 746 |
Returns 0 if the pixel was retrieved, or -1 if not. |
| 747 |
|
| 748 |
|
| 749 |
=for comment |
| 750 |
From: File imext.c |
| 751 |
|
| 752 |
=item i_gpixf(im, C<x>, C<y>, C<fcolor>) |
| 753 |
|
| 754 |
|
| 755 |
Retrieves the color of the pixel (x,y) as a floating point color into |
| 756 |
C<fcolor>. |
| 757 |
|
| 758 |
Returns 0 if the pixel was retrieved, or -1 if not. |
| 759 |
|
| 760 |
|
| 761 |
=for comment |
| 762 |
From: File imext.c |
| 763 |
|
| 764 |
=item i_gsamp(im, left, right, y, samples, channels, channel_count) |
| 765 |
|
| 766 |
|
| 767 |
Reads sample values from C<im> for the horizontal line (left, y) to |
| 768 |
(right-1,y) for the channels specified by C<channels>, an array of int |
| 769 |
with C<channel_count> elements. |
| 770 |
|
| 771 |
If channels is NULL then the first channels_count channels are retrieved for |
| 772 |
each pixel. |
| 773 |
|
| 774 |
Returns the number of samples read (which should be (right-left) * |
| 775 |
channel_count) |
| 776 |
|
| 777 |
|
| 778 |
=for comment |
| 779 |
From: File imext.c |
| 780 |
|
| 781 |
=item i_gsamp_bg(im, l, r, y, samples, out_channels, background) |
| 782 |
|
| 783 |
|
| 784 |
Like C<i_gsampf()> but applies the source image color over a supplied |
| 785 |
background color. |
| 786 |
|
| 787 |
This is intended for output to image formats that don't support alpha |
| 788 |
channels. |
| 789 |
|
| 790 |
|
| 791 |
=for comment |
| 792 |
From: File paste.im |
| 793 |
|
| 794 |
=item i_gsamp_bits(im, left, right, y, samples, channels, channel_count, bits) |
| 795 |
|
| 796 |
Reads integer samples scaled to C<bits> bits of precision into the |
| 797 |
C<unsigned int> array C<samples>. |
| 798 |
|
| 799 |
Expect this to be slow unless C<< bits == im->bits >>. |
| 800 |
|
| 801 |
Returns the number of samples copied, or -1 on error. |
| 802 |
|
| 803 |
Not all image types implement this method. |
| 804 |
|
| 805 |
Pushes errors, but does not call C<i_clear_error()>. |
| 806 |
|
| 807 |
|
| 808 |
=for comment |
| 809 |
From: File imext.c |
| 810 |
|
| 811 |
=item i_gsampf(im, left, right, y, samples, channels, channel_count) |
| 812 |
|
| 813 |
|
| 814 |
Reads floating point sample values from C<im> for the horizontal line |
| 815 |
(left, y) to (right-1,y) for the channels specified by C<channels>, an |
| 816 |
array of int with channel_count elements. |
| 817 |
|
| 818 |
If C<channels> is NULL then the first C<channel_count> channels are |
| 819 |
retrieved for each pixel. |
| 820 |
|
| 821 |
Returns the number of samples read (which should be (C<right>-C<left>) |
| 822 |
* C<channel_count>) |
| 823 |
|
| 824 |
|
| 825 |
=for comment |
| 826 |
From: File imext.c |
| 827 |
|
| 828 |
=item i_gsampf_bg(im, l, r, y, samples, out_channels, background) |
| 829 |
|
| 830 |
|
| 831 |
Like C<i_gsampf()> but applies the source image color over a supplied |
| 832 |
background color. |
| 833 |
|
| 834 |
This is intended for output to image formats that don't support alpha |
| 835 |
channels. |
| 836 |
|
| 837 |
|
| 838 |
=for comment |
| 839 |
From: File paste.im |
| 840 |
|
| 841 |
=item i_line(C<im>, C<x1>, C<y1>, C<x2>, C<y2>, C<color>, C<endp>) |
| 842 |
|
| 843 |
|
| 844 |
=for stopwords Bresenham's |
| 845 |
|
| 846 |
Draw a line to image using Bresenham's line drawing algorithm |
| 847 |
|
| 848 |
im - image to draw to |
| 849 |
x1 - starting x coordinate |
| 850 |
y1 - starting x coordinate |
| 851 |
x2 - starting x coordinate |
| 852 |
y2 - starting x coordinate |
| 853 |
color - color to write to image |
| 854 |
endp - endpoint flag (boolean) |
| 855 |
|
| 856 |
|
| 857 |
=for comment |
| 858 |
From: File draw.c |
| 859 |
|
| 860 |
=item i_line_aa(C<im>, C<x1>, C<x2>, C<y1>, C<y2>, C<color>, C<endp>) |
| 861 |
|
| 862 |
|
| 863 |
Anti-alias draws a line from (x1,y1) to (x2, y2) in color. |
| 864 |
|
| 865 |
The point (x2, y2) is drawn only if C<endp> is set. |
| 866 |
|
| 867 |
|
| 868 |
=for comment |
| 869 |
From: File draw.c |
| 870 |
|
| 871 |
=item i_plin(im, l, r, y, colors) |
| 872 |
|
| 873 |
|
| 874 |
Sets (r-l) pixels starting from (l,y) using (r-l) values from |
| 875 |
I<colors>. |
| 876 |
|
| 877 |
Returns the number of pixels set. |
| 878 |
|
| 879 |
|
| 880 |
=for comment |
| 881 |
From: File imext.c |
| 882 |
|
| 883 |
=item i_plinf(im, C<left>, C<right>, C<fcolors>) |
| 884 |
|
| 885 |
|
| 886 |
Sets (right-left) pixels starting from (left,y) using (right-left) |
| 887 |
floating point colors from C<fcolors>. |
| 888 |
|
| 889 |
Returns the number of pixels set. |
| 890 |
|
| 891 |
|
| 892 |
=for comment |
| 893 |
From: File imext.c |
| 894 |
|
| 895 |
=item i_poly_aa_cfill_m(im, count, x, y, mode, fill) |
| 896 |
|
| 897 |
i_poly_aa_cfill(im, count, x, y, mode, fill); |
| 898 |
|
| 899 |
Fill a polygon defined by the points specified by the x and y arrays with |
| 900 |
the fill specified by C<fill>. |
| 901 |
|
| 902 |
|
| 903 |
=for comment |
| 904 |
From: File polygon.c |
| 905 |
|
| 906 |
=item i_poly_aa_m(im, count, x, y, mode, color) |
| 907 |
|
| 908 |
i_poly_aa_m(im, count, x, y, mode, color); |
| 909 |
|
| 910 |
Fill a polygon defined by the points specified by the x and y arrays with |
| 911 |
the color specified by C<color>. |
| 912 |
|
| 913 |
|
| 914 |
=for comment |
| 915 |
From: File polygon.c |
| 916 |
|
| 917 |
=item i_poly_poly_aa(im, count, polys, mode, color) |
| 918 |
|
| 919 |
i_poly_poly_aa(im, 1, &poly, mode, color); |
| 920 |
|
| 921 |
Fill the C<count> polygons defined by C<polys> the color specified by |
| 922 |
C<color>. |
| 923 |
|
| 924 |
At least one polygon must be supplied. |
| 925 |
|
| 926 |
All polygons must have at least 3 points. |
| 927 |
|
| 928 |
|
| 929 |
=for comment |
| 930 |
From: File polygon.c |
| 931 |
|
| 932 |
=item i_poly_poly_aa_cfill(im, count, polys, mode, fill) |
| 933 |
|
| 934 |
i_poly_poly_aa_cfill(im, 1, &poly, mode, fill); |
| 935 |
|
| 936 |
Fill the C<count> polygons defined by C<polys> the fill specified by |
| 937 |
C<fill>. |
| 938 |
|
| 939 |
At least one polygon must be supplied. |
| 940 |
|
| 941 |
All polygons must have at least 3 points. |
| 942 |
|
| 943 |
|
| 944 |
=for comment |
| 945 |
From: File polygon.c |
| 946 |
|
| 947 |
=item i_ppal(im, left, right, y, indexes) |
| 948 |
|
| 949 |
|
| 950 |
Writes palette indexes for the horizontal line (left, y) to (right-1, |
| 951 |
y) from C<indexes>. |
| 952 |
|
| 953 |
Returns the number of indexes written. |
| 954 |
|
| 955 |
Always returns 0 for direct color images. |
| 956 |
|
| 957 |
|
| 958 |
=for comment |
| 959 |
From: File imext.c |
| 960 |
|
| 961 |
=item i_ppix(im, x, y, color) |
| 962 |
|
| 963 |
|
| 964 |
Sets the pixel at (x,y) to I<color>. |
| 965 |
|
| 966 |
Returns 0 if the pixel was drawn, or -1 if not. |
| 967 |
|
| 968 |
Does no alpha blending, just copies the channels from the supplied |
| 969 |
color to the image. |
| 970 |
|
| 971 |
|
| 972 |
=for comment |
| 973 |
From: File imext.c |
| 974 |
|
| 975 |
=item i_ppixf(im, C<x>, C<y>, C<fcolor>) |
| 976 |
|
| 977 |
|
| 978 |
Sets the pixel at (C<x>,C<y>) to the floating point color C<fcolor>. |
| 979 |
|
| 980 |
Returns 0 if the pixel was drawn, or -1 if not. |
| 981 |
|
| 982 |
Does no alpha blending, just copies the channels from the supplied |
| 983 |
color to the image. |
| 984 |
|
| 985 |
|
| 986 |
=for comment |
| 987 |
From: File imext.c |
| 988 |
|
| 989 |
=item i_psamp(im, left, right, y, samples, channels, channel_count) |
| 990 |
|
| 991 |
Writes sample values from C<samples> to C<im> for the horizontal line |
| 992 |
(left, y) to (right-1, y) inclusive for the channels specified by |
| 993 |
C<channels>, an array of C<int> with C<channel_count> elements. |
| 994 |
|
| 995 |
If C<channels> is C<NULL> then the first C<channels_count> channels |
| 996 |
are written to for each pixel. |
| 997 |
|
| 998 |
Returns the number of samples written, which should be (right - left) |
| 999 |
* channel_count. If a channel not in the image is in channels, left |
| 1000 |
is negative, left is outside the image or y is outside the image, |
| 1001 |
returns -1 and pushes an error. |
| 1002 |
|
| 1003 |
|
| 1004 |
=for comment |
| 1005 |
From: File immacros.h |
| 1006 |
|
| 1007 |
=item i_psamp_bits(im, left, right, y, samples, channels, channel_count, bits) |
| 1008 |
|
| 1009 |
Writes integer samples scaled to C<bits> bits of precision from the |
| 1010 |
C<unsigned int> array C<samples>. |
| 1011 |
|
| 1012 |
Expect this to be slow unless C<< bits == im->bits >>. |
| 1013 |
|
| 1014 |
Returns the number of samples copied, or -1 on error. |
| 1015 |
|
| 1016 |
Not all image types implement this method. |
| 1017 |
|
| 1018 |
Pushes errors, but does not call C<i_clear_error()>. |
| 1019 |
|
| 1020 |
|
| 1021 |
=for comment |
| 1022 |
From: File imext.c |
| 1023 |
|
| 1024 |
=item i_psampf(im, left, right, y, samples, channels, channel_count) |
| 1025 |
|
| 1026 |
Writes floating point sample values from C<samples> to C<im> for the |
| 1027 |
horizontal line (left, y) to (right-1, y) inclusive for the channels |
| 1028 |
specified by C<channels>, an array of C<int> with C<channel_count> |
| 1029 |
elements. |
| 1030 |
|
| 1031 |
If C<channels> is C<NULL> then the first C<channels_count> channels |
| 1032 |
are written to for each pixel. |
| 1033 |
|
| 1034 |
Returns the number of samples written, which should be (right - left) |
| 1035 |
* channel_count. If a channel not in the image is in channels, left |
| 1036 |
is negative, left is outside the image or y is outside the image, |
| 1037 |
returns -1 and pushes an error. |
| 1038 |
|
| 1039 |
|
| 1040 |
=for comment |
| 1041 |
From: File immacros.h |
| 1042 |
|
| 1043 |
|
| 1044 |
=back |
| 1045 |
|
| 1046 |
=head2 Error handling |
| 1047 |
|
| 1048 |
=over |
| 1049 |
|
| 1050 |
=item i_push_errorf(int code, char const *fmt, ...) |
| 1051 |
|
| 1052 |
i_push_errorf(errno, "Cannot open file %s: %d", filename, errno); |
| 1053 |
|
| 1054 |
A version of i_push_error() that does printf() like formatting. |
| 1055 |
|
| 1056 |
Does not support perl specific format codes. |
| 1057 |
|
| 1058 |
|
| 1059 |
=for comment |
| 1060 |
From: File error.c |
| 1061 |
|
| 1062 |
=item im_clear_error(ctx) |
| 1063 |
X<im_clear_error API>X<i_clear_error API> |
| 1064 |
|
| 1065 |
im_clear_error(aIMCTX); |
| 1066 |
i_clear_error(); |
| 1067 |
|
| 1068 |
Clears the error stack. |
| 1069 |
|
| 1070 |
Called by any Imager function before doing any other processing. |
| 1071 |
|
| 1072 |
Also callable as C<i_clear_error()>. |
| 1073 |
|
| 1074 |
|
| 1075 |
=for comment |
| 1076 |
From: File error.c |
| 1077 |
|
| 1078 |
=item im_push_error(ctx, code, message) |
| 1079 |
X<im_push_error API>X<i_push_error API> |
| 1080 |
|
| 1081 |
i_push_error(0, "Yep, it's broken"); |
| 1082 |
i_push_error(errno, "Error writing"); |
| 1083 |
im_push_error(aIMCTX, 0, "Something is wrong"); |
| 1084 |
|
| 1085 |
Called by an Imager function to push an error message onto the stack. |
| 1086 |
|
| 1087 |
No message is pushed if the stack is full (since this means someone |
| 1088 |
forgot to call i_clear_error(), or that a function that doesn't do |
| 1089 |
error handling is calling function that does.). |
| 1090 |
|
| 1091 |
|
| 1092 |
=for comment |
| 1093 |
From: File error.c |
| 1094 |
|
| 1095 |
=item im_push_errorf(ctx, code, char const *fmt, ...) |
| 1096 |
|
| 1097 |
im_push_errorf(aIMCTX, errno, "Cannot open file %s: %d", filename, errno); |
| 1098 |
|
| 1099 |
A version of im_push_error() that does printf() like formatting. |
| 1100 |
|
| 1101 |
Does not support perl specific format codes. |
| 1102 |
|
| 1103 |
|
| 1104 |
=for comment |
| 1105 |
From: File error.c |
| 1106 |
|
| 1107 |
=item im_push_errorvf(ctx, code, format, args) |
| 1108 |
X<im_push_error_vf API>X<i_push_errorvf API> |
| 1109 |
|
| 1110 |
va_args args; |
| 1111 |
va_start(args, lastarg); |
| 1112 |
im_push_errorvf(ctx, code, format, args); |
| 1113 |
|
| 1114 |
Intended for use by higher level functions, takes a varargs pointer |
| 1115 |
and a format to produce the finally pushed error message. |
| 1116 |
|
| 1117 |
Does not support perl specific format codes. |
| 1118 |
|
| 1119 |
Also callable as C<i_push_errorvf(code, format, args)> |
| 1120 |
|
| 1121 |
|
| 1122 |
=for comment |
| 1123 |
From: File error.c |
| 1124 |
|
| 1125 |
|
| 1126 |
=back |
| 1127 |
|
| 1128 |
=head2 Files |
| 1129 |
|
| 1130 |
=over |
| 1131 |
|
| 1132 |
=item i_get_file_background(im, &bg) |
| 1133 |
|
| 1134 |
|
| 1135 |
Retrieve the file write background color tag from the image. |
| 1136 |
|
| 1137 |
If not present, C<bg> is set to black. |
| 1138 |
|
| 1139 |
Returns 1 if the C<i_background> tag was found and valid. |
| 1140 |
|
| 1141 |
|
| 1142 |
=for comment |
| 1143 |
From: File image.c |
| 1144 |
|
| 1145 |
=item i_get_file_backgroundf(im, &bg) |
| 1146 |
|
| 1147 |
|
| 1148 |
Retrieve the file write background color tag from the image as a |
| 1149 |
floating point color. |
| 1150 |
|
| 1151 |
Implemented in terms of i_get_file_background(). |
| 1152 |
|
| 1153 |
If not present, C<bg> is set to black. |
| 1154 |
|
| 1155 |
Returns 1 if the C<i_background> tag was found and valid. |
| 1156 |
|
| 1157 |
|
| 1158 |
=for comment |
| 1159 |
From: File image.c |
| 1160 |
|
| 1161 |
=item im_get_image_file_limits(ctx, &width, &height, &bytes) |
| 1162 |
X<im_get_image_file_limits API>X<i_get_image_file_limits> |
| 1163 |
|
| 1164 |
im_get_image_file_limits(aIMCTX, &width, &height, &bytes) |
| 1165 |
i_get_image_file_limits(&width, &height, &bytes) |
| 1166 |
|
| 1167 |
Retrieves the file limits set by i_set_image_file_limits(). |
| 1168 |
|
| 1169 |
=over |
| 1170 |
|
| 1171 |
=item * |
| 1172 |
|
| 1173 |
i_img_dim *width, *height - the maximum width and height of the image. |
| 1174 |
|
| 1175 |
=item * |
| 1176 |
|
| 1177 |
size_t *bytes - size in memory of the image in bytes. |
| 1178 |
|
| 1179 |
=back |
| 1180 |
|
| 1181 |
Also callable as C<i_get_image_file_limits(&width, &height, &bytes)>. |
| 1182 |
|
| 1183 |
|
| 1184 |
=for comment |
| 1185 |
From: File limits.c |
| 1186 |
|
| 1187 |
=item im_int_check_image_file_limits(width, height, channels, sample_size) |
| 1188 |
X<im_int_check_image_file_limits API>X<i_int_check_image_file_limits> |
| 1189 |
|
| 1190 |
im_int_check_image_file_limits(aIMCTX, width, height, channels, sizeof(i_sample_t)) |
| 1191 |
i_int_check_image_file_limits(width, height, channels, sizeof(i_sample_t)) |
| 1192 |
|
| 1193 |
Checks the size of a file in memory against the configured image file |
| 1194 |
limits. |
| 1195 |
|
| 1196 |
This also range checks the values to those permitted by Imager and |
| 1197 |
checks for overflows in calculating the size. |
| 1198 |
|
| 1199 |
Returns non-zero if the file is within limits. |
| 1200 |
|
| 1201 |
This function is intended to be called by image file read functions. |
| 1202 |
|
| 1203 |
Also callable as C<i_int_check_image_file_limits(width, height, channels, sizeof(i_sample_t)>. |
| 1204 |
|
| 1205 |
|
| 1206 |
=for comment |
| 1207 |
From: File limits.c |
| 1208 |
|
| 1209 |
=item im_set_image_file_limits(ctx, width, height, bytes) |
| 1210 |
X<im_set_image_file_limits API>X<i_set_image_file_limits API> |
| 1211 |
|
| 1212 |
im_set_image_file_limits(aIMCTX, 500, 500, 1000000); |
| 1213 |
i_set_image_file_limits(500, 500, 1000000); |
| 1214 |
|
| 1215 |
Set limits on the sizes of images read by Imager. |
| 1216 |
|
| 1217 |
Setting a limit to 0 means that limit is ignored. |
| 1218 |
|
| 1219 |
Negative limits result in failure. |
| 1220 |
|
| 1221 |
Parameters: |
| 1222 |
|
| 1223 |
=over |
| 1224 |
|
| 1225 |
=item * |
| 1226 |
|
| 1227 |
i_img_dim width, height - maximum width and height. |
| 1228 |
|
| 1229 |
=item * |
| 1230 |
|
| 1231 |
size_t bytes - maximum size in memory in bytes. A value of zero sets |
| 1232 |
this limit to one gigabyte. |
| 1233 |
|
| 1234 |
=back |
| 1235 |
|
| 1236 |
Returns non-zero on success. |
| 1237 |
|
| 1238 |
Also callable as C<i_set_image_file_limits(width, height, bytes)>. |
| 1239 |
|
| 1240 |
|
| 1241 |
=for comment |
| 1242 |
From: File limits.c |
| 1243 |
|
| 1244 |
|
| 1245 |
=back |
| 1246 |
|
| 1247 |
=head2 Fills |
| 1248 |
|
| 1249 |
=over |
| 1250 |
|
| 1251 |
=item i_new_fill_fount(C<xa>, C<ya>, C<xb>, C<yb>, C<type>, C<repeat>, C<combine>, C<super_sample>, C<ssample_param>, C<count>, C<segs>) |
| 1252 |
|
| 1253 |
|
| 1254 |
fill = i_new_fill_fount(0, 0, 100, 100, i_ft_linear, i_ft_linear, |
| 1255 |
i_fr_triangle, 0, i_fts_grid, 9, 1, segs); |
| 1256 |
|
| 1257 |
|
| 1258 |
Creates a new general fill which fills with a fountain fill. |
| 1259 |
|
| 1260 |
|
| 1261 |
=for comment |
| 1262 |
From: File filters.im |
| 1263 |
|
| 1264 |
=item i_new_fill_hatch(C<fg>, C<bg>, C<combine>, C<hatch>, C<cust_hatch>, C<dx>, C<dy>) |
| 1265 |
|
| 1266 |
|
| 1267 |
i_fill_t *fill = i_new_fill_hatch(&fg_color, &bg_color, combine, hatch, custom_hatch, dx, dy); |
| 1268 |
|
| 1269 |
Creates a new hatched fill with the C<fg> color used for the 1 bits in |
| 1270 |
the hatch and C<bg> for the 0 bits. If C<combine> is non-zero alpha |
| 1271 |
values will be combined. |
| 1272 |
|
| 1273 |
If C<cust_hatch> is non-NULL it should be a pointer to 8 bytes of the |
| 1274 |
hash definition, with the high-bits to the left. |
| 1275 |
|
| 1276 |
If C<cust_hatch> is NULL then one of the standard hatches is used. |
| 1277 |
|
| 1278 |
(C<dx>, C<dy>) are an offset into the hatch which can be used to hatch |
| 1279 |
adjoining areas out of alignment, or to align the origin of a hatch |
| 1280 |
with the side of a filled area. |
| 1281 |
|
| 1282 |
|
| 1283 |
=for comment |
| 1284 |
From: File fills.c |
| 1285 |
|
| 1286 |
=item i_new_fill_hatchf(C<fg>, C<bg>, C<combine>, C<hatch>, C<cust_hatch>, C<dx>, C<dy>) |
| 1287 |
|
| 1288 |
|
| 1289 |
i_fill_t *fill = i_new_fill_hatchf(&fg_fcolor, &bg_fcolor, combine, hatch, custom_hatch, dx, dy); |
| 1290 |
|
| 1291 |
Creates a new hatched fill with the C<fg> color used for the 1 bits in |
| 1292 |
the hatch and C<bg> for the 0 bits. If C<combine> is non-zero alpha |
| 1293 |
values will be combined. |
| 1294 |
|
| 1295 |
If C<cust_hatch> is non-NULL it should be a pointer to 8 bytes of the |
| 1296 |
hash definition, with the high-bits to the left. |
| 1297 |
|
| 1298 |
If C<cust_hatch> is NULL then one of the standard hatches is used. |
| 1299 |
|
| 1300 |
(C<dx>, C<dy>) are an offset into the hatch which can be used to hatch |
| 1301 |
adjoining areas out of alignment, or to align the origin of a hatch |
| 1302 |
with the side of a filled area. |
| 1303 |
|
| 1304 |
|
| 1305 |
=for comment |
| 1306 |
From: File fills.c |
| 1307 |
|
| 1308 |
=item i_new_fill_image(C<im>, C<matrix>, C<xoff>, C<yoff>, C<combine>) |
| 1309 |
|
| 1310 |
|
| 1311 |
i_fill_t *fill = i_new_fill_image(src_img, matrix, x_offset, y_offset, combine); |
| 1312 |
|
| 1313 |
Create an image based fill. |
| 1314 |
|
| 1315 |
matrix is an array of 9 doubles representing a transformation matrix. |
| 1316 |
|
| 1317 |
C<xoff> and C<yoff> are the offset into the image to start filling from. |
| 1318 |
|
| 1319 |
|
| 1320 |
=for comment |
| 1321 |
From: File fills.c |
| 1322 |
|
| 1323 |
=item i_new_fill_solid(color, combine) |
| 1324 |
|
| 1325 |
|
| 1326 |
i_fill_t *fill = i_new_fill_solid(&color, combine); |
| 1327 |
|
| 1328 |
Create a solid fill based on an 8-bit color. |
| 1329 |
|
| 1330 |
If combine is non-zero then alpha values will be combined. |
| 1331 |
|
| 1332 |
|
| 1333 |
=for comment |
| 1334 |
From: File fills.c |
| 1335 |
|
| 1336 |
=item i_new_fill_solidf(color, combine) |
| 1337 |
|
| 1338 |
|
| 1339 |
i_fill_t *fill = i_new_fill_solidf(&fcolor, combine); |
| 1340 |
|
| 1341 |
Create a solid fill based on a float color. |
| 1342 |
|
| 1343 |
If combine is non-zero then alpha values will be combined. |
| 1344 |
|
| 1345 |
|
| 1346 |
=for comment |
| 1347 |
From: File fills.c |
| 1348 |
|
| 1349 |
=item i_fill_destroy(fill) |
| 1350 |
|
| 1351 |
i_fill_destroy(fill); |
| 1352 |
|
| 1353 |
Call to destroy any fill object. |
| 1354 |
|
| 1355 |
|
| 1356 |
=for comment |
| 1357 |
From: File fills.c |
| 1358 |
|
| 1359 |
|
| 1360 |
=back |
| 1361 |
|
| 1362 |
=head2 I/O Layers |
| 1363 |
|
| 1364 |
=over |
| 1365 |
|
| 1366 |
=item im_io_new_bufchain(ctx) |
| 1367 |
X<im_io_new_bufchain API>X<i_io_new_bufchain API> |
| 1368 |
|
| 1369 |
Returns a new io_glue object that has the 'empty' source and but can |
| 1370 |
be written to and read from later (like a pseudo file). |
| 1371 |
|
| 1372 |
Also callable as C<io_new_bufchain()>. |
| 1373 |
|
| 1374 |
|
| 1375 |
=for comment |
| 1376 |
From: File iolayer.c |
| 1377 |
|
| 1378 |
=item im_io_new_buffer(ctx, data, length) |
| 1379 |
X<im_io_new_buffer API>X<io_new_buffer API> |
| 1380 |
|
| 1381 |
Returns a new io_glue object that has the source defined as reading |
| 1382 |
from specified buffer. Note that the buffer is not copied. |
| 1383 |
|
| 1384 |
ctx - an Imager context object |
| 1385 |
data - buffer to read from |
| 1386 |
length - length of buffer |
| 1387 |
|
| 1388 |
Also callable as C<io_new_buffer(data, length>. |
| 1389 |
|
| 1390 |
|
| 1391 |
=for comment |
| 1392 |
From: File iolayer.c |
| 1393 |
|
| 1394 |
=item im_io_new_cb(ctx, p, read_cb, write_cb, seek_cb, close_cb, destroy_cb) |
| 1395 |
X<im_io_new_cb API>X<io_new_cb API> |
| 1396 |
|
| 1397 |
Create a new I/O layer object that calls your supplied callbacks. |
| 1398 |
|
| 1399 |
In general the callbacks should behave like the corresponding POSIX |
| 1400 |
primitives. |
| 1401 |
|
| 1402 |
=over |
| 1403 |
|
| 1404 |
=item * |
| 1405 |
|
| 1406 |
C<read_cb>(p, buffer, length) should read up to C<length> bytes into |
| 1407 |
C<buffer> and return the number of bytes read. At end of file, return |
| 1408 |
0. On error, return -1. |
| 1409 |
|
| 1410 |
=item * |
| 1411 |
|
| 1412 |
C<write_cb>(p, buffer, length) should write up to C<length> bytes from |
| 1413 |
C<buffer> and return the number of bytes written. A return value <= 0 |
| 1414 |
will be treated as an error. |
| 1415 |
|
| 1416 |
=item * |
| 1417 |
|
| 1418 |
C<seekcb>(p, offset, whence) should seek and return the new offset. |
| 1419 |
|
| 1420 |
=item * |
| 1421 |
|
| 1422 |
C<close_cb>(p) should return 0 on success, -1 on failure. |
| 1423 |
|
| 1424 |
=item * |
| 1425 |
|
| 1426 |
C<destroy_cb>(p) should release any memory specific to your callback |
| 1427 |
handlers. |
| 1428 |
|
| 1429 |
=back |
| 1430 |
|
| 1431 |
Also callable as C<io_new_cb(p, readcb, writecb, seekcb, closecb, |
| 1432 |
destroycb)>. |
| 1433 |
|
| 1434 |
|
| 1435 |
=for comment |
| 1436 |
From: File iolayer.c |
| 1437 |
|
| 1438 |
=item im_io_new_fd(ctx, file) |
| 1439 |
X<io_new_fd API>X<im_io_new_fd API> |
| 1440 |
|
| 1441 |
Returns a new io_glue object that has the source defined as reading |
| 1442 |
from specified file descriptor. Note that the interface to receiving |
| 1443 |
data from the io_glue callbacks hasn't been done yet. |
| 1444 |
|
| 1445 |
ctx - and Imager context object |
| 1446 |
file - file descriptor to read/write from |
| 1447 |
|
| 1448 |
Also callable as C<io_new_fd(file)>. |
| 1449 |
|
| 1450 |
|
| 1451 |
=for comment |
| 1452 |
From: File iolayer.c |
| 1453 |
|
| 1454 |
=item i_io_close(io) |
| 1455 |
|
| 1456 |
Flush any pending output and perform the close action for the stream. |
| 1457 |
|
| 1458 |
Returns 0 on success. |
| 1459 |
|
| 1460 |
|
| 1461 |
=for comment |
| 1462 |
From: File iolayer.c |
| 1463 |
|
| 1464 |
=item i_io_flush(io) |
| 1465 |
|
| 1466 |
Flush any buffered output. |
| 1467 |
|
| 1468 |
Returns true on success, |
| 1469 |
|
| 1470 |
|
| 1471 |
=for comment |
| 1472 |
From: File iolayer.c |
| 1473 |
|
| 1474 |
=item i_io_getc(ig) |
| 1475 |
|
| 1476 |
A macro to read a single byte from a buffered I/O glue object. |
| 1477 |
|
| 1478 |
Returns EOF on failure, or a byte. |
| 1479 |
|
| 1480 |
|
| 1481 |
=for comment |
| 1482 |
From: File iolayer.c |
| 1483 |
|
| 1484 |
=item i_io_gets(ig, buffer, size, end_of_line) |
| 1485 |
|
| 1486 |
char buffer[BUFSIZ] |
| 1487 |
ssize_t len = i_io_gets(buffer, sizeof(buffer), '\n'); |
| 1488 |
|
| 1489 |
Read up to C<size>-1 bytes from the stream C<ig> into C<buffer>. |
| 1490 |
|
| 1491 |
If the byte C<end_of_line> is seen then no further bytes will be read. |
| 1492 |
|
| 1493 |
Returns the number of bytes read. |
| 1494 |
|
| 1495 |
Always C<NUL> terminates the buffer. |
| 1496 |
|
| 1497 |
|
| 1498 |
=for comment |
| 1499 |
From: File iolayer.c |
| 1500 |
|
| 1501 |
=item i_io_peekc(ig) |
| 1502 |
|
| 1503 |
Read the next character from the stream without advancing the stream. |
| 1504 |
|
| 1505 |
On error or end of file, return EOF. |
| 1506 |
|
| 1507 |
For unbuffered streams a single character buffer will be setup. |
| 1508 |
|
| 1509 |
|
| 1510 |
=for comment |
| 1511 |
From: File iolayer.c |
| 1512 |
|
| 1513 |
=item i_io_peekn(ig, buffer, size) |
| 1514 |
|
| 1515 |
ssize_t count = i_io_peekn(ig, buffer, sizeof(buffer)); |
| 1516 |
|
| 1517 |
Buffer at least C<size> (at most C<< ig->buf_size >> bytes of data |
| 1518 |
from the stream and return C<size> bytes of it to the caller in |
| 1519 |
C<buffer>. |
| 1520 |
|
| 1521 |
This ignores the buffered state of the stream, and will always setup |
| 1522 |
buffering if needed. |
| 1523 |
|
| 1524 |
If no C<type> parameter is provided to Imager::read() or |
| 1525 |
Imager::read_multi(), Imager will call C<i_io_peekn()> when probing |
| 1526 |
for the file format. |
| 1527 |
|
| 1528 |
Returns -1 on error, 0 if there is no data before EOF, or the number |
| 1529 |
of bytes read into C<buffer>. |
| 1530 |
|
| 1531 |
|
| 1532 |
=for comment |
| 1533 |
From: File iolayer.c |
| 1534 |
|
| 1535 |
=item i_io_putc(ig, c) |
| 1536 |
|
| 1537 |
Write a single character to the stream. |
| 1538 |
|
| 1539 |
On success return c, on error returns EOF |
| 1540 |
|
| 1541 |
|
| 1542 |
=for comment |
| 1543 |
From: File iolayer.c |
| 1544 |
|
| 1545 |
=item i_io_read(io, buffer, size) |
| 1546 |
|
| 1547 |
Read up to C<size> bytes from the stream C<io> into C<buffer>. |
| 1548 |
|
| 1549 |
Returns the number of bytes read. Returns 0 on end of file. Returns |
| 1550 |
-1 on error. |
| 1551 |
|
| 1552 |
|
| 1553 |
=for comment |
| 1554 |
From: File iolayer.c |
| 1555 |
|
| 1556 |
=item i_io_seek(io, offset, whence) |
| 1557 |
|
| 1558 |
Seek within the stream. |
| 1559 |
|
| 1560 |
Acts like perl's seek. |
| 1561 |
|
| 1562 |
|
| 1563 |
=for comment |
| 1564 |
From: File iolayer.c |
| 1565 |
|
| 1566 |
=item i_io_set_buffered(io, buffered) |
| 1567 |
|
| 1568 |
Set the buffering mode of the stream. |
| 1569 |
|
| 1570 |
If you switch buffering off on a stream with buffering on: |
| 1571 |
|
| 1572 |
=over |
| 1573 |
|
| 1574 |
=item * |
| 1575 |
|
| 1576 |
any buffered output will be flushed. |
| 1577 |
|
| 1578 |
=item * |
| 1579 |
|
| 1580 |
any existing buffered input will be consumed before reads become |
| 1581 |
unbuffered. |
| 1582 |
|
| 1583 |
=back |
| 1584 |
|
| 1585 |
Returns true on success. This may fail if any buffered output cannot |
| 1586 |
be flushed. |
| 1587 |
|
| 1588 |
|
| 1589 |
=for comment |
| 1590 |
From: File iolayer.c |
| 1591 |
|
| 1592 |
=item i_io_write(io, buffer, size) |
| 1593 |
|
| 1594 |
ssize_t result = i_io_write(io, buffer, size) |
| 1595 |
|
| 1596 |
Write to the given I/O stream. |
| 1597 |
|
| 1598 |
Returns the number of bytes written. |
| 1599 |
|
| 1600 |
|
| 1601 |
=for comment |
| 1602 |
From: File iolayer.c |
| 1603 |
|
| 1604 |
=item io_slurp(ig, c) |
| 1605 |
X<io_slurp API> |
| 1606 |
|
| 1607 |
Takes the source that the io_glue is bound to and allocates space for |
| 1608 |
a return buffer and returns the entire content in a single buffer. |
| 1609 |
Note: This only works for io_glue objects created by |
| 1610 |
io_new_bufchain(). It is useful for saving to scalars and such. |
| 1611 |
|
| 1612 |
ig - io_glue object |
| 1613 |
c - pointer to a pointer to where data should be copied to |
| 1614 |
|
| 1615 |
char *data; |
| 1616 |
size_t size = io_slurp(ig, &data); |
| 1617 |
... do something with the data ... |
| 1618 |
myfree(data); |
| 1619 |
|
| 1620 |
io_slurp() will abort the program if the supplied I/O layer is not |
| 1621 |
from io_new_bufchain(). |
| 1622 |
|
| 1623 |
|
| 1624 |
=for comment |
| 1625 |
From: File iolayer.c |
| 1626 |
|
| 1627 |
=item io_glue_destroy(ig) |
| 1628 |
X<io_glue_destroy API> |
| 1629 |
|
| 1630 |
io_glue_destroy(ig); |
| 1631 |
|
| 1632 |
Destroy an io_glue objects. Should clean up all related buffers. |
| 1633 |
|
| 1634 |
ig - io_glue object to destroy. |
| 1635 |
|
| 1636 |
|
| 1637 |
=for comment |
| 1638 |
From: File iolayer.c |
| 1639 |
|
| 1640 |
|
| 1641 |
=back |
| 1642 |
|
| 1643 |
=head2 Image |
| 1644 |
|
| 1645 |
=over |
| 1646 |
|
| 1647 |
=item i_copy(source) |
| 1648 |
|
| 1649 |
|
| 1650 |
Creates a new image that is a copy of the image C<source>. |
| 1651 |
|
| 1652 |
Tags are not copied, only the image data. |
| 1653 |
|
| 1654 |
Returns: i_img * |
| 1655 |
|
| 1656 |
|
| 1657 |
=for comment |
| 1658 |
From: File image.c |
| 1659 |
|
| 1660 |
=item i_copyto(C<dest>, C<src>, C<x1>, C<y1>, C<x2>, C<y2>, C<tx>, C<ty>) |
| 1661 |
|
| 1662 |
|
| 1663 |
Copies image data from the area (C<x1>,C<y1>)-[C<x2>,C<y2>] in the |
| 1664 |
source image to a rectangle the same size with it's top-left corner at |
| 1665 |
(C<tx>,C<ty>) in the destination image. |
| 1666 |
|
| 1667 |
If C<x1> > C<x2> or C<y1> > C<y2> then the corresponding co-ordinates |
| 1668 |
are swapped. |
| 1669 |
|
| 1670 |
|
| 1671 |
=for comment |
| 1672 |
From: File paste.im |
| 1673 |
|
| 1674 |
=item i_copyto_trans(C<im>, C<src>, C<x1>, C<y1>, C<x2>, C<y2>, C<tx>, C<ty>, C<trans>) |
| 1675 |
|
| 1676 |
|
| 1677 |
(C<x1>,C<y1>) (C<x2>,C<y2>) specifies the region to copy (in the |
| 1678 |
source coordinates) (C<tx>,C<ty>) specifies the upper left corner for |
| 1679 |
the target image. pass NULL in C<trans> for non transparent i_colors. |
| 1680 |
|
| 1681 |
|
| 1682 |
=for comment |
| 1683 |
From: File image.c |
| 1684 |
|
| 1685 |
=item i_img_info(im, info) |
| 1686 |
|
| 1687 |
|
| 1688 |
Return image information |
| 1689 |
|
| 1690 |
im - Image pointer |
| 1691 |
info - pointer to array to return data |
| 1692 |
|
| 1693 |
info is an array of 4 integers with the following values: |
| 1694 |
|
| 1695 |
info[0] - width |
| 1696 |
info[1] - height |
| 1697 |
info[2] - channels |
| 1698 |
info[3] - channel mask |
| 1699 |
|
| 1700 |
|
| 1701 |
=for comment |
| 1702 |
From: File image.c |
| 1703 |
|
| 1704 |
=item i_rubthru(C<im>, C<src>, C<tx>, C<ty>, C<src_minx>, C<src_miny>, C<src_maxx>, C<src_maxy>) |
| 1705 |
|
| 1706 |
|
| 1707 |
Takes the sub image C<src>[C<src_minx>, C<src_maxx>)[C<src_miny>, C<src_maxy>)> and |
| 1708 |
overlays it at (C<tx>,C<ty>) on the image object. |
| 1709 |
|
| 1710 |
The alpha channel of each pixel in C<src> is used to control how much |
| 1711 |
the existing color in C<im> is replaced, if it is 255 then the color |
| 1712 |
is completely replaced, if it is 0 then the original color is left |
| 1713 |
unmodified. |
| 1714 |
|
| 1715 |
|
| 1716 |
=for comment |
| 1717 |
From: File rubthru.im |
| 1718 |
|
| 1719 |
|
| 1720 |
=back |
| 1721 |
|
| 1722 |
=head2 Image creation/destruction |
| 1723 |
|
| 1724 |
=over |
| 1725 |
|
| 1726 |
=item i_sametype(C<im>, C<xsize>, C<ysize>) |
| 1727 |
|
| 1728 |
|
| 1729 |
i_img *img = i_sametype(src, width, height); |
| 1730 |
|
| 1731 |
Returns an image of the same type (sample size, channels, paletted/direct). |
| 1732 |
|
| 1733 |
For paletted images the palette is copied from the source. |
| 1734 |
|
| 1735 |
|
| 1736 |
=for comment |
| 1737 |
From: File image.c |
| 1738 |
|
| 1739 |
=item i_sametype_chans(C<im>, C<xsize>, C<ysize>, C<channels>) |
| 1740 |
|
| 1741 |
|
| 1742 |
i_img *img = i_sametype_chans(src, width, height, channels); |
| 1743 |
|
| 1744 |
Returns an image of the same type (sample size). |
| 1745 |
|
| 1746 |
For paletted images the equivalent direct type is returned. |
| 1747 |
|
| 1748 |
|
| 1749 |
=for comment |
| 1750 |
From: File image.c |
| 1751 |
|
| 1752 |
=item im_img_16_new(ctx, x, y, ch) |
| 1753 |
X<im_img_16_new API>X<i_img_16_new API> |
| 1754 |
|
| 1755 |
i_img *img = im_img_16_new(aIMCTX, width, height, channels); |
| 1756 |
i_img *img = i_img_16_new(width, height, channels); |
| 1757 |
|
| 1758 |
Create a new 16-bit/sample image. |
| 1759 |
|
| 1760 |
Returns the image on success, or NULL on failure. |
| 1761 |
|
| 1762 |
Also callable as C<i_img_16_new(x, y, ch)> |
| 1763 |
|
| 1764 |
|
| 1765 |
=for comment |
| 1766 |
From: File img16.c |
| 1767 |
|
| 1768 |
=item im_img_8_new(ctx, x, y, ch) |
| 1769 |
X<im_img_8_new API>X<i_img_8_new API> |
| 1770 |
|
| 1771 |
i_img *img = im_img_8_new(aIMCTX, width, height, channels); |
| 1772 |
i_img *img = i_img_8_new(width, height, channels); |
| 1773 |
|
| 1774 |
Creates a new image object I<x> pixels wide, and I<y> pixels high with |
| 1775 |
I<ch> channels. |
| 1776 |
|
| 1777 |
|
| 1778 |
=for comment |
| 1779 |
From: File img8.c |
| 1780 |
|
| 1781 |
=item im_img_double_new(ctx, x, y, ch) |
| 1782 |
X<im_img_double_new API>X<i_img_double_new API> |
| 1783 |
|
| 1784 |
i_img *img = im_img_double_new(aIMCTX, width, height, channels); |
| 1785 |
i_img *img = i_img_double_new(width, height, channels); |
| 1786 |
|
| 1787 |
Creates a new double per sample image. |
| 1788 |
|
| 1789 |
Also callable as C<i_img_double_new(width, height, channels)>. |
| 1790 |
|
| 1791 |
|
| 1792 |
=for comment |
| 1793 |
From: File imgdouble.c |
| 1794 |
|
| 1795 |
=item im_img_pal_new(ctx, C<x>, C<y>, C<channels>, C<maxpal>) |
| 1796 |
X<im_img_pal_new API>X<i_img_pal_new API> |
| 1797 |
|
| 1798 |
i_img *img = im_img_pal_new(aIMCTX, width, height, channels, max_palette_size) |
| 1799 |
i_img *img = i_img_pal_new(width, height, channels, max_palette_size) |
| 1800 |
|
| 1801 |
Creates a new paletted image of the supplied dimensions. |
| 1802 |
|
| 1803 |
C<max_palette_size> is now ignored, all images have a 256 color |
| 1804 |
palette allocated. |
| 1805 |
|
| 1806 |
Returns a new image or NULL on failure. |
| 1807 |
|
| 1808 |
Also callable as C<i_img_pal_new(width, height, channels, max_palette_size)>. |
| 1809 |
|
| 1810 |
|
| 1811 |
=for comment |
| 1812 |
From: File palimg.c |
| 1813 |
|
| 1814 |
=item i_img_destroy(C<img>) |
| 1815 |
|
| 1816 |
i_img_destroy(img) |
| 1817 |
|
| 1818 |
Destroy an image object |
| 1819 |
|
| 1820 |
|
| 1821 |
=for comment |
| 1822 |
From: File image.c |
| 1823 |
|
| 1824 |
|
| 1825 |
=back |
| 1826 |
|
| 1827 |
=head2 Image Implementation |
| 1828 |
|
| 1829 |
=over |
| 1830 |
|
| 1831 |
=item im_img_alloc(aIMCTX) |
| 1832 |
X<im_img_alloc API>X<i_img_alloc API> |
| 1833 |
|
| 1834 |
i_img *im = im_img_alloc(aIMCTX); |
| 1835 |
i_img *im = i_img_alloc(); |
| 1836 |
|
| 1837 |
Allocates a new i_img structure. |
| 1838 |
|
| 1839 |
When implementing a new image type perform the following steps in your |
| 1840 |
image object creation function: |
| 1841 |
|
| 1842 |
=over |
| 1843 |
|
| 1844 |
=item 1. |
| 1845 |
|
| 1846 |
allocate the image with i_img_alloc(). |
| 1847 |
|
| 1848 |
=item 2. |
| 1849 |
|
| 1850 |
initialize any function pointers or other data as needed, you can |
| 1851 |
overwrite the whole block if you need to. |
| 1852 |
|
| 1853 |
=item 3. |
| 1854 |
|
| 1855 |
initialize Imager's internal data by calling i_img_init() on the image |
| 1856 |
object. |
| 1857 |
|
| 1858 |
=back |
| 1859 |
|
| 1860 |
|
| 1861 |
=for comment |
| 1862 |
From: File image.c |
| 1863 |
|
| 1864 |
=item im_img_init(aIMCTX, image) |
| 1865 |
X<im_img_init API>X<i_img_init API> |
| 1866 |
|
| 1867 |
im_img_init(aIMCTX, im); |
| 1868 |
i_img_init(im); |
| 1869 |
|
| 1870 |
Imager internal initialization of images. |
| 1871 |
|
| 1872 |
See L</im_img_alloc(aIMCTX)> for more information. |
| 1873 |
|
| 1874 |
|
| 1875 |
=for comment |
| 1876 |
From: File image.c |
| 1877 |
|
| 1878 |
|
| 1879 |
=back |
| 1880 |
|
| 1881 |
=head2 Image Information |
| 1882 |
|
| 1883 |
=over |
| 1884 |
|
| 1885 |
=item i_img_alpha_channel(im, &channel) |
| 1886 |
|
| 1887 |
int alpha_channel; |
| 1888 |
int has_alpha = i_img_alpha_channel(im, &alpha_channel); |
| 1889 |
|
| 1890 |
Work out the alpha channel for an image. |
| 1891 |
|
| 1892 |
If the image has an alpha channel, sets C<*channel> to the alpha |
| 1893 |
channel index and returns non-zero. |
| 1894 |
|
| 1895 |
If the image has no alpha channel, returns zero and C<*channel> is not |
| 1896 |
modified. |
| 1897 |
|
| 1898 |
C<channel> may be C<NULL>. |
| 1899 |
|
| 1900 |
|
| 1901 |
=for comment |
| 1902 |
From: File image.c |
| 1903 |
|
| 1904 |
=item i_img_color_channels(im) |
| 1905 |
|
| 1906 |
int color_channels = i_img_color_channels(im); |
| 1907 |
|
| 1908 |
Returns the number of color channels in the image. For now this is |
| 1909 |
always 1 (for grayscale) or 3 (for RGB) but may be 0 in some special |
| 1910 |
cases in a future release of Imager. |
| 1911 |
|
| 1912 |
|
| 1913 |
=for comment |
| 1914 |
From: File image.c |
| 1915 |
|
| 1916 |
=item i_img_color_model(im) |
| 1917 |
|
| 1918 |
i_color_model_t cm = i_img_color_model(im); |
| 1919 |
|
| 1920 |
Returns the color model for the image. |
| 1921 |
|
| 1922 |
A future version of Imager will allow for images with extra channels |
| 1923 |
beyond gray/rgb and alpha. |
| 1924 |
|
| 1925 |
|
| 1926 |
=for comment |
| 1927 |
From: File image.c |
| 1928 |
|
| 1929 |
=item i_img_get_height(C<im>) |
| 1930 |
|
| 1931 |
i_img_dim height = i_img_get_height(im); |
| 1932 |
|
| 1933 |
Returns the height in pixels of the image. |
| 1934 |
|
| 1935 |
|
| 1936 |
=for comment |
| 1937 |
From: File image.c |
| 1938 |
|
| 1939 |
=item i_img_get_width(C<im>) |
| 1940 |
|
| 1941 |
i_img_dim width = i_img_get_width(im); |
| 1942 |
|
| 1943 |
Returns the width in pixels of the image. |
| 1944 |
|
| 1945 |
|
| 1946 |
=for comment |
| 1947 |
From: File image.c |
| 1948 |
|
| 1949 |
=item i_img_getchannels(C<im>) |
| 1950 |
|
| 1951 |
int channels = i_img_getchannels(img); |
| 1952 |
|
| 1953 |
Get the number of channels in C<im>. |
| 1954 |
|
| 1955 |
|
| 1956 |
=for comment |
| 1957 |
From: File image.c |
| 1958 |
|
| 1959 |
=item i_img_getmask(C<im>) |
| 1960 |
|
| 1961 |
int mask = i_img_getmask(img); |
| 1962 |
|
| 1963 |
Get the image channel mask for C<im>. |
| 1964 |
|
| 1965 |
|
| 1966 |
=for comment |
| 1967 |
From: File image.c |
| 1968 |
|
| 1969 |
=item i_img_has_alpha(C<im>) |
| 1970 |
|
| 1971 |
|
| 1972 |
Return true if the image has an alpha channel. |
| 1973 |
|
| 1974 |
|
| 1975 |
=for comment |
| 1976 |
From: File immacros.h |
| 1977 |
|
| 1978 |
=item i_img_is_monochrome(img, &zero_is_white) |
| 1979 |
|
| 1980 |
|
| 1981 |
Tests an image to check it meets our monochrome tests. |
| 1982 |
|
| 1983 |
The idea is that a file writer can use this to test where it should |
| 1984 |
write the image in whatever bi-level format it uses, eg. C<pbm> for |
| 1985 |
C<pnm>. |
| 1986 |
|
| 1987 |
For performance of encoders we require monochrome images: |
| 1988 |
|
| 1989 |
=over |
| 1990 |
|
| 1991 |
=item * |
| 1992 |
|
| 1993 |
be paletted |
| 1994 |
|
| 1995 |
=item * |
| 1996 |
|
| 1997 |
have a palette of two colors, containing only C<(0,0,0)> and |
| 1998 |
C<(255,255,255)> in either order. |
| 1999 |
|
| 2000 |
=back |
| 2001 |
|
| 2002 |
C<zero_is_white> is set to non-zero if the first palette entry is white. |
| 2003 |
|
| 2004 |
|
| 2005 |
=for comment |
| 2006 |
From: File image.c |
| 2007 |
|
| 2008 |
=item i_img_setmask(C<im>, C<ch_mask>) |
| 2009 |
|
| 2010 |
// only channel 0 writable |
| 2011 |
i_img_setmask(img, 0x01); |
| 2012 |
|
| 2013 |
Set the image channel mask for C<im> to C<ch_mask>. |
| 2014 |
|
| 2015 |
The image channel mask gives some control over which channels can be |
| 2016 |
written to in the image. |
| 2017 |
|
| 2018 |
|
| 2019 |
=for comment |
| 2020 |
From: File image.c |
| 2021 |
|
| 2022 |
|
| 2023 |
=back |
| 2024 |
|
| 2025 |
=head2 Image quantization |
| 2026 |
|
| 2027 |
=over |
| 2028 |
|
| 2029 |
=item i_quant_makemap(C<quant>, C<imgs>, C<count>) |
| 2030 |
|
| 2031 |
|
| 2032 |
Analyzes the C<count> images in C<imgs> according to the rules in |
| 2033 |
C<quant> to build a color map (optimal or not depending on |
| 2034 |
C<< quant->make_colors >>). |
| 2035 |
|
| 2036 |
|
| 2037 |
=for comment |
| 2038 |
From: File quant.c |
| 2039 |
|
| 2040 |
=item i_quant_translate(C<quant>, C<img>) |
| 2041 |
|
| 2042 |
|
| 2043 |
Quantize the image given the palette in C<quant>. |
| 2044 |
|
| 2045 |
On success returns a pointer to a memory block of C<< img->xsize * |
| 2046 |
img->ysize >> C<i_palidx> entries. |
| 2047 |
|
| 2048 |
On failure returns NULL. |
| 2049 |
|
| 2050 |
You should call myfree() on the returned block when you're done with |
| 2051 |
it. |
| 2052 |
|
| 2053 |
This function will fail if the supplied palette contains no colors. |
| 2054 |
|
| 2055 |
|
| 2056 |
=for comment |
| 2057 |
From: File quant.c |
| 2058 |
|
| 2059 |
=item i_quant_transparent(C<quant>, C<data>, C<img>, C<trans_index>) |
| 2060 |
|
| 2061 |
|
| 2062 |
Dither the alpha channel on C<img> into the palette indexes in |
| 2063 |
C<data>. Pixels to be transparent are replaced with C<trans_pixel>. |
| 2064 |
|
| 2065 |
The method used depends on the tr_* members of C<quant>. |
| 2066 |
|
| 2067 |
|
| 2068 |
=for comment |
| 2069 |
From: File quant.c |
| 2070 |
|
| 2071 |
|
| 2072 |
=back |
| 2073 |
|
| 2074 |
=head2 Logging |
| 2075 |
|
| 2076 |
=over |
| 2077 |
|
| 2078 |
=item i_lhead(file, line) |
| 2079 |
|
| 2080 |
This is an internal function called by the mm_log() macro. |
| 2081 |
|
| 2082 |
|
| 2083 |
=for comment |
| 2084 |
From: File log.c |
| 2085 |
|
| 2086 |
=item i_loog(level, format, ...) |
| 2087 |
|
| 2088 |
This is an internal function called by the mm_log() macro. |
| 2089 |
|
| 2090 |
|
| 2091 |
=for comment |
| 2092 |
From: File log.c |
| 2093 |
|
| 2094 |
|
| 2095 |
=back |
| 2096 |
|
| 2097 |
=head2 mutex |
| 2098 |
|
| 2099 |
=over |
| 2100 |
|
| 2101 |
=item i_mutex_t |
| 2102 |
X<i_mutex> |
| 2103 |
|
| 2104 |
i_mutex_t mutex; |
| 2105 |
|
| 2106 |
Opaque type for Imager's mutex API. |
| 2107 |
|
| 2108 |
|
| 2109 |
=for comment |
| 2110 |
From: File imdatatypes.h |
| 2111 |
|
| 2112 |
|
| 2113 |
=back |
| 2114 |
|
| 2115 |
=head2 Mutex functions |
| 2116 |
|
| 2117 |
=over |
| 2118 |
|
| 2119 |
=item i_mutex_new() |
| 2120 |
|
| 2121 |
i_mutex_t m = i_mutex_new(); |
| 2122 |
|
| 2123 |
Create a mutex. |
| 2124 |
|
| 2125 |
If a critical section cannot be created for whatever reason, Imager |
| 2126 |
will abort. |
| 2127 |
|
| 2128 |
|
| 2129 |
=for comment |
| 2130 |
From: File mutexwin.c |
| 2131 |
|
| 2132 |
=item i_mutex_destroy(m) |
| 2133 |
|
| 2134 |
i_mutex_destroy(m); |
| 2135 |
|
| 2136 |
Destroy a mutex. |
| 2137 |
|
| 2138 |
|
| 2139 |
=for comment |
| 2140 |
From: File mutexwin.c |
| 2141 |
|
| 2142 |
=item i_mutex_lock(m) |
| 2143 |
|
| 2144 |
i_mutex_lock(m); |
| 2145 |
|
| 2146 |
Lock the mutex, waiting if another thread has the mutex locked. |
| 2147 |
|
| 2148 |
|
| 2149 |
=for comment |
| 2150 |
From: File mutexwin.c |
| 2151 |
|
| 2152 |
=item i_mutex_unlock(m) |
| 2153 |
|
| 2154 |
i_mutex_unlock(m); |
| 2155 |
|
| 2156 |
Release the mutex. |
| 2157 |
|
| 2158 |
The behavior of releasing a mutex you don't hold is unspecified. |
| 2159 |
|
| 2160 |
|
| 2161 |
=for comment |
| 2162 |
From: File mutexwin.c |
| 2163 |
|
| 2164 |
|
| 2165 |
=back |
| 2166 |
|
| 2167 |
=head2 Paletted images |
| 2168 |
|
| 2169 |
=over |
| 2170 |
|
| 2171 |
=item i_addcolors(im, colors, count) |
| 2172 |
|
| 2173 |
|
| 2174 |
Adds colors to the image's palette. |
| 2175 |
|
| 2176 |
On success returns the index of the lowest color added. |
| 2177 |
|
| 2178 |
On failure returns -1. |
| 2179 |
|
| 2180 |
Always fails for direct color images. |
| 2181 |
|
| 2182 |
|
| 2183 |
=for comment |
| 2184 |
From: File imext.c |
| 2185 |
|
| 2186 |
=item i_colorcount(im) |
| 2187 |
|
| 2188 |
|
| 2189 |
Returns the number of colors in the image's palette. |
| 2190 |
|
| 2191 |
Returns -1 for direct images. |
| 2192 |
|
| 2193 |
|
| 2194 |
=for comment |
| 2195 |
From: File imext.c |
| 2196 |
|
| 2197 |
=item i_findcolor(im, color, &entry) |
| 2198 |
|
| 2199 |
|
| 2200 |
Searches the images palette for the given color. |
| 2201 |
|
| 2202 |
On success sets *I<entry> to the index of the color, and returns true. |
| 2203 |
|
| 2204 |
On failure returns false. |
| 2205 |
|
| 2206 |
Always fails on direct color images. |
| 2207 |
|
| 2208 |
|
| 2209 |
=for comment |
| 2210 |
From: File imext.c |
| 2211 |
|
| 2212 |
=item i_getcolors(im, index, colors, count) |
| 2213 |
|
| 2214 |
|
| 2215 |
Retrieves I<count> colors starting from I<index> in the image's |
| 2216 |
palette. |
| 2217 |
|
| 2218 |
On success stores the colors into I<colors> and returns true. |
| 2219 |
|
| 2220 |
On failure returns false. |
| 2221 |
|
| 2222 |
Always fails for direct color images. |
| 2223 |
|
| 2224 |
Fails if there are less than I<index>+I<count> colors in the image's |
| 2225 |
palette. |
| 2226 |
|
| 2227 |
|
| 2228 |
=for comment |
| 2229 |
From: File imext.c |
| 2230 |
|
| 2231 |
=item i_maxcolors(im) |
| 2232 |
|
| 2233 |
|
| 2234 |
Returns the maximum number of colors the palette can hold for the |
| 2235 |
image. |
| 2236 |
|
| 2237 |
Returns -1 for direct color images. |
| 2238 |
|
| 2239 |
|
| 2240 |
=for comment |
| 2241 |
From: File imext.c |
| 2242 |
|
| 2243 |
=item i_setcolors(im, index, colors, count) |
| 2244 |
|
| 2245 |
|
| 2246 |
Sets I<count> colors starting from I<index> in the image's palette. |
| 2247 |
|
| 2248 |
On success returns true. |
| 2249 |
|
| 2250 |
On failure returns false. |
| 2251 |
|
| 2252 |
The image must have at least I<index>+I<count> colors in it's palette |
| 2253 |
for this to succeed. |
| 2254 |
|
| 2255 |
Always fails on direct color images. |
| 2256 |
|
| 2257 |
|
| 2258 |
=for comment |
| 2259 |
From: File imext.c |
| 2260 |
|
| 2261 |
|
| 2262 |
=back |
| 2263 |
|
| 2264 |
=head2 Tags |
| 2265 |
|
| 2266 |
=over |
| 2267 |
|
| 2268 |
=item i_tags_delbycode(tags, code) |
| 2269 |
|
| 2270 |
|
| 2271 |
Delete any tags with the given code. |
| 2272 |
|
| 2273 |
Returns the number of tags deleted. |
| 2274 |
|
| 2275 |
|
| 2276 |
=for comment |
| 2277 |
From: File tags.c |
| 2278 |
|
| 2279 |
=item i_tags_delbyname(tags, name) |
| 2280 |
|
| 2281 |
|
| 2282 |
Delete any tags with the given name. |
| 2283 |
|
| 2284 |
Returns the number of tags deleted. |
| 2285 |
|
| 2286 |
|
| 2287 |
=for comment |
| 2288 |
From: File tags.c |
| 2289 |
|
| 2290 |
=item i_tags_delete(tags, index) |
| 2291 |
|
| 2292 |
|
| 2293 |
Delete a tag by index. |
| 2294 |
|
| 2295 |
Returns true on success. |
| 2296 |
|
| 2297 |
|
| 2298 |
=for comment |
| 2299 |
From: File tags.c |
| 2300 |
|
| 2301 |
=item i_tags_destroy(tags) |
| 2302 |
|
| 2303 |
|
| 2304 |
Destroys the given tags structure. Called by i_img_destroy(). |
| 2305 |
|
| 2306 |
|
| 2307 |
=for comment |
| 2308 |
From: File tags.c |
| 2309 |
|
| 2310 |
=item i_tags_find(tags, name, start, &entry) |
| 2311 |
|
| 2312 |
|
| 2313 |
Searches for a tag of the given I<name> starting from index I<start>. |
| 2314 |
|
| 2315 |
On success returns true and sets *I<entry>. |
| 2316 |
|
| 2317 |
On failure returns false. |
| 2318 |
|
| 2319 |
|
| 2320 |
=for comment |
| 2321 |
From: File tags.c |
| 2322 |
|
| 2323 |
=item i_tags_findn(tags, code, start, &entry) |
| 2324 |
|
| 2325 |
|
| 2326 |
Searches for a tag of the given I<code> starting from index I<start>. |
| 2327 |
|
| 2328 |
On success returns true and sets *I<entry>. |
| 2329 |
|
| 2330 |
On failure returns false. |
| 2331 |
|
| 2332 |
|
| 2333 |
=for comment |
| 2334 |
From: File tags.c |
| 2335 |
|
| 2336 |
=item i_tags_get_color(tags, name, code, &value) |
| 2337 |
|
| 2338 |
|
| 2339 |
Retrieve a tag specified by name or code as color. |
| 2340 |
|
| 2341 |
On success sets the i_color *I<value> to the color and returns true. |
| 2342 |
|
| 2343 |
On failure returns false. |
| 2344 |
|
| 2345 |
|
| 2346 |
=for comment |
| 2347 |
From: File tags.c |
| 2348 |
|
| 2349 |
=item i_tags_get_float(tags, name, code, value) |
| 2350 |
|
| 2351 |
|
| 2352 |
Retrieves a tag as a floating point value. |
| 2353 |
|
| 2354 |
If the tag has a string value then that is parsed as a floating point |
| 2355 |
number, otherwise the integer value of the tag is used. |
| 2356 |
|
| 2357 |
On success sets *I<value> and returns true. |
| 2358 |
|
| 2359 |
On failure returns false. |
| 2360 |
|
| 2361 |
|
| 2362 |
=for comment |
| 2363 |
From: File tags.c |
| 2364 |
|
| 2365 |
=item i_tags_get_int(tags, name, code, &value) |
| 2366 |
|
| 2367 |
|
| 2368 |
Retrieve a tag specified by name or code as an integer. |
| 2369 |
|
| 2370 |
On success sets the int *I<value> to the integer and returns true. |
| 2371 |
|
| 2372 |
On failure returns false. |
| 2373 |
|
| 2374 |
|
| 2375 |
=for comment |
| 2376 |
From: File tags.c |
| 2377 |
|
| 2378 |
=item i_tags_get_string(tags, name, code, value, value_size) |
| 2379 |
|
| 2380 |
|
| 2381 |
Retrieves a tag by name or code as a string. |
| 2382 |
|
| 2383 |
On success copies the string to value for a max of value_size and |
| 2384 |
returns true. |
| 2385 |
|
| 2386 |
On failure returns false. |
| 2387 |
|
| 2388 |
value_size must be at least large enough for a string representation |
| 2389 |
of an integer. |
| 2390 |
|
| 2391 |
The copied value is always C<NUL> terminated. |
| 2392 |
|
| 2393 |
|
| 2394 |
=for comment |
| 2395 |
From: File tags.c |
| 2396 |
|
| 2397 |
=item i_tags_new(i_img_tags *tags) |
| 2398 |
|
| 2399 |
|
| 2400 |
Initialize a tags structure. Should not be used if the tags structure |
| 2401 |
has been previously used. |
| 2402 |
|
| 2403 |
This should be called tags member of an i_img object on creation (in |
| 2404 |
i_img_*_new() functions). |
| 2405 |
|
| 2406 |
To destroy the contents use i_tags_destroy() |
| 2407 |
|
| 2408 |
|
| 2409 |
=for comment |
| 2410 |
From: File tags.c |
| 2411 |
|
| 2412 |
=item i_tags_set(tags, name, data, size) |
| 2413 |
|
| 2414 |
i_tags_set(&img->tags, "i_comment", -1); |
| 2415 |
|
| 2416 |
Sets the given tag to the string I<data> |
| 2417 |
|
| 2418 |
If size is -1 then the strlen(I<data>) bytes are stored. |
| 2419 |
|
| 2420 |
Even on failure, if an existing tag I<name> exists, it will be |
| 2421 |
removed. |
| 2422 |
|
| 2423 |
|
| 2424 |
=for comment |
| 2425 |
From: File tags.c |
| 2426 |
|
| 2427 |
=item i_tags_set_color(tags, name, code, &value) |
| 2428 |
|
| 2429 |
|
| 2430 |
Stores the given color as a tag with the given name and code. |
| 2431 |
|
| 2432 |
|
| 2433 |
=for comment |
| 2434 |
From: File tags.c |
| 2435 |
|
| 2436 |
=item i_tags_set_float(tags, name, code, value) |
| 2437 |
|
| 2438 |
|
| 2439 |
Equivalent to i_tags_set_float2(tags, name, code, value, 30). |
| 2440 |
|
| 2441 |
|
| 2442 |
=for comment |
| 2443 |
From: File tags.c |
| 2444 |
|
| 2445 |
=item i_tags_set_float2(tags, name, code, value, places) |
| 2446 |
|
| 2447 |
|
| 2448 |
Sets the tag with the given name and code to the given floating point |
| 2449 |
value. |
| 2450 |
|
| 2451 |
Since tags are strings or ints, we convert the value to a string before |
| 2452 |
storage at the precision specified by C<places>. |
| 2453 |
|
| 2454 |
|
| 2455 |
=for comment |
| 2456 |
From: File tags.c |
| 2457 |
|
| 2458 |
=item i_tags_setn(C<tags>, C<name>, C<idata>) |
| 2459 |
|
| 2460 |
i_tags_setn(&img->tags, "i_xres", 204); |
| 2461 |
i_tags_setn(&img->tags, "i_yres", 196); |
| 2462 |
|
| 2463 |
Sets the given tag to the integer C<idata> |
| 2464 |
|
| 2465 |
Even on failure, if an existing tag C<name> exists, it will be |
| 2466 |
removed. |
| 2467 |
|
| 2468 |
|
| 2469 |
=for comment |
| 2470 |
From: File tags.c |
| 2471 |
|
| 2472 |
|
| 2473 |
=back |
| 2474 |
|
| 2475 |
=head2 Uncategorized functions |
| 2476 |
|
| 2477 |
=over |
| 2478 |
|
| 2479 |
=item i_utf8_advance(char **p, size_t *len) |
| 2480 |
|
| 2481 |
Retrieve a C<UTF-8> character from the stream. |
| 2482 |
|
| 2483 |
Modifies *p and *len to indicate the consumed characters. |
| 2484 |
|
| 2485 |
This doesn't support the extended C<UTF-8> encoding used by later |
| 2486 |
versions of Perl. Since this is typically used to implement text |
| 2487 |
output by font drivers, the strings supplied shouldn't have such out |
| 2488 |
of range characters. |
| 2489 |
|
| 2490 |
This doesn't check that the C<UTF-8> character is using the shortest |
| 2491 |
possible representation. |
| 2492 |
|
| 2493 |
Returns ~0UL on failure. |
| 2494 |
|
| 2495 |
|
| 2496 |
=for comment |
| 2497 |
From: File io.c |
| 2498 |
|
| 2499 |
=item im_context_refdec(ctx, where) |
| 2500 |
X<im_context_refdec API> |
| 2501 |
=section Context objects |
| 2502 |
|
| 2503 |
im_context_refdec(aIMCTX, "a description"); |
| 2504 |
|
| 2505 |
Remove a reference to the context, releasing it if all references have |
| 2506 |
been removed. |
| 2507 |
|
| 2508 |
|
| 2509 |
=for comment |
| 2510 |
From: File context.c |
| 2511 |
|
| 2512 |
=item im_context_refinc(ctx, where) |
| 2513 |
X<im_context_refinc API> |
| 2514 |
=section Context objects |
| 2515 |
|
| 2516 |
im_context_refinc(aIMCTX, "a description"); |
| 2517 |
|
| 2518 |
Add a new reference to the context. |
| 2519 |
|
| 2520 |
|
| 2521 |
=for comment |
| 2522 |
From: File context.c |
| 2523 |
|
| 2524 |
=item im_context_slot_get(ctx, slot) |
| 2525 |
|
| 2526 |
Retrieve the value previously stored in the given slot of the context |
| 2527 |
object. |
| 2528 |
|
| 2529 |
|
| 2530 |
=for comment |
| 2531 |
From: File context.c |
| 2532 |
|
| 2533 |
=item im_context_slot_new(destructor) |
| 2534 |
|
| 2535 |
Allocate a new context-local-storage slot. |
| 2536 |
|
| 2537 |
C<desctructor> will be called when the context is destroyed if the |
| 2538 |
corresponding slot is non-NULL. |
| 2539 |
|
| 2540 |
|
| 2541 |
=for comment |
| 2542 |
From: File context.c |
| 2543 |
|
| 2544 |
=item im_context_slot_set(slot, value) |
| 2545 |
|
| 2546 |
Set the value of a slot. |
| 2547 |
|
| 2548 |
Returns true on success. |
| 2549 |
|
| 2550 |
Aborts if the slot supplied is invalid. |
| 2551 |
|
| 2552 |
If reallocation of slot storage fails, returns false. |
| 2553 |
|
| 2554 |
|
| 2555 |
=for comment |
| 2556 |
From: File context.c |
| 2557 |
|
| 2558 |
=item im_decode_exif |
| 2559 |
|
| 2560 |
im_decode_exif(im, data_base, data_size); |
| 2561 |
|
| 2562 |
The data from C<data_base> for C<data_size> bytes will be scanned for |
| 2563 |
EXIF data. |
| 2564 |
|
| 2565 |
Any data found will be used to set tags in the supplied image. |
| 2566 |
|
| 2567 |
The intent is that invalid EXIF data will simply fail to set tags, and |
| 2568 |
write to the log. In no case should this code exit when supplied |
| 2569 |
invalid data. |
| 2570 |
|
| 2571 |
Returns true if the EXIF block was valid, this is mostly used for |
| 2572 |
testing, you don't need to test this in a typical file reader unless |
| 2573 |
you have a strict mode. |
| 2574 |
|
| 2575 |
This is a limited version of "validity", eg. IFDs are meant to be |
| 2576 |
sorted, which this doesn't check. |
| 2577 |
|
| 2578 |
|
| 2579 |
=for comment |
| 2580 |
From: File imexif.c |
| 2581 |
|
| 2582 |
=item im_errors(ctx) |
| 2583 |
|
| 2584 |
i_errmsg *errors = im_errors(aIMCTX); |
| 2585 |
i_errmsg *errors = i_errors(); |
| 2586 |
|
| 2587 |
Returns a pointer to the first element of an array of error messages, |
| 2588 |
terminated by a NULL pointer. The highest level message is first. |
| 2589 |
|
| 2590 |
Also callable as C<i_errors()>. |
| 2591 |
|
| 2592 |
|
| 2593 |
=for comment |
| 2594 |
From: File error.c |
| 2595 |
|
| 2596 |
=item im_get_context() |
| 2597 |
|
| 2598 |
Retrieve the context object for the current thread. |
| 2599 |
|
| 2600 |
Inside Imager itself this is just a function pointer, which the |
| 2601 |
F<Imager.xs> BOOT handler initializes for use within perl. If you're |
| 2602 |
taking the Imager code and embedding it elsewhere you need to |
| 2603 |
initialize the C<im_get_context> pointer at some point. |
| 2604 |
|
| 2605 |
|
| 2606 |
=for comment |
| 2607 |
From: File imext.c |
| 2608 |
|
| 2609 |
|
| 2610 |
|
| 2611 |
=back |
| 2612 |
|
| 2613 |
|
| 2614 |
=head1 UNDOCUMENTED |
| 2615 |
|
| 2616 |
The following API functions are undocumented so far, hopefully this |
| 2617 |
will change: |
| 2618 |
|
| 2619 |
=over |
| 2620 |
|
| 2621 |
=item * |
| 2622 |
|
| 2623 |
B<im_lhead> |
| 2624 |
|
| 2625 |
=item * |
| 2626 |
|
| 2627 |
B<im_loog> |
| 2628 |
|
| 2629 |
=item * |
| 2630 |
|
| 2631 |
B<mm_log> |
| 2632 |
|
| 2633 |
|
| 2634 |
|
| 2635 |
=back |
| 2636 |
|
| 2637 |
|
| 2638 |
=head1 AUTHOR |
| 2639 |
|
| 2640 |
Tony Cook <[email protected]> |
| 2641 |
|
| 2642 |
=head1 SEE ALSO |
| 2643 |
|
| 2644 |
Imager, Imager::API, Imager::ExtUtils, Imager::Inline |
| 2645 |
|
| 2646 |
=cut |