| 1 |
|
| #include "imexttypes.h" |
| 2 |
|
| #include "imager.h" |
| 3 |
|
| #include "imio.h" |
| 4 |
|
| #include "imexif.h" |
| 5 |
|
| |
| 6 |
|
| static im_context_t get_context(void); |
| 7 |
|
| static i_img *mathom_i_img_8_new(i_img_dim, i_img_dim, int); |
| 8 |
|
| static i_img *mathom_i_img_16_new(i_img_dim, i_img_dim, int); |
| 9 |
|
| static i_img *mathom_i_img_double_new(i_img_dim, i_img_dim, int); |
| 10 |
|
| static i_img *mathom_i_img_pal_new(i_img_dim, i_img_dim, int, int); |
| 11 |
|
| static void mathom_i_clear_error(void); |
| 12 |
|
| static void mathom_i_push_error(int, const char *); |
| 13 |
|
| static void mathom_i_push_errorvf(int, const char *, va_list); |
| 14 |
|
| static int mathom_i_set_image_file_limits(i_img_dim, i_img_dim, size_t); |
| 15 |
|
| static int mathom_i_get_image_file_limits(i_img_dim*, i_img_dim*, size_t*); |
| 16 |
|
| static int |
| 17 |
|
| mathom_i_int_check_image_file_limits(i_img_dim, i_img_dim, int, size_t); |
| 18 |
|
| static i_img *mathom_i_img_alloc(void); |
| 19 |
|
| static void mathom_i_img_init(i_img *); |
| 20 |
|
| static i_io_glue_t *mathom_io_new_fd(int); |
| 21 |
|
| static i_io_glue_t *mathom_io_new_bufchain(void); |
| 22 |
|
| static i_io_glue_t * |
| 23 |
|
| mathom_io_new_buffer(const char *data, size_t, i_io_closebufp_t, void *); |
| 24 |
|
| static i_io_glue_t * |
| 25 |
|
| mathom_io_new_cb(void *, i_io_readl_t, i_io_writel_t, i_io_seekl_t, |
| 26 |
|
| i_io_closel_t, i_io_destroyl_t); |
| 27 |
|
| |
| 28 |
|
| /* |
| 29 |
|
| DON'T ADD CASTS TO THESE |
| 30 |
|
| */ |
| 31 |
|
| im_ext_funcs imager_function_table = |
| 32 |
|
| { |
| 33 |
|
| IMAGER_API_VERSION, |
| 34 |
|
| IMAGER_API_LEVEL, |
| 35 |
|
| |
| 36 |
|
| mymalloc, |
| 37 |
|
| myfree, |
| 38 |
|
| myrealloc, |
| 39 |
|
| |
| 40 |
|
| mathom_i_img_8_new, |
| 41 |
|
| mathom_i_img_16_new, |
| 42 |
|
| mathom_i_img_double_new, |
| 43 |
|
| mathom_i_img_pal_new, |
| 44 |
|
| i_img_destroy, |
| 45 |
|
| i_sametype, |
| 46 |
|
| i_sametype_chans, |
| 47 |
|
| i_img_info, |
| 48 |
|
| |
| 49 |
|
| i_ppix, |
| 50 |
|
| i_gpix, |
| 51 |
|
| i_ppixf, |
| 52 |
|
| i_gpixf, |
| 53 |
|
| i_plin, |
| 54 |
|
| i_glin, |
| 55 |
|
| i_plinf, |
| 56 |
|
| i_glinf, |
| 57 |
|
| i_gsamp, |
| 58 |
|
| i_gsampf, |
| 59 |
|
| i_gpal, |
| 60 |
|
| i_ppal, |
| 61 |
|
| i_addcolors, |
| 62 |
|
| i_getcolors, |
| 63 |
|
| i_colorcount, |
| 64 |
|
| i_maxcolors, |
| 65 |
|
| i_findcolor, |
| 66 |
|
| i_setcolors, |
| 67 |
|
| |
| 68 |
|
| i_new_fill_solid, |
| 69 |
|
| i_new_fill_solidf, |
| 70 |
|
| i_new_fill_hatch, |
| 71 |
|
| i_new_fill_hatchf, |
| 72 |
|
| i_new_fill_image, |
| 73 |
|
| i_new_fill_fount, |
| 74 |
|
| i_fill_destroy, |
| 75 |
|
| |
| 76 |
|
| i_quant_makemap, |
| 77 |
|
| i_quant_translate, |
| 78 |
|
| i_quant_transparent, |
| 79 |
|
| |
| 80 |
|
| mathom_i_clear_error, |
| 81 |
|
| mathom_i_push_error, |
| 82 |
|
| i_push_errorf, |
| 83 |
|
| mathom_i_push_errorvf, |
| 84 |
|
| |
| 85 |
|
| i_tags_new, |
| 86 |
|
| i_tags_set, |
| 87 |
|
| i_tags_setn, |
| 88 |
|
| i_tags_destroy, |
| 89 |
|
| i_tags_find, |
| 90 |
|
| i_tags_findn, |
| 91 |
|
| i_tags_delete, |
| 92 |
|
| i_tags_delbyname, |
| 93 |
|
| i_tags_delbycode, |
| 94 |
|
| i_tags_get_float, |
| 95 |
|
| i_tags_set_float, |
| 96 |
|
| i_tags_set_float2, |
| 97 |
|
| i_tags_get_int, |
| 98 |
|
| i_tags_get_string, |
| 99 |
|
| i_tags_get_color, |
| 100 |
|
| i_tags_set_color, |
| 101 |
|
| |
| 102 |
|
| i_box, |
| 103 |
|
| i_box_filled, |
| 104 |
|
| i_box_cfill, |
| 105 |
|
| i_line, |
| 106 |
|
| i_line_aa, |
| 107 |
|
| i_arc, |
| 108 |
|
| i_arc_aa, |
| 109 |
|
| i_arc_cfill, |
| 110 |
|
| i_arc_aa_cfill, |
| 111 |
|
| i_circle_aa, |
| 112 |
|
| i_flood_fill, |
| 113 |
|
| i_flood_cfill, |
| 114 |
|
| |
| 115 |
|
| i_copyto, |
| 116 |
|
| i_copyto_trans, |
| 117 |
|
| i_copy, |
| 118 |
|
| i_rubthru, |
| 119 |
|
| |
| 120 |
|
| /* IMAGER_API_LEVEL 2 functions */ |
| 121 |
|
| mathom_i_set_image_file_limits, |
| 122 |
|
| mathom_i_get_image_file_limits, |
| 123 |
|
| mathom_i_int_check_image_file_limits, |
| 124 |
|
| |
| 125 |
|
| i_flood_fill_border, |
| 126 |
|
| i_flood_cfill_border, |
| 127 |
|
| |
| 128 |
|
| /* IMAGER_API_LEVEL 3 functions */ |
| 129 |
|
| i_img_setmask, |
| 130 |
|
| i_img_getmask, |
| 131 |
|
| i_img_getchannels, |
| 132 |
|
| i_img_get_width, |
| 133 |
|
| i_img_get_height, |
| 134 |
|
| i_lhead, |
| 135 |
|
| i_loog, |
| 136 |
|
| |
| 137 |
|
| /* IMAGER_API_LEVEL 4 functions */ |
| 138 |
|
| mathom_i_img_alloc, |
| 139 |
|
| mathom_i_img_init, |
| 140 |
|
| |
| 141 |
|
| /* IMAGER_API_LEVEL 5 functions */ |
| 142 |
|
| i_img_is_monochrome, |
| 143 |
|
| i_gsamp_bg, |
| 144 |
|
| i_gsampf_bg, |
| 145 |
|
| i_get_file_background, |
| 146 |
|
| i_get_file_backgroundf, |
| 147 |
|
| i_utf8_advance, |
| 148 |
|
| i_render_new, |
| 149 |
|
| i_render_delete, |
| 150 |
|
| i_render_color, |
| 151 |
|
| i_render_fill, |
| 152 |
|
| i_render_line, |
| 153 |
|
| i_render_linef, |
| 154 |
|
| |
| 155 |
|
| /* level 6 */ |
| 156 |
|
| i_io_getc_imp, |
| 157 |
|
| i_io_peekc_imp, |
| 158 |
|
| i_io_peekn, |
| 159 |
|
| i_io_putc_imp, |
| 160 |
|
| i_io_read, |
| 161 |
|
| i_io_write, |
| 162 |
|
| i_io_seek, |
| 163 |
|
| i_io_flush, |
| 164 |
|
| i_io_close, |
| 165 |
|
| i_io_set_buffered, |
| 166 |
|
| i_io_gets, |
| 167 |
|
| mathom_io_new_fd, |
| 168 |
|
| mathom_io_new_bufchain, |
| 169 |
|
| mathom_io_new_buffer, |
| 170 |
|
| mathom_io_new_cb, |
| 171 |
|
| io_slurp, |
| 172 |
|
| io_glue_destroy, |
| 173 |
|
| |
| 174 |
|
| /* level 8 */ |
| 175 |
|
| im_img_8_new, |
| 176 |
|
| im_img_16_new, |
| 177 |
|
| im_img_double_new, |
| 178 |
|
| im_img_pal_new, |
| 179 |
|
| im_clear_error, |
| 180 |
|
| im_push_error, |
| 181 |
|
| im_push_errorvf, |
| 182 |
|
| im_push_errorf, |
| 183 |
|
| im_set_image_file_limits, |
| 184 |
|
| im_get_image_file_limits, |
| 185 |
|
| im_int_check_image_file_limits, |
| 186 |
|
| im_img_alloc, |
| 187 |
|
| im_img_init, |
| 188 |
|
| im_io_new_fd, |
| 189 |
|
| im_io_new_bufchain, |
| 190 |
|
| im_io_new_buffer, |
| 191 |
|
| im_io_new_cb8, |
| 192 |
|
| get_context, |
| 193 |
|
| im_lhead, |
| 194 |
|
| im_loog, |
| 195 |
|
| im_context_refinc, |
| 196 |
|
| im_context_refdec, |
| 197 |
|
| im_errors, |
| 198 |
|
| i_mutex_new, |
| 199 |
|
| i_mutex_destroy, |
| 200 |
|
| i_mutex_lock, |
| 201 |
|
| i_mutex_unlock, |
| 202 |
|
| im_context_slot_new, |
| 203 |
|
| im_context_slot_set, |
| 204 |
|
| im_context_slot_get, |
| 205 |
|
| |
| 206 |
|
| /* level 9 */ |
| 207 |
|
| i_poly_poly_aa, |
| 208 |
|
| i_poly_poly_aa_cfill, |
| 209 |
|
| i_poly_aa_m, |
| 210 |
|
| i_poly_aa_cfill_m, |
| 211 |
|
| |
| 212 |
|
| i_img_alpha_channel, |
| 213 |
|
| i_img_color_model, |
| 214 |
|
| i_img_color_channels, |
| 215 |
|
| |
| 216 |
|
| /* level 10 */ |
| 217 |
|
| im_decode_exif, |
| 218 |
|
| |
| 219 |
|
| /* level 11 */ |
| 220 |
|
| im_malloc, |
| 221 |
|
| im_realloc, |
| 222 |
|
| im_free, |
| 223 |
|
| im_malloc_fail, |
| 224 |
|
| |
| 225 |
|
| /* level 12 */ |
| 226 |
|
| im_io_set_max_mmap_size, |
| 227 |
|
| im_io_get_max_mmap_size |
| 228 |
|
| }; |
| 229 |
|
| |
| 230 |
|
| /* in general these functions aren't called by Imager internally, but |
| 231 |
|
| only via the pointers above, since faster macros that call the |
| 232 |
|
| image vtable pointers are used. |
| 233 |
|
| |
| 234 |
|
| () are used around the function names to prevent macro replacement |
| 235 |
|
| on the function names. |
| 236 |
|
| */ |
| 237 |
|
| |
| 238 |
|
| /* |
| 239 |
|
| =item i_ppix(im, x, y, color) |
| 240 |
|
| |
| 241 |
|
| =category Drawing |
| 242 |
|
| |
| 243 |
|
| Sets the pixel at (x,y) to I<color>. |
| 244 |
|
| |
| 245 |
|
| Returns 0 if the pixel was drawn, or -1 if not. |
| 246 |
|
| |
| 247 |
|
| Does no alpha blending, just copies the channels from the supplied |
| 248 |
|
| color to the image. |
| 249 |
|
| |
| 250 |
|
| =cut |
| 251 |
|
| */ |
| 252 |
|
| |
| 253 |
|
| int |
| 254 |
0 |
| (i_ppix)(i_img *im, i_img_dim x, i_img_dim y, const i_color *val) { |
| 255 |
0 |
| return i_ppix(im, x, y, val); |
| 256 |
|
| } |
| 257 |
|
| |
| 258 |
|
| /* |
| 259 |
|
| =item i_gpix(im, C<x>, C<y>, C<color>) |
| 260 |
|
| |
| 261 |
|
| =category Drawing |
| 262 |
|
| |
| 263 |
|
| Retrieves the C<color> of the pixel (x,y). |
| 264 |
|
| |
| 265 |
|
| Returns 0 if the pixel was retrieved, or -1 if not. |
| 266 |
|
| |
| 267 |
|
| =cut |
| 268 |
|
| */ |
| 269 |
|
| |
| 270 |
|
| int |
| 271 |
0 |
| (i_gpix)(i_img *im,i_img_dim x,i_img_dim y,i_color *val) { |
| 272 |
0 |
| return i_gpix(im, x, y, val); |
| 273 |
|
| } |
| 274 |
|
| |
| 275 |
|
| /* |
| 276 |
|
| =item i_ppixf(im, C<x>, C<y>, C<fcolor>) |
| 277 |
|
| |
| 278 |
|
| =category Drawing |
| 279 |
|
| |
| 280 |
|
| Sets the pixel at (C<x>,C<y>) to the floating point color C<fcolor>. |
| 281 |
|
| |
| 282 |
|
| Returns 0 if the pixel was drawn, or -1 if not. |
| 283 |
|
| |
| 284 |
|
| Does no alpha blending, just copies the channels from the supplied |
| 285 |
|
| color to the image. |
| 286 |
|
| |
| 287 |
|
| =cut |
| 288 |
|
| */ |
| 289 |
|
| int |
| 290 |
0 |
| (i_ppixf)(i_img *im, i_img_dim x, i_img_dim y, const i_fcolor *val) { |
| 291 |
0 |
| return i_ppixf(im, x, y, val); |
| 292 |
|
| } |
| 293 |
|
| |
| 294 |
|
| /* |
| 295 |
|
| =item i_gpixf(im, C<x>, C<y>, C<fcolor>) |
| 296 |
|
| |
| 297 |
|
| =category Drawing |
| 298 |
|
| |
| 299 |
|
| Retrieves the color of the pixel (x,y) as a floating point color into |
| 300 |
|
| C<fcolor>. |
| 301 |
|
| |
| 302 |
|
| Returns 0 if the pixel was retrieved, or -1 if not. |
| 303 |
|
| |
| 304 |
|
| =cut |
| 305 |
|
| */ |
| 306 |
|
| |
| 307 |
|
| int |
| 308 |
0 |
| (i_gpixf)(i_img *im,i_img_dim x,i_img_dim y,i_fcolor *val) { |
| 309 |
0 |
| return i_gpixf(im, x, y, val); |
| 310 |
|
| } |
| 311 |
|
| |
| 312 |
|
| /* |
| 313 |
|
| =item i_plin(im, l, r, y, colors) |
| 314 |
|
| |
| 315 |
|
| =category Drawing |
| 316 |
|
| |
| 317 |
|
| Sets (r-l) pixels starting from (l,y) using (r-l) values from |
| 318 |
|
| I<colors>. |
| 319 |
|
| |
| 320 |
|
| Returns the number of pixels set. |
| 321 |
|
| |
| 322 |
|
| =cut |
| 323 |
|
| */ |
| 324 |
|
| |
| 325 |
|
| i_img_dim |
| 326 |
0 |
| (i_plin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_color *vals) { |
| 327 |
0 |
| return i_plin(im, l, r, y, vals); |
| 328 |
|
| } |
| 329 |
|
| |
| 330 |
|
| /* |
| 331 |
|
| =item i_glin(im, l, r, y, colors) |
| 332 |
|
| |
| 333 |
|
| =category Drawing |
| 334 |
|
| |
| 335 |
|
| Retrieves (r-l) pixels starting from (l,y) into I<colors>. |
| 336 |
|
| |
| 337 |
|
| Returns the number of pixels retrieved. |
| 338 |
|
| |
| 339 |
|
| =cut |
| 340 |
|
| */ |
| 341 |
|
| |
| 342 |
|
| i_img_dim |
| 343 |
0 |
| (i_glin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_color *vals) { |
| 344 |
0 |
| return i_glin(im, l, r, y, vals); |
| 345 |
|
| } |
| 346 |
|
| |
| 347 |
|
| /* |
| 348 |
|
| =item i_plinf(im, C<left>, C<right>, C<fcolors>) |
| 349 |
|
| |
| 350 |
|
| =category Drawing |
| 351 |
|
| |
| 352 |
|
| Sets (right-left) pixels starting from (left,y) using (right-left) |
| 353 |
|
| floating point colors from C<fcolors>. |
| 354 |
|
| |
| 355 |
|
| Returns the number of pixels set. |
| 356 |
|
| |
| 357 |
|
| =cut |
| 358 |
|
| */ |
| 359 |
|
| |
| 360 |
|
| i_img_dim |
| 361 |
0 |
| (i_plinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_fcolor *vals) { |
| 362 |
0 |
| return i_plinf(im, l, r, y, vals); |
| 363 |
|
| } |
| 364 |
|
| |
| 365 |
|
| /* |
| 366 |
|
| =item i_glinf(im, l, r, y, colors) |
| 367 |
|
| |
| 368 |
|
| =category Drawing |
| 369 |
|
| |
| 370 |
|
| Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating |
| 371 |
|
| point colors. |
| 372 |
|
| |
| 373 |
|
| Returns the number of pixels retrieved. |
| 374 |
|
| |
| 375 |
|
| =cut |
| 376 |
|
| */ |
| 377 |
|
| |
| 378 |
|
| i_img_dim |
| 379 |
0 |
| (i_glinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fcolor *vals) { |
| 380 |
0 |
| return i_glinf(im, l, r, y, vals); |
| 381 |
|
| } |
| 382 |
|
| |
| 383 |
|
| /* |
| 384 |
|
| =item i_gsamp(im, left, right, y, samples, channels, channel_count) |
| 385 |
|
| |
| 386 |
|
| =category Drawing |
| 387 |
|
| |
| 388 |
|
| Reads sample values from C<im> for the horizontal line (left, y) to |
| 389 |
|
| (right-1,y) for the channels specified by C<channels>, an array of int |
| 390 |
|
| with C<channel_count> elements. |
| 391 |
|
| |
| 392 |
|
| If channels is NULL then the first channels_count channels are retrieved for |
| 393 |
|
| each pixel. |
| 394 |
|
| |
| 395 |
|
| Returns the number of samples read (which should be (right-left) * |
| 396 |
|
| channel_count) |
| 397 |
|
| |
| 398 |
|
| =cut |
| 399 |
|
| */ |
| 400 |
|
| i_img_dim |
| 401 |
0 |
| (i_gsamp)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_sample_t *samp, |
| 402 |
|
| const int *chans, int chan_count) { |
| 403 |
0 |
| return i_gsamp(im, l, r, y, samp, chans, chan_count); |
| 404 |
|
| } |
| 405 |
|
| |
| 406 |
|
| /* |
| 407 |
|
| =item i_gsampf(im, left, right, y, samples, channels, channel_count) |
| 408 |
|
| |
| 409 |
|
| =category Drawing |
| 410 |
|
| |
| 411 |
|
| Reads floating point sample values from C<im> for the horizontal line |
| 412 |
|
| (left, y) to (right-1,y) for the channels specified by C<channels>, an |
| 413 |
|
| array of int with channel_count elements. |
| 414 |
|
| |
| 415 |
|
| If C<channels> is NULL then the first C<channel_count> channels are |
| 416 |
|
| retrieved for each pixel. |
| 417 |
|
| |
| 418 |
|
| Returns the number of samples read (which should be (C<right>-C<left>) |
| 419 |
|
| * C<channel_count>) |
| 420 |
|
| |
| 421 |
|
| =cut |
| 422 |
|
| */ |
| 423 |
|
| i_img_dim |
| 424 |
0 |
| (i_gsampf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samp, |
| 425 |
|
| const int *chans, int chan_count) { |
| 426 |
0 |
| return i_gsampf(im, l, r, y, samp, chans, chan_count); |
| 427 |
|
| } |
| 428 |
|
| |
| 429 |
|
| /* |
| 430 |
|
| =item i_gsamp_bits(im, left, right, y, samples, channels, channel_count, bits) |
| 431 |
|
| =category Drawing |
| 432 |
|
| |
| 433 |
|
| Reads integer samples scaled to C<bits> bits of precision into the |
| 434 |
|
| C<unsigned int> array C<samples>. |
| 435 |
|
| |
| 436 |
|
| Expect this to be slow unless C<< bits == im->bits >>. |
| 437 |
|
| |
| 438 |
|
| Returns the number of samples copied, or -1 on error. |
| 439 |
|
| |
| 440 |
|
| Not all image types implement this method. |
| 441 |
|
| |
| 442 |
|
| Pushes errors, but does not call C<i_clear_error()>. |
| 443 |
|
| |
| 444 |
|
| =cut |
| 445 |
|
| */ |
| 446 |
|
| |
| 447 |
|
| /* |
| 448 |
|
| =item i_psamp_bits(im, left, right, y, samples, channels, channel_count, bits) |
| 449 |
|
| =category Drawing |
| 450 |
|
| |
| 451 |
|
| Writes integer samples scaled to C<bits> bits of precision from the |
| 452 |
|
| C<unsigned int> array C<samples>. |
| 453 |
|
| |
| 454 |
|
| Expect this to be slow unless C<< bits == im->bits >>. |
| 455 |
|
| |
| 456 |
|
| Returns the number of samples copied, or -1 on error. |
| 457 |
|
| |
| 458 |
|
| Not all image types implement this method. |
| 459 |
|
| |
| 460 |
|
| Pushes errors, but does not call C<i_clear_error()>. |
| 461 |
|
| |
| 462 |
|
| =cut |
| 463 |
|
| */ |
| 464 |
|
| |
| 465 |
|
| /* |
| 466 |
|
| =item i_gpal(im, left, right, y, indexes) |
| 467 |
|
| |
| 468 |
|
| =category Drawing |
| 469 |
|
| |
| 470 |
|
| Reads palette indexes for the horizontal line (left, y) to (right-1, |
| 471 |
|
| y) into C<indexes>. |
| 472 |
|
| |
| 473 |
|
| Returns the number of indexes read. |
| 474 |
|
| |
| 475 |
|
| Always returns 0 for direct color images. |
| 476 |
|
| |
| 477 |
|
| =cut |
| 478 |
|
| */ |
| 479 |
|
| i_img_dim |
| 480 |
0 |
| (i_gpal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, i_palidx *vals) { |
| 481 |
0 |
▶ | return i_gpal(im, x, r, y, vals); |
Branch: 1 branch
| Branch | True | False | Total |
| return i_gpal(im, x, r, y, vals); |
0 |
0 |
0 |
|
| 482 |
|
| } |
| 483 |
|
| |
| 484 |
|
| /* |
| 485 |
|
| =item i_ppal(im, left, right, y, indexes) |
| 486 |
|
| |
| 487 |
|
| =category Drawing |
| 488 |
|
| |
| 489 |
|
| Writes palette indexes for the horizontal line (left, y) to (right-1, |
| 490 |
|
| y) from C<indexes>. |
| 491 |
|
| |
| 492 |
|
| Returns the number of indexes written. |
| 493 |
|
| |
| 494 |
|
| Always returns 0 for direct color images. |
| 495 |
|
| |
| 496 |
|
| =cut |
| 497 |
|
| */ |
| 498 |
|
| i_img_dim |
| 499 |
0 |
| (i_ppal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, const i_palidx *vals) { |
| 500 |
0 |
▶ | return i_ppal(im, x, r, y, vals); |
Branch: 1 branch
| Branch | True | False | Total |
| return i_ppal(im, x, r, y, vals); |
0 |
0 |
0 |
|
| 501 |
|
| } |
| 502 |
|
| |
| 503 |
|
| /* |
| 504 |
|
| =item i_addcolors(im, colors, count) |
| 505 |
|
| |
| 506 |
|
| =category Paletted images |
| 507 |
|
| |
| 508 |
|
| Adds colors to the image's palette. |
| 509 |
|
| |
| 510 |
|
| On success returns the index of the lowest color added. |
| 511 |
|
| |
| 512 |
|
| On failure returns -1. |
| 513 |
|
| |
| 514 |
|
| Always fails for direct color images. |
| 515 |
|
| |
| 516 |
|
| =cut |
| 517 |
|
| */ |
| 518 |
|
| |
| 519 |
|
| int |
| 520 |
0 |
| (i_addcolors)(i_img *im, const i_color *colors, int count) { |
| 521 |
0 |
▶ | return i_addcolors(im, colors, count); |
Branch: 1 branch
| Branch | True | False | Total |
| return i_addcolors(im, colors, count); |
0 |
0 |
0 |
|
| 522 |
|
| } |
| 523 |
|
| |
| 524 |
|
| /* |
| 525 |
|
| =item i_getcolors(im, index, colors, count) |
| 526 |
|
| |
| 527 |
|
| =category Paletted images |
| 528 |
|
| |
| 529 |
|
| Retrieves I<count> colors starting from I<index> in the image's |
| 530 |
|
| palette. |
| 531 |
|
| |
| 532 |
|
| On success stores the colors into I<colors> and returns true. |
| 533 |
|
| |
| 534 |
|
| On failure returns false. |
| 535 |
|
| |
| 536 |
|
| Always fails for direct color images. |
| 537 |
|
| |
| 538 |
|
| Fails if there are less than I<index>+I<count> colors in the image's |
| 539 |
|
| palette. |
| 540 |
|
| |
| 541 |
|
| =cut |
| 542 |
|
| */ |
| 543 |
|
| |
| 544 |
|
| int |
| 545 |
0 |
| (i_getcolors)(i_img *im, int i, i_color *colors, int count) { |
| 546 |
0 |
▶ | return i_getcolors(im, i, colors, count); |
Branch: 1 branch
| Branch | True | False | Total |
| return i_getcolors(im, i, colors, count); |
0 |
0 |
0 |
|
| 547 |
|
| } |
| 548 |
|
| |
| 549 |
|
| /* |
| 550 |
|
| =item i_colorcount(im) |
| 551 |
|
| |
| 552 |
|
| =category Paletted images |
| 553 |
|
| |
| 554 |
|
| Returns the number of colors in the image's palette. |
| 555 |
|
| |
| 556 |
|
| Returns -1 for direct images. |
| 557 |
|
| |
| 558 |
|
| =cut |
| 559 |
|
| */ |
| 560 |
|
| |
| 561 |
|
| int |
| 562 |
0 |
| (i_colorcount)(i_img *im) { |
| 563 |
0 |
▶ | return i_colorcount(im); |
Branch: 1 branch
| Branch | True | False | Total |
| return i_colorcount(im); |
0 |
0 |
0 |
|
| 564 |
|
| } |
| 565 |
|
| |
| 566 |
|
| /* |
| 567 |
|
| =item i_maxcolors(im) |
| 568 |
|
| |
| 569 |
|
| =category Paletted images |
| 570 |
|
| |
| 571 |
|
| Returns the maximum number of colors the palette can hold for the |
| 572 |
|
| image. |
| 573 |
|
| |
| 574 |
|
| Returns -1 for direct color images. |
| 575 |
|
| |
| 576 |
|
| =cut |
| 577 |
|
| */ |
| 578 |
|
| |
| 579 |
|
| int |
| 580 |
0 |
| (i_maxcolors)(i_img *im) { |
| 581 |
0 |
▶ | return i_maxcolors(im); |
Branch: 1 branch
| Branch | True | False | Total |
| return i_maxcolors(im); |
0 |
0 |
0 |
|
| 582 |
|
| } |
| 583 |
|
| |
| 584 |
|
| /* |
| 585 |
|
| =item i_findcolor(im, color, &entry) |
| 586 |
|
| |
| 587 |
|
| =category Paletted images |
| 588 |
|
| |
| 589 |
|
| Searches the images palette for the given color. |
| 590 |
|
| |
| 591 |
|
| On success sets *I<entry> to the index of the color, and returns true. |
| 592 |
|
| |
| 593 |
|
| On failure returns false. |
| 594 |
|
| |
| 595 |
|
| Always fails on direct color images. |
| 596 |
|
| |
| 597 |
|
| =cut |
| 598 |
|
| */ |
| 599 |
|
| int |
| 600 |
0 |
| (i_findcolor)(i_img *im, const i_color *color, i_palidx *entry) { |
| 601 |
0 |
▶ | return i_findcolor(im, color, entry); |
Branch: 1 branch
| Branch | True | False | Total |
| return i_findcolor(im, color, entry); |
0 |
0 |
0 |
|
| 602 |
|
| } |
| 603 |
|
| |
| 604 |
|
| /* |
| 605 |
|
| =item i_setcolors(im, index, colors, count) |
| 606 |
|
| |
| 607 |
|
| =category Paletted images |
| 608 |
|
| |
| 609 |
|
| Sets I<count> colors starting from I<index> in the image's palette. |
| 610 |
|
| |
| 611 |
|
| On success returns true. |
| 612 |
|
| |
| 613 |
|
| On failure returns false. |
| 614 |
|
| |
| 615 |
|
| The image must have at least I<index>+I<count> colors in it's palette |
| 616 |
|
| for this to succeed. |
| 617 |
|
| |
| 618 |
|
| Always fails on direct color images. |
| 619 |
|
| |
| 620 |
|
| =cut |
| 621 |
|
| */ |
| 622 |
|
| int |
| 623 |
0 |
| (i_setcolors)(i_img *im, int index, const i_color *colors, int count) { |
| 624 |
0 |
▶ | return i_setcolors(im, index, colors, count); |
Branch: 1 branch
| Branch | True | False | Total |
| return i_setcolors(im, index, colors, count); |
0 |
0 |
0 |
|
| 625 |
|
| } |
| 626 |
|
| |
| 627 |
|
| /* |
| 628 |
|
| =item im_get_context() |
| 629 |
|
| |
| 630 |
|
| Retrieve the context object for the current thread. |
| 631 |
|
| |
| 632 |
|
| Inside Imager itself this is just a function pointer, which the |
| 633 |
|
| F<Imager.xs> BOOT handler initializes for use within perl. If you're |
| 634 |
|
| taking the Imager code and embedding it elsewhere you need to |
| 635 |
|
| initialize the C<im_get_context> pointer at some point. |
| 636 |
|
| |
| 637 |
|
| =cut |
| 638 |
|
| */ |
| 639 |
|
| |
| 640 |
|
| static im_context_t |
| 641 |
445 |
| get_context(void) { |
| 642 |
445 |
| return im_get_context(); |
| 643 |
|
| } |
| 644 |
|
| |
| 645 |
|
| static i_img * |
| 646 |
0 |
| mathom_i_img_8_new(i_img_dim xsize, i_img_dim ysize, int channels) { |
| 647 |
0 |
| return i_img_8_new(xsize, ysize, channels); |
| 648 |
|
| } |
| 649 |
|
| |
| 650 |
|
| static i_img * |
| 651 |
0 |
| mathom_i_img_16_new(i_img_dim xsize, i_img_dim ysize, int channels) { |
| 652 |
0 |
| return i_img_16_new(xsize, ysize, channels); |
| 653 |
|
| } |
| 654 |
|
| |
| 655 |
|
| static i_img * |
| 656 |
0 |
| mathom_i_img_double_new(i_img_dim xsize, i_img_dim ysize, int channels) { |
| 657 |
0 |
| return i_img_double_new(xsize, ysize, channels); |
| 658 |
|
| } |
| 659 |
|
| |
| 660 |
|
| static i_img * |
| 661 |
0 |
| mathom_i_img_pal_new(i_img_dim xsize, i_img_dim ysize, int channels, |
| 662 |
|
| int maxpal) { |
| 663 |
0 |
| return i_img_pal_new(xsize, ysize, channels, maxpal); |
| 664 |
|
| } |
| 665 |
|
| |
| 666 |
|
| static void |
| 667 |
0 |
| mathom_i_clear_error(void) { |
| 668 |
0 |
| i_clear_error(); |
| 669 |
0 |
| } |
| 670 |
|
| |
| 671 |
|
| static void |
| 672 |
0 |
| mathom_i_push_error(int code, const char *msg) { |
| 673 |
0 |
| i_push_error(code, msg); |
| 674 |
0 |
| } |
| 675 |
|
| |
| 676 |
|
| static void |
| 677 |
0 |
| mathom_i_push_errorvf(int code, const char *fmt, va_list args) { |
| 678 |
0 |
| i_push_errorvf(code, fmt, args); |
| 679 |
0 |
| } |
| 680 |
|
| |
| 681 |
|
| static int |
| 682 |
0 |
| mathom_i_set_image_file_limits(i_img_dim max_width, i_img_dim max_height, |
| 683 |
|
| size_t max_bytes) { |
| 684 |
0 |
| return i_set_image_file_limits(max_width, max_height, max_bytes); |
| 685 |
|
| } |
| 686 |
|
| |
| 687 |
|
| static int |
| 688 |
0 |
| mathom_i_get_image_file_limits(i_img_dim *pmax_width, i_img_dim *pmax_height, |
| 689 |
|
| size_t *pmax_bytes) { |
| 690 |
0 |
| return i_get_image_file_limits(pmax_width, pmax_height, pmax_bytes); |
| 691 |
|
| } |
| 692 |
|
| |
| 693 |
|
| static int |
| 694 |
0 |
| mathom_i_int_check_image_file_limits(i_img_dim width, i_img_dim height, |
| 695 |
|
| int channels, size_t sample_size) { |
| 696 |
0 |
| return i_int_check_image_file_limits(width, height, channels, sample_size); |
| 697 |
|
| } |
| 698 |
|
| |
| 699 |
|
| static i_img * |
| 700 |
0 |
| mathom_i_img_alloc(void) { |
| 701 |
0 |
| return i_img_alloc(); |
| 702 |
|
| } |
| 703 |
|
| |
| 704 |
|
| static void |
| 705 |
0 |
| mathom_i_img_init(i_img *im) { |
| 706 |
0 |
| i_img_init(im); |
| 707 |
0 |
| } |
| 708 |
|
| |
| 709 |
|
| static i_io_glue_t * |
| 710 |
0 |
| mathom_io_new_fd(int fd) { |
| 711 |
0 |
| return io_new_fd(fd); |
| 712 |
|
| } |
| 713 |
|
| static i_io_glue_t * |
| 714 |
0 |
| mathom_io_new_bufchain(void) { |
| 715 |
0 |
| return io_new_bufchain(); |
| 716 |
|
| } |
| 717 |
|
| |
| 718 |
|
| static i_io_glue_t * |
| 719 |
0 |
| mathom_io_new_buffer(const char *data, size_t size, i_io_closebufp_t closefp, |
| 720 |
|
| void *close_data) { |
| 721 |
0 |
| return io_new_buffer(data, size, closefp, close_data); |
| 722 |
|
| } |
| 723 |
|
| |
| 724 |
|
| static i_io_glue_t * |
| 725 |
0 |
| mathom_io_new_cb(void *p, i_io_readl_t readcb, i_io_writel_t writecb, |
| 726 |
|
| i_io_seekl_t seekcb, i_io_closel_t closecb, |
| 727 |
|
| i_io_destroyl_t destroycb) { |
| 728 |
0 |
| return io_new_cb(p, readcb, writecb, seekcb, closecb, destroycb); |
| 729 |
|
| } |