| 1 |
#define PERL_NO_GET_CONTEXT |
| 2 |
#ifdef __cplusplus |
| 3 |
extern "C" { |
| 4 |
#endif |
| 5 |
#include "EXTERN.h" |
| 6 |
#include "perl.h" |
| 7 |
#include "XSUB.h" |
| 8 |
#define NEED_newRV_noinc |
| 9 |
#define NEED_sv_2pv_nolen |
| 10 |
#define NEED_sv_2pvbyte |
| 11 |
#include "ppport.h" |
| 12 |
#ifdef __cplusplus |
| 13 |
} |
| 14 |
#endif |
| 15 |
|
| 16 |
#define i_int_hlines_testing() 1 |
| 17 |
|
| 18 |
#include "imager.h" |
| 19 |
#include "feat.h" |
| 20 |
#include "dynaload.h" |
| 21 |
#include "regmach.h" |
| 22 |
#include "imextdef.h" |
| 23 |
#include "imextpltypes.h" |
| 24 |
#include "imperlio.h" |
| 25 |
#include <float.h> |
| 26 |
|
| 27 |
#if i_int_hlines_testing() |
| 28 |
#include "imageri.h" |
| 29 |
#endif |
| 30 |
|
| 31 |
#include "imperl.h" |
| 32 |
|
| 33 |
#define ARRAY_COUNT(array) (sizeof(array)/sizeof(*array)) |
| 34 |
|
| 35 |
#ifndef SSize_t_MAX |
| 36 |
#define SSize_t_MAX (SSize_t)(~(Size_t)0 >> 1) |
| 37 |
#endif |
| 38 |
|
| 39 |
/* |
| 40 |
|
| 41 |
Context object management |
| 42 |
|
| 43 |
*/ |
| 44 |
|
| 45 |
#ifdef PERL_IMPLICIT_CONTEXT |
| 46 |
|
| 47 |
#define MY_CXT_KEY "Imager::_context" XS_VERSION |
| 48 |
|
| 49 |
typedef struct { |
| 50 |
im_context_t ctx; |
| 51 |
} my_cxt_t; |
| 52 |
|
| 53 |
START_MY_CXT |
| 54 |
|
| 55 |
static void |
| 56 |
start_context(pTHX) { |
| 57 |
dMY_CXT; |
| 58 |
MY_CXT.ctx = im_context_new(); |
| 59 |
sv_setref_pv(get_sv("Imager::_context", GV_ADD), "Imager::Context", MY_CXT.ctx); |
| 60 |
} |
| 61 |
|
| 62 |
static im_context_t |
| 63 |
perl_get_context(void) { |
| 64 |
dTHX; |
| 65 |
dMY_CXT; |
| 66 |
|
| 67 |
return MY_CXT.ctx; |
| 68 |
} |
| 69 |
|
| 70 |
#else |
| 71 |
|
| 72 |
static im_context_t perl_context; |
| 73 |
|
| 74 |
static void |
| 75 |
start_context(pTHX) { |
| 76 |
perl_context = im_context_new(); |
| 77 |
|
| 78 |
/* just so it gets destroyed */ |
| 79 |
sv_setref_pv(get_sv("Imager::_context", GV_ADD), "Imager::Context", perl_context); |
| 80 |
} |
| 81 |
|
| 82 |
static im_context_t |
| 83 |
perl_get_context(void) { |
| 84 |
return perl_context; |
| 85 |
} |
| 86 |
|
| 87 |
#endif |
| 88 |
|
| 89 |
typedef im_context_t Imager__Context; |
| 90 |
|
| 91 |
static void |
| 92 |
S_im_context_DESTROY(pTHX_ im_context_t ctx) { |
| 93 |
#ifdef PERL_IMPLICIT_CONTEXT |
| 94 |
dMY_CXT; |
| 95 |
|
| 96 |
if (ctx == MY_CXT.ctx) |
| 97 |
MY_CXT.ctx = NULL; |
| 98 |
#else |
| 99 |
perl_context = NULL; |
| 100 |
#endif |
| 101 |
|
| 102 |
im_context_refdec(ctx, "DESTROY"); |
| 103 |
} |
| 104 |
|
| 105 |
#define im_context_DESTROY(ctx) S_im_context_DESTROY(aTHX_ (ctx)) |
| 106 |
|
| 107 |
/* used to represent channel lists parameters */ |
| 108 |
typedef struct i_channel_list_tag { |
| 109 |
int *channels; |
| 110 |
int count; |
| 111 |
} i_channel_list; |
| 112 |
|
| 113 |
typedef struct { |
| 114 |
size_t count; |
| 115 |
const i_sample_t *samples; |
| 116 |
} i_sample_list; |
| 117 |
|
| 118 |
typedef struct { |
| 119 |
size_t count; |
| 120 |
const i_fsample_t *samples; |
| 121 |
} i_fsample_list; |
| 122 |
|
| 123 |
typedef struct { |
| 124 |
size_t count; |
| 125 |
const i_polygon_t *polygons; |
| 126 |
} i_polygon_list; |
| 127 |
|
| 128 |
typedef struct { |
| 129 |
SV *sv; |
| 130 |
SV *rsv; |
| 131 |
size_t count; |
| 132 |
i_trim_colors_t *colors; |
| 133 |
} i_trim_color_list; |
| 134 |
|
| 135 |
/* |
| 136 |
|
| 137 |
Allocate memory that will be discarded when mortals are discarded. |
| 138 |
|
| 139 |
*/ |
| 140 |
|
| 141 |
static void * |
| 142 |
malloc_temp(pTHX_ size_t size) { |
| 143 |
void *result; |
| 144 |
Newx(result, size, char); |
| 145 |
SAVEFREEPV(result); |
| 146 |
|
| 147 |
return result; |
| 148 |
} |
| 149 |
|
| 150 |
static void * |
| 151 |
calloc_temp(pTHX_ size_t size) { |
| 152 |
void *result; |
| 153 |
Newxz(result, size, char); |
| 154 |
SAVEFREEPV(result); |
| 155 |
|
| 156 |
return result; |
| 157 |
} |
| 158 |
|
| 159 |
/* for use with the T_AVARRAY typemap */ |
| 160 |
#define doublePtr(size) ((double *)calloc_temp(aTHX_ sizeof(double) * (size))) |
| 161 |
#define SvDouble(sv, pname) (SvNV(sv)) |
| 162 |
|
| 163 |
#define intPtr(size) ((int *)calloc_temp(aTHX_ sizeof(int) * (size))) |
| 164 |
#define SvInt(sv, pname) (SvIV(sv)) |
| 165 |
|
| 166 |
#define i_img_dimPtr(size) ((i_img_dim *)calloc_temp(aTHX_ sizeof(i_img_dim) * (size))) |
| 167 |
#define SvI_img_dim(sv, pname) (SvIV(sv)) |
| 168 |
|
| 169 |
#define i_colorPtr(size) ((i_color *)calloc_temp(aTHX_ sizeof(i_color) * (size))) |
| 170 |
|
| 171 |
#define SvI_color(sv, pname) S_sv_to_i_color(aTHX_ sv, pname) |
| 172 |
|
| 173 |
static i_color |
| 174 |
S_sv_to_i_color(pTHX_ SV *sv, const char *pname) { |
| 175 |
if (!sv_derived_from(sv, "Imager::Color")) { |
| 176 |
croak("%s: not a color object", pname); |
| 177 |
} |
| 178 |
return *INT2PTR(i_color *, SvIV((SV *)SvRV(sv))); |
| 179 |
} |
| 180 |
|
| 181 |
/* These functions are all shared - then comes platform dependant code */ |
| 182 |
static int getstr(void *hv_t,char *key,char **store) { |
| 183 |
dTHX; |
| 184 |
SV** svpp; |
| 185 |
HV* hv=(HV*)hv_t; |
| 186 |
|
| 187 |
mm_log((1,"getstr(hv_t %p, key %s, store %p)\n",hv_t,key,store)); |
| 188 |
|
| 189 |
if ( !hv_exists(hv,key,strlen(key)) ) return 0; |
| 190 |
|
| 191 |
svpp=hv_fetch(hv, key, strlen(key), 0); |
| 192 |
*store=SvPV(*svpp, PL_na ); |
| 193 |
|
| 194 |
return 1; |
| 195 |
} |
| 196 |
|
| 197 |
static int getint(void *hv_t,char *key,int *store) { |
| 198 |
dTHX; |
| 199 |
SV** svpp; |
| 200 |
HV* hv=(HV*)hv_t; |
| 201 |
|
| 202 |
mm_log((1,"getint(hv_t %p, key %s, store %p)\n",hv_t,key,store)); |
| 203 |
|
| 204 |
if ( !hv_exists(hv,key,strlen(key)) ) return 0; |
| 205 |
|
| 206 |
svpp=hv_fetch(hv, key, strlen(key), 0); |
| 207 |
*store=(int)SvIV(*svpp); |
| 208 |
return 1; |
| 209 |
} |
| 210 |
|
| 211 |
static int getdouble(void *hv_t,char* key,double *store) { |
| 212 |
dTHX; |
| 213 |
SV** svpp; |
| 214 |
HV* hv=(HV*)hv_t; |
| 215 |
|
| 216 |
mm_log((1,"getdouble(hv_t %p, key %s, store %p)\n",hv_t,key,store)); |
| 217 |
|
| 218 |
if ( !hv_exists(hv,key,strlen(key)) ) return 0; |
| 219 |
svpp=hv_fetch(hv, key, strlen(key), 0); |
| 220 |
*store=(double)SvNV(*svpp); |
| 221 |
return 1; |
| 222 |
} |
| 223 |
|
| 224 |
static int getvoid(void *hv_t,char* key,void **store) { |
| 225 |
dTHX; |
| 226 |
SV** svpp; |
| 227 |
HV* hv=(HV*)hv_t; |
| 228 |
|
| 229 |
mm_log((1,"getvoid(hv_t %p, key %s, store %p)\n",hv_t,key,store)); |
| 230 |
|
| 231 |
if ( !hv_exists(hv,key,strlen(key)) ) return 0; |
| 232 |
|
| 233 |
svpp=hv_fetch(hv, key, strlen(key), 0); |
| 234 |
*store = INT2PTR(void*, SvIV(*svpp)); |
| 235 |
|
| 236 |
return 1; |
| 237 |
} |
| 238 |
|
| 239 |
static int getobj(void *hv_t,char *key,char *type,void **store) { |
| 240 |
dTHX; |
| 241 |
SV** svpp; |
| 242 |
HV* hv=(HV*)hv_t; |
| 243 |
|
| 244 |
mm_log((1,"getobj(hv_t %p, key %s,type %s, store %p)\n",hv_t,key,type,store)); |
| 245 |
|
| 246 |
if ( !hv_exists(hv,key,strlen(key)) ) return 0; |
| 247 |
|
| 248 |
svpp=hv_fetch(hv, key, strlen(key), 0); |
| 249 |
|
| 250 |
if (sv_derived_from(*svpp,type)) { |
| 251 |
IV tmp = SvIV((SV*)SvRV(*svpp)); |
| 252 |
*store = INT2PTR(void*, tmp); |
| 253 |
} else { |
| 254 |
mm_log((1,"getobj: key exists in hash but is not of correct type")); |
| 255 |
return 0; |
| 256 |
} |
| 257 |
|
| 258 |
return 1; |
| 259 |
} |
| 260 |
|
| 261 |
UTIL_table_t i_UTIL_table={getstr,getint,getdouble,getvoid,getobj}; |
| 262 |
|
| 263 |
static void |
| 264 |
free_buffer(void *p) { |
| 265 |
myfree(p); |
| 266 |
} |
| 267 |
|
| 268 |
|
| 269 |
static void |
| 270 |
i_log_entry(char *string, int level) { |
| 271 |
mm_log((level, "%s", string)); |
| 272 |
} |
| 273 |
|
| 274 |
static SV * |
| 275 |
make_i_color_sv(pTHX_ const i_color *c) { |
| 276 |
SV *sv; |
| 277 |
i_color *col = mymalloc(sizeof(i_color)); |
| 278 |
*col = *c; |
| 279 |
sv = newSV(0); |
| 280 |
sv_setref_pv(sv, "Imager::Color", (void *)col); |
| 281 |
|
| 282 |
return sv; |
| 283 |
} |
| 284 |
|
| 285 |
static SV * |
| 286 |
make_i_color_sv_mortal(pTHX_ const i_color *c) { |
| 287 |
return sv_2mortal(make_i_color_sv(aTHX_ c)); |
| 288 |
} |
| 289 |
|
| 290 |
static SV * |
| 291 |
make_i_fcolor_sv(pTHX_ const i_fcolor *c) { |
| 292 |
SV *sv; |
| 293 |
i_fcolor *col = mymalloc(sizeof(i_fcolor)); |
| 294 |
*col = *c; |
| 295 |
sv = newSV(0); |
| 296 |
sv_setref_pv(sv, "Imager::Color::Float", (void *)col); |
| 297 |
|
| 298 |
return sv; |
| 299 |
} |
| 300 |
|
| 301 |
static SV * |
| 302 |
make_i_fcolor_sv_mortal(pTHX_ const i_fcolor *c) { |
| 303 |
return sv_2mortal(make_i_fcolor_sv(aTHX_ c)); |
| 304 |
} |
| 305 |
|
| 306 |
#define CBDATA_BUFSIZE 8192 |
| 307 |
|
| 308 |
struct cbdata { |
| 309 |
/* the SVs we use to call back to Perl */ |
| 310 |
SV *writecb; |
| 311 |
SV *readcb; |
| 312 |
SV *seekcb; |
| 313 |
SV *closecb; |
| 314 |
}; |
| 315 |
|
| 316 |
static ssize_t |
| 317 |
call_reader(struct cbdata *cbd, void *buf, size_t size, |
| 318 |
size_t maxread) { |
| 319 |
dTHX; |
| 320 |
int count; |
| 321 |
int result; |
| 322 |
SV *data; |
| 323 |
dSP; |
| 324 |
|
| 325 |
if (!SvOK(cbd->readcb)) { |
| 326 |
mm_log((1, "read callback called but no readcb supplied\n")); |
| 327 |
i_push_error(0, "read callback called but no readcb supplied"); |
| 328 |
return -1; |
| 329 |
} |
| 330 |
|
| 331 |
ENTER; |
| 332 |
SAVETMPS; |
| 333 |
EXTEND(SP, 2); |
| 334 |
PUSHMARK(SP); |
| 335 |
PUSHs(sv_2mortal(newSViv(size))); |
| 336 |
PUSHs(sv_2mortal(newSViv(maxread))); |
| 337 |
PUTBACK; |
| 338 |
|
| 339 |
count = perl_call_sv(cbd->readcb, G_SCALAR); |
| 340 |
|
| 341 |
SPAGAIN; |
| 342 |
|
| 343 |
if (count != 1) |
| 344 |
croak("Result of perl_call_sv(..., G_SCALAR) != 1"); |
| 345 |
|
| 346 |
data = POPs; |
| 347 |
|
| 348 |
if (SvOK(data)) { |
| 349 |
STRLEN len; |
| 350 |
char *ptr = SvPVbyte(data, len); |
| 351 |
if (len > maxread) |
| 352 |
croak("Too much data returned in reader callback (wanted %d, got %d, expected %d)", |
| 353 |
(int)size, (int)len, (int)maxread); |
| 354 |
|
| 355 |
memcpy(buf, ptr, len); |
| 356 |
result = len; |
| 357 |
} |
| 358 |
else { |
| 359 |
result = -1; |
| 360 |
} |
| 361 |
|
| 362 |
PUTBACK; |
| 363 |
FREETMPS; |
| 364 |
LEAVE; |
| 365 |
|
| 366 |
return result; |
| 367 |
} |
| 368 |
|
| 369 |
static off_t |
| 370 |
io_seeker(void *p, off_t offset, int whence) { |
| 371 |
dTHX; |
| 372 |
struct cbdata *cbd = p; |
| 373 |
int count; |
| 374 |
off_t result; |
| 375 |
dSP; |
| 376 |
|
| 377 |
if (!SvOK(cbd->seekcb)) { |
| 378 |
mm_log((1, "seek callback called but no seekcb supplied\n")); |
| 379 |
i_push_error(0, "seek callback called but no seekcb supplied"); |
| 380 |
return -1; |
| 381 |
} |
| 382 |
|
| 383 |
ENTER; |
| 384 |
SAVETMPS; |
| 385 |
EXTEND(SP, 2); |
| 386 |
PUSHMARK(SP); |
| 387 |
PUSHs(sv_2mortal(newSViv(offset))); |
| 388 |
PUSHs(sv_2mortal(newSViv(whence))); |
| 389 |
PUTBACK; |
| 390 |
|
| 391 |
count = perl_call_sv(cbd->seekcb, G_SCALAR); |
| 392 |
|
| 393 |
SPAGAIN; |
| 394 |
|
| 395 |
if (count != 1) |
| 396 |
croak("Result of perl_call_sv(..., G_SCALAR) != 1"); |
| 397 |
|
| 398 |
result = POPi; |
| 399 |
|
| 400 |
PUTBACK; |
| 401 |
FREETMPS; |
| 402 |
LEAVE; |
| 403 |
|
| 404 |
return result; |
| 405 |
} |
| 406 |
|
| 407 |
static ssize_t |
| 408 |
io_writer(void *p, void const *data, size_t size) { |
| 409 |
dTHX; |
| 410 |
struct cbdata *cbd = p; |
| 411 |
I32 count; |
| 412 |
SV *sv; |
| 413 |
dSP; |
| 414 |
bool success; |
| 415 |
|
| 416 |
if (!SvOK(cbd->writecb)) { |
| 417 |
mm_log((1, "write callback called but no writecb supplied\n")); |
| 418 |
i_push_error(0, "write callback called but no writecb supplied"); |
| 419 |
return -1; |
| 420 |
} |
| 421 |
|
| 422 |
ENTER; |
| 423 |
SAVETMPS; |
| 424 |
EXTEND(SP, 1); |
| 425 |
PUSHMARK(SP); |
| 426 |
PUSHs(sv_2mortal(newSVpv((char *)data, size))); |
| 427 |
PUTBACK; |
| 428 |
|
| 429 |
count = perl_call_sv(cbd->writecb, G_SCALAR); |
| 430 |
|
| 431 |
SPAGAIN; |
| 432 |
if (count != 1) |
| 433 |
croak("Result of perl_call_sv(..., G_SCALAR) != 1"); |
| 434 |
|
| 435 |
sv = POPs; |
| 436 |
success = SvTRUE(sv); |
| 437 |
|
| 438 |
|
| 439 |
PUTBACK; |
| 440 |
FREETMPS; |
| 441 |
LEAVE; |
| 442 |
|
| 443 |
return success ? (ssize_t)size : -1; |
| 444 |
} |
| 445 |
|
| 446 |
static ssize_t |
| 447 |
io_reader(void *p, void *data, size_t size) { |
| 448 |
struct cbdata *cbd = p; |
| 449 |
|
| 450 |
return call_reader(cbd, data, size, size); |
| 451 |
} |
| 452 |
|
| 453 |
static int io_closer(void *p) { |
| 454 |
dTHX; |
| 455 |
struct cbdata *cbd = p; |
| 456 |
int success = 1; |
| 457 |
|
| 458 |
if (SvOK(cbd->closecb)) { |
| 459 |
dSP; |
| 460 |
I32 count; |
| 461 |
|
| 462 |
ENTER; |
| 463 |
SAVETMPS; |
| 464 |
PUSHMARK(SP); |
| 465 |
PUTBACK; |
| 466 |
|
| 467 |
count = perl_call_sv(cbd->closecb, G_SCALAR); |
| 468 |
|
| 469 |
SPAGAIN; |
| 470 |
|
| 471 |
if (count) { |
| 472 |
SV *sv = POPs; |
| 473 |
success = SvTRUE(sv); |
| 474 |
} |
| 475 |
else |
| 476 |
success = 0; |
| 477 |
|
| 478 |
PUTBACK; |
| 479 |
FREETMPS; |
| 480 |
LEAVE; |
| 481 |
} |
| 482 |
|
| 483 |
return success ? 0 : -1; |
| 484 |
} |
| 485 |
|
| 486 |
static void io_destroyer(void *p) { |
| 487 |
dTHX; |
| 488 |
struct cbdata *cbd = p; |
| 489 |
|
| 490 |
SvREFCNT_dec(cbd->writecb); |
| 491 |
SvREFCNT_dec(cbd->readcb); |
| 492 |
SvREFCNT_dec(cbd->seekcb); |
| 493 |
SvREFCNT_dec(cbd->closecb); |
| 494 |
myfree(cbd); |
| 495 |
} |
| 496 |
|
| 497 |
static bool |
| 498 |
im_SvREFSCALAR(SV *sv) { |
| 499 |
svtype type = SvTYPE(sv); |
| 500 |
|
| 501 |
switch (type) { |
| 502 |
case SVt_PV: |
| 503 |
case SVt_PVIV: |
| 504 |
case SVt_PVNV: |
| 505 |
case SVt_PVMG: |
| 506 |
case SVt_IV: |
| 507 |
case SVt_NV: |
| 508 |
case SVt_PVLV: |
| 509 |
#if PERL_VERSION > 10 |
| 510 |
case SVt_REGEXP: |
| 511 |
#endif |
| 512 |
return 1; |
| 513 |
|
| 514 |
default: |
| 515 |
return 0; |
| 516 |
} |
| 517 |
} |
| 518 |
|
| 519 |
static const char * |
| 520 |
describe_sv(SV *sv) { |
| 521 |
if (SvOK(sv)) { |
| 522 |
if (SvROK(sv)) { |
| 523 |
svtype type = SvTYPE(SvRV(sv)); |
| 524 |
switch (type) { |
| 525 |
case SVt_PVCV: return "CV"; |
| 526 |
case SVt_PVGV: return "GV"; |
| 527 |
case SVt_PVLV: return "LV"; |
| 528 |
default: return "some reference"; |
| 529 |
} |
| 530 |
} |
| 531 |
else { |
| 532 |
return "non-reference scalar"; |
| 533 |
} |
| 534 |
} |
| 535 |
else { |
| 536 |
return "undef"; |
| 537 |
} |
| 538 |
} |
| 539 |
|
| 540 |
static i_io_glue_t * |
| 541 |
do_io_new_buffer(pTHX_ SV *data_sv) { |
| 542 |
const char *data; |
| 543 |
char *data_copy; |
| 544 |
STRLEN length; |
| 545 |
SV *sv; |
| 546 |
|
| 547 |
SvGETMAGIC(data_sv); |
| 548 |
if (SvROK(data_sv)) { |
| 549 |
if (im_SvREFSCALAR(SvRV(data_sv))) { |
| 550 |
sv = SvRV(data_sv); |
| 551 |
} |
| 552 |
else { |
| 553 |
i_push_errorf(0, "data is not a scalar or a reference to scalar"); |
| 554 |
return NULL; |
| 555 |
} |
| 556 |
} |
| 557 |
else { |
| 558 |
sv = data_sv; |
| 559 |
} |
| 560 |
|
| 561 |
/* previously this would keep the SV around, but this is unsafe in |
| 562 |
many ways, so always copy the bytes */ |
| 563 |
data = SvPVbyte(sv, length); |
| 564 |
data_copy = mymalloc(length); |
| 565 |
memcpy(data_copy, data, length); |
| 566 |
return io_new_buffer(data_copy, length, free_buffer, data_copy); |
| 567 |
} |
| 568 |
|
| 569 |
static i_io_glue_t * |
| 570 |
do_io_new_cb(pTHX_ SV *writecb, SV *readcb, SV *seekcb, SV *closecb) { |
| 571 |
struct cbdata *cbd; |
| 572 |
|
| 573 |
cbd = mymalloc(sizeof(struct cbdata)); |
| 574 |
cbd->writecb = newSVsv(writecb); |
| 575 |
cbd->readcb = newSVsv(readcb); |
| 576 |
cbd->seekcb = newSVsv(seekcb); |
| 577 |
cbd->closecb = newSVsv(closecb); |
| 578 |
|
| 579 |
mm_log((1, "do_io_new_cb(writecb %p (%s), readcb %p (%s), seekcb %p (%s), closecb %p (%s))\n", writecb, describe_sv(writecb), readcb, describe_sv(readcb), seekcb, describe_sv(seekcb), closecb, describe_sv(closecb))); |
| 580 |
|
| 581 |
return io_new_cb(cbd, io_reader, io_writer, io_seeker, io_closer, |
| 582 |
io_destroyer); |
| 583 |
} |
| 584 |
|
| 585 |
struct value_name { |
| 586 |
const char *name; |
| 587 |
int value; |
| 588 |
}; |
| 589 |
static int |
| 590 |
lookup_name(const struct value_name *names, int count, char *name, int def_value, int push_errors, const char *id, int *failed) |
| 591 |
{ |
| 592 |
int i; |
| 593 |
|
| 594 |
if (push_errors) |
| 595 |
*failed = 0; |
| 596 |
|
| 597 |
for (i = 0; i < count; ++i) |
| 598 |
if (strEQ(names[i].name, name)) |
| 599 |
return names[i].value; |
| 600 |
|
| 601 |
if (push_errors) { |
| 602 |
i_push_errorf(0, "unknown value '%s' for %s", name, id); |
| 603 |
*failed = 1; |
| 604 |
} |
| 605 |
|
| 606 |
return def_value; |
| 607 |
} |
| 608 |
|
| 609 |
static struct value_name transp_names[] = |
| 610 |
{ |
| 611 |
{ "none", tr_none }, |
| 612 |
{ "threshold", tr_threshold }, |
| 613 |
{ "errdiff", tr_errdiff }, |
| 614 |
{ "ordered", tr_ordered, }, |
| 615 |
}; |
| 616 |
|
| 617 |
static struct value_name make_color_names[] = |
| 618 |
{ |
| 619 |
{ "none", mc_none, }, |
| 620 |
{ "webmap", mc_web_map, }, |
| 621 |
{ "addi", mc_addi, }, |
| 622 |
{ "mediancut", mc_median_cut, }, |
| 623 |
{ "mono", mc_mono, }, |
| 624 |
{ "monochrome", mc_mono, }, |
| 625 |
{ "gray", mc_gray, }, |
| 626 |
{ "gray4", mc_gray4, }, |
| 627 |
{ "gray16", mc_gray16, }, |
| 628 |
}; |
| 629 |
|
| 630 |
static struct value_name translate_names[] = |
| 631 |
{ |
| 632 |
{ "giflib", pt_giflib, }, |
| 633 |
{ "closest", pt_closest, }, |
| 634 |
{ "perturb", pt_perturb, }, |
| 635 |
{ "errdiff", pt_errdiff, }, |
| 636 |
}; |
| 637 |
|
| 638 |
static struct value_name errdiff_names[] = |
| 639 |
{ |
| 640 |
{ "floyd", ed_floyd, }, |
| 641 |
{ "jarvis", ed_jarvis, }, |
| 642 |
{ "stucki", ed_stucki, }, |
| 643 |
{ "custom", ed_custom, }, |
| 644 |
}; |
| 645 |
|
| 646 |
static struct value_name orddith_names[] = |
| 647 |
{ |
| 648 |
{ "random", od_random, }, |
| 649 |
{ "dot8", od_dot8, }, |
| 650 |
{ "dot4", od_dot4, }, |
| 651 |
{ "hline", od_hline, }, |
| 652 |
{ "vline", od_vline, }, |
| 653 |
{ "/line", od_slashline, }, |
| 654 |
{ "slashline", od_slashline, }, |
| 655 |
{ "\\line", od_backline, }, |
| 656 |
{ "backline", od_backline, }, |
| 657 |
{ "tiny", od_tiny, }, |
| 658 |
{ "custom", od_custom, }, |
| 659 |
}; |
| 660 |
|
| 661 |
/* look through the hash for quantization options */ |
| 662 |
static int |
| 663 |
ip_handle_quant_opts_low(pTHX_ i_quantize *quant, HV *hv, int push_errors) |
| 664 |
{ |
| 665 |
SV **sv; |
| 666 |
int i; |
| 667 |
STRLEN len; |
| 668 |
char *str; |
| 669 |
int failed = 0; |
| 670 |
|
| 671 |
quant->mc_colors = mymalloc(quant->mc_size * sizeof(i_color)); |
| 672 |
|
| 673 |
sv = hv_fetch(hv, "transp", 6, 0); |
| 674 |
if (sv && *sv && (str = SvPV(*sv, len))) { |
| 675 |
quant->transp = |
| 676 |
lookup_name(transp_names, sizeof(transp_names)/sizeof(*transp_names), |
| 677 |
str, tr_none, push_errors, "transp", &failed); |
| 678 |
if (failed) |
| 679 |
return 0; |
| 680 |
if (quant->transp != tr_none) { |
| 681 |
quant->tr_threshold = 127; |
| 682 |
sv = hv_fetch(hv, "tr_threshold", 12, 0); |
| 683 |
if (sv && *sv) |
| 684 |
quant->tr_threshold = SvIV(*sv); |
| 685 |
} |
| 686 |
if (quant->transp == tr_errdiff) { |
| 687 |
sv = hv_fetch(hv, "tr_errdiff", 10, 0); |
| 688 |
if (sv && *sv && (str = SvPV(*sv, len))) { |
| 689 |
quant->tr_errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd, push_errors, "tr_errdiff", &failed); |
| 690 |
if (failed) |
| 691 |
return 0; |
| 692 |
} |
| 693 |
} |
| 694 |
if (quant->transp == tr_ordered) { |
| 695 |
quant->tr_orddith = od_tiny; |
| 696 |
sv = hv_fetch(hv, "tr_orddith", 10, 0); |
| 697 |
if (sv && *sv && (str = SvPV(*sv, len))) { |
| 698 |
quant->tr_orddith = lookup_name(orddith_names, sizeof(orddith_names)/sizeof(*orddith_names), str, od_random, push_errors, "tr_orddith", &failed); |
| 699 |
if (failed) |
| 700 |
return 0; |
| 701 |
} |
| 702 |
|
| 703 |
if (quant->tr_orddith == od_custom) { |
| 704 |
sv = hv_fetch(hv, "tr_map", 6, 0); |
| 705 |
if (sv && *sv && SvTYPE(SvRV(*sv)) == SVt_PVAV) { |
| 706 |
AV *av = (AV*)SvRV(*sv); |
| 707 |
unsigned index; |
| 708 |
len = av_len(av) + 1; |
| 709 |
if (len > sizeof(quant->tr_custom)) |
| 710 |
len = sizeof(quant->tr_custom); |
| 711 |
for (index = 0; index < len; ++index) { |
| 712 |
SV **sv2 = av_fetch(av, index, 0); |
| 713 |
if (sv2 && *sv2) { |
| 714 |
quant->tr_custom[index] = SvIV(*sv2); |
| 715 |
} |
| 716 |
} |
| 717 |
while (index < sizeof(quant->tr_custom)) |
| 718 |
quant->tr_custom[index++] = 0; |
| 719 |
} |
| 720 |
} |
| 721 |
} |
| 722 |
} |
| 723 |
quant->make_colors = mc_median_cut; |
| 724 |
sv = hv_fetch(hv, "make_colors", 11, 0); |
| 725 |
if (sv && *sv && (str = SvPV(*sv, len))) { |
| 726 |
quant->make_colors = |
| 727 |
lookup_name(make_color_names, sizeof(make_color_names)/sizeof(*make_color_names), str, mc_median_cut, push_errors, "make_colors", &failed); |
| 728 |
if (failed) |
| 729 |
return 0; |
| 730 |
} |
| 731 |
sv = hv_fetch(hv, "colors", 6, 0); |
| 732 |
if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) { |
| 733 |
/* needs to be an array of Imager::Color |
| 734 |
note that the caller allocates the mc_color array and sets mc_size |
| 735 |
to it's size */ |
| 736 |
AV *av = (AV *)SvRV(*sv); |
| 737 |
quant->mc_count = av_len(av)+1; |
| 738 |
if (quant->mc_count > quant->mc_size) |
| 739 |
quant->mc_count = quant->mc_size; |
| 740 |
for (i = 0; i < quant->mc_count; ++i) { |
| 741 |
SV **sv1 = av_fetch(av, i, 0); |
| 742 |
if (sv1 && *sv1 && SvROK(*sv1) && sv_derived_from(*sv1, "Imager::Color")) { |
| 743 |
i_color *col = INT2PTR(i_color *, SvIV((SV*)SvRV(*sv1))); |
| 744 |
quant->mc_colors[i] = *col; |
| 745 |
} |
| 746 |
else if (push_errors) { |
| 747 |
i_push_errorf(0, "colors[%d] isn't an Imager::Color object", i); |
| 748 |
return 0; |
| 749 |
} |
| 750 |
} |
| 751 |
} |
| 752 |
sv = hv_fetch(hv, "max_colors", 10, 0); |
| 753 |
if (sv && *sv) { |
| 754 |
IV iv = SvIV(*sv); |
| 755 |
if (iv <= 0) { |
| 756 |
i_push_errorf(0, "max_colors of %ld is invalid", (long)iv); |
| 757 |
return 0; |
| 758 |
} |
| 759 |
if (iv <= quant->mc_size && iv >= quant->mc_count) |
| 760 |
quant->mc_size = iv; |
| 761 |
} |
| 762 |
|
| 763 |
quant->translate = pt_closest; |
| 764 |
sv = hv_fetch(hv, "translate", 9, 0); |
| 765 |
if (sv && *sv && (str = SvPV(*sv, len))) { |
| 766 |
quant->translate = lookup_name(translate_names, sizeof(translate_names)/sizeof(*translate_names), str, pt_closest, push_errors, "translate", &failed); |
| 767 |
if (failed) |
| 768 |
return 0; |
| 769 |
} |
| 770 |
sv = hv_fetch(hv, "errdiff", 7, 0); |
| 771 |
if (sv && *sv && (str = SvPV(*sv, len))) { |
| 772 |
quant->errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd, push_errors, "errdiff", &failed); |
| 773 |
if (failed) |
| 774 |
return 0; |
| 775 |
} |
| 776 |
if (quant->translate == pt_errdiff && quant->errdiff == ed_custom) { |
| 777 |
/* get the error diffusion map */ |
| 778 |
sv = hv_fetch(hv, "errdiff_width", 13, 0); |
| 779 |
if (sv && *sv) |
| 780 |
quant->ed_width = SvIV(*sv); |
| 781 |
sv = hv_fetch(hv, "errdiff_height", 14, 0); |
| 782 |
if (sv && *sv) |
| 783 |
quant->ed_height = SvIV(*sv); |
| 784 |
sv = hv_fetch(hv, "errdiff_orig", 12, 0); |
| 785 |
if (sv && *sv) |
| 786 |
quant->ed_orig = SvIV(*sv); |
| 787 |
if (quant->ed_width > 0 && quant->ed_height > 0) { |
| 788 |
int sum = 0; |
| 789 |
quant->ed_map = mymalloc(sizeof(int) * quant->ed_width * quant->ed_height); |
| 790 |
sv = hv_fetch(hv, "errdiff_map", 11, 0); |
| 791 |
if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) { |
| 792 |
AV *av = (AV*)SvRV(*sv); |
| 793 |
size_t avi; |
| 794 |
len = av_len(av) + 1; |
| 795 |
if (len > (size_t)quant->ed_width * quant->ed_height) |
| 796 |
len = (size_t)quant->ed_width * quant->ed_height; |
| 797 |
for (avi = 0; avi < len; ++avi) { |
| 798 |
SV **sv2 = av_fetch(av, avi, 0); |
| 799 |
if (sv2 && *sv2) { |
| 800 |
IV iv = SvIV(*sv2); |
| 801 |
if (push_errors && iv < 0) { |
| 802 |
i_push_errorf(0, "errdiff_map values must be non-negative, errdiff[%lu] is negative", |
| 803 |
(unsigned long)avi); |
| 804 |
return 0; |
| 805 |
} |
| 806 |
quant->ed_map[avi] = iv; |
| 807 |
sum += quant->ed_map[avi]; |
| 808 |
} |
| 809 |
} |
| 810 |
} |
| 811 |
if (!sum) { |
| 812 |
/* broken map */ |
| 813 |
myfree(quant->ed_map); |
| 814 |
quant->ed_map = 0; |
| 815 |
quant->errdiff = ed_floyd; |
| 816 |
if (push_errors) { |
| 817 |
i_push_error(0, "error diffusion map must contain some non-zero values"); |
| 818 |
return 0; |
| 819 |
} |
| 820 |
} |
| 821 |
} |
| 822 |
} |
| 823 |
sv = hv_fetch(hv, "perturb", 7, 0); |
| 824 |
if (sv && *sv) |
| 825 |
quant->perturb = SvIV(*sv); |
| 826 |
|
| 827 |
return 1; |
| 828 |
} |
| 829 |
|
| 830 |
static void |
| 831 |
ip_cleanup_quant_opts(pTHX_ i_quantize *quant) { |
| 832 |
myfree(quant->mc_colors); |
| 833 |
if (quant->ed_map) |
| 834 |
myfree(quant->ed_map); |
| 835 |
} |
| 836 |
|
| 837 |
static int |
| 838 |
ip_handle_quant_opts2(pTHX_ i_quantize *quant, HV *hv) { |
| 839 |
int result = ip_handle_quant_opts_low(aTHX_ quant, hv, 1); |
| 840 |
if (!result) { |
| 841 |
ip_cleanup_quant_opts(aTHX_ quant); |
| 842 |
} |
| 843 |
return result; |
| 844 |
} |
| 845 |
|
| 846 |
static void |
| 847 |
ip_handle_quant_opts(pTHX_ i_quantize *quant, HV *hv) { |
| 848 |
(void)ip_handle_quant_opts_low(aTHX_ quant, hv, 0); |
| 849 |
} |
| 850 |
|
| 851 |
/* copies the color map from the hv into the colors member of the HV */ |
| 852 |
static void |
| 853 |
ip_copy_colors_back(pTHX_ HV *hv, i_quantize *quant) { |
| 854 |
SV **sv; |
| 855 |
AV *av; |
| 856 |
int i; |
| 857 |
SV *work; |
| 858 |
|
| 859 |
sv = hv_fetch(hv, "colors", 6, 0); |
| 860 |
if (!sv || !*sv || !SvROK(*sv) || SvTYPE(SvRV(*sv)) != SVt_PVAV) { |
| 861 |
/* nothing to do */ |
| 862 |
return; |
| 863 |
} |
| 864 |
|
| 865 |
av = (AV *)SvRV(*sv); |
| 866 |
av_clear(av); |
| 867 |
av_extend(av, quant->mc_count+1); |
| 868 |
for (i = 0; i < quant->mc_count; ++i) { |
| 869 |
i_color *in = quant->mc_colors+i; |
| 870 |
Imager__Color c = ICL_new_internal(in->rgb.r, in->rgb.g, in->rgb.b, 255); |
| 871 |
work = sv_newmortal(); |
| 872 |
sv_setref_pv(work, "Imager::Color", (void *)c); |
| 873 |
SvREFCNT_inc(work); |
| 874 |
av_push(av, work); |
| 875 |
} |
| 876 |
} |
| 877 |
|
| 878 |
static struct value_name |
| 879 |
poly_fill_mode_names[] = |
| 880 |
{ |
| 881 |
{ "evenodd", i_pfm_evenodd }, |
| 882 |
{ "nonzero", i_pfm_nonzero } |
| 883 |
}; |
| 884 |
|
| 885 |
static i_poly_fill_mode_t |
| 886 |
S_get_poly_fill_mode(pTHX_ SV *sv) { |
| 887 |
if (looks_like_number(sv)) { |
| 888 |
IV work = SvIV(sv); |
| 889 |
if (work < (IV)i_pfm_evenodd || work > (IV)i_pfm_nonzero) |
| 890 |
work = (IV)i_pfm_evenodd; |
| 891 |
return (i_poly_fill_mode_t)work; |
| 892 |
} |
| 893 |
else { |
| 894 |
return (i_poly_fill_mode_t)lookup_name |
| 895 |
(poly_fill_mode_names, ARRAY_COUNT(poly_fill_mode_names), |
| 896 |
SvPV_nolen(sv), i_pfm_evenodd, 0, NULL, NULL); |
| 897 |
} |
| 898 |
} |
| 899 |
|
| 900 |
static void |
| 901 |
S_get_polygon_list(pTHX_ i_polygon_list *polys, SV *sv) { |
| 902 |
AV *av; |
| 903 |
size_t poly_index; |
| 904 |
i_polygon_t *s; |
| 905 |
|
| 906 |
SvGETMAGIC(sv); |
| 907 |
if (!SvOK(sv) || !SvROK(sv) || SvTYPE(SvRV(sv)) != SVt_PVAV) |
| 908 |
croak("polys must be an arrayref"); |
| 909 |
|
| 910 |
av = (AV*)SvRV(sv); |
| 911 |
polys->count = av_len(av) + 1; |
| 912 |
if (polys->count < 1) |
| 913 |
croak("polypolygon: no polygons provided"); |
| 914 |
s = malloc_temp(aTHX_ sizeof(i_polygon_t) * polys->count); |
| 915 |
for (poly_index = 0; poly_index < polys->count; ++poly_index) { |
| 916 |
SV **poly_sv = av_fetch(av, poly_index, 0); |
| 917 |
AV *poly_av; |
| 918 |
SV **x_sv, **y_sv; |
| 919 |
AV *x_av, *y_av; |
| 920 |
double *x_data, *y_data; |
| 921 |
ssize_t j; |
| 922 |
ssize_t point_count; |
| 923 |
|
| 924 |
if (!poly_sv) |
| 925 |
croak("poly_polygon: nothing found for polygon %zu", poly_index); |
| 926 |
/* needs to be another av */ |
| 927 |
SvGETMAGIC(*poly_sv); |
| 928 |
if (!SvOK(*poly_sv) || !SvROK(*poly_sv) || SvTYPE(SvRV(*poly_sv)) != SVt_PVAV) |
| 929 |
croak("poly_polygon: polygon %zu isn't an arrayref", poly_index); |
| 930 |
poly_av = (AV*)SvRV(*poly_sv); |
| 931 |
/* with two elements */ |
| 932 |
if (av_len(poly_av) != 1) |
| 933 |
croak("poly_polygon: polygon %zu should contain two arrays", poly_index); |
| 934 |
x_sv = av_fetch(poly_av, 0, 0); |
| 935 |
y_sv = av_fetch(poly_av, 1, 0); |
| 936 |
if (!x_sv) |
| 937 |
croak("poly_polygon: polygon %zu has no x elements", poly_index); |
| 938 |
if (!y_sv) |
| 939 |
croak("poly_polygon: polygon %zu has no y elements", poly_index); |
| 940 |
SvGETMAGIC(*x_sv); |
| 941 |
SvGETMAGIC(*y_sv); |
| 942 |
if (!SvOK(*x_sv) || !SvROK(*x_sv) || SvTYPE(SvRV(*x_sv)) != SVt_PVAV) { |
| 943 |
croak("poly_polygon: polygon %zu x elements isn't an array", |
| 944 |
poly_index); |
| 945 |
} |
| 946 |
if (!SvOK(*y_sv) || !SvROK(*y_sv) || SvTYPE(SvRV(*y_sv)) != SVt_PVAV) { |
| 947 |
croak("poly_polygon: polygon %zu y elements isn't an array", |
| 948 |
poly_index); |
| 949 |
} |
| 950 |
x_av = (AV*)SvRV(*x_sv); |
| 951 |
y_av = (AV*)SvRV(*y_sv); |
| 952 |
if (av_len(x_av) != av_len(y_av)) { |
| 953 |
croak("poly_polygon: polygon %zu x and y arrays different lengths", |
| 954 |
poly_index+1); |
| 955 |
} |
| 956 |
point_count = av_len(x_av)+1; |
| 957 |
x_data = malloc_temp(aTHX_ sizeof(double) * point_count * 2); |
| 958 |
y_data = x_data + point_count; |
| 959 |
|
| 960 |
for (j = 0; j < point_count; ++j) { |
| 961 |
SV **x_item_sv = av_fetch(x_av, j, 0); |
| 962 |
SV **y_item_sv = av_fetch(y_av, j, 0); |
| 963 |
x_data[j] = x_item_sv ? SvNV(*x_item_sv) : 0; |
| 964 |
y_data[j] = y_item_sv ? SvNV(*y_item_sv) : 0; |
| 965 |
} |
| 966 |
s[poly_index].x = x_data; |
| 967 |
s[poly_index].y = y_data; |
| 968 |
s[poly_index].count = point_count; |
| 969 |
} |
| 970 |
polys->polygons = s; |
| 971 |
} |
| 972 |
|
| 973 |
/* loads the segments of a fountain fill into an array */ |
| 974 |
static i_fountain_seg * |
| 975 |
load_fount_segs(pTHX_ AV *asegs, int *count) { |
| 976 |
/* Each element of segs must contain: |
| 977 |
[ start, middle, end, c0, c1, segtype, colortrans ] |
| 978 |
start, middle, end are doubles from 0 to 1 |
| 979 |
c0, c1 are Imager::Color::Float or Imager::Color objects |
| 980 |
segtype, colortrans are ints |
| 981 |
*/ |
| 982 |
int i, j; |
| 983 |
AV *aseg; |
| 984 |
i_fountain_seg *segs; |
| 985 |
double work[3]; |
| 986 |
int worki[2]; |
| 987 |
|
| 988 |
*count = av_len(asegs)+1; |
| 989 |
if (*count < 1) |
| 990 |
croak("i_fountain must have at least one segment"); |
| 991 |
segs = mymalloc(sizeof(i_fountain_seg) * *count); |
| 992 |
for(i = 0; i < *count; i++) { |
| 993 |
SV **sv1 = av_fetch(asegs, i, 0); |
| 994 |
if (!sv1 || !*sv1 || !SvROK(*sv1) |
| 995 |
|| SvTYPE(SvRV(*sv1)) != SVt_PVAV) { |
| 996 |
myfree(segs); |
| 997 |
croak("i_fountain: segs must be an arrayref of arrayrefs"); |
| 998 |
} |
| 999 |
aseg = (AV *)SvRV(*sv1); |
| 1000 |
if (av_len(aseg) != 7-1) { |
| 1001 |
myfree(segs); |
| 1002 |
croak("i_fountain: a segment must have 7 members"); |
| 1003 |
} |
| 1004 |
for (j = 0; j < 3; ++j) { |
| 1005 |
SV **sv2 = av_fetch(aseg, j, 0); |
| 1006 |
if (!sv2 || !*sv2) { |
| 1007 |
myfree(segs); |
| 1008 |
croak("i_fountain: XS error"); |
| 1009 |
} |
| 1010 |
work[j] = SvNV(*sv2); |
| 1011 |
} |
| 1012 |
segs[i].start = work[0]; |
| 1013 |
segs[i].middle = work[1]; |
| 1014 |
segs[i].end = work[2]; |
| 1015 |
for (j = 0; j < 2; ++j) { |
| 1016 |
SV **sv3 = av_fetch(aseg, 3+j, 0); |
| 1017 |
if (!sv3 || !*sv3 || !SvROK(*sv3) || |
| 1018 |
(!sv_derived_from(*sv3, "Imager::Color") |
| 1019 |
&& !sv_derived_from(*sv3, "Imager::Color::Float"))) { |
| 1020 |
myfree(segs); |
| 1021 |
croak("i_fountain: segs must contain colors in elements 3 and 4"); |
| 1022 |
} |
| 1023 |
if (sv_derived_from(*sv3, "Imager::Color::Float")) { |
| 1024 |
segs[i].c[j] = *INT2PTR(i_fcolor *, SvIV((SV *)SvRV(*sv3))); |
| 1025 |
} |
| 1026 |
else { |
| 1027 |
i_color c = *INT2PTR(i_color *, SvIV((SV *)SvRV(*sv3))); |
| 1028 |
int ch; |
| 1029 |
for (ch = 0; ch < MAXCHANNELS; ++ch) { |
| 1030 |
segs[i].c[j].channel[ch] = c.channel[ch] / 255.0; |
| 1031 |
} |
| 1032 |
} |
| 1033 |
} |
| 1034 |
for (j = 0; j < 2; ++j) { |
| 1035 |
SV **sv2 = av_fetch(aseg, j+5, 0); |
| 1036 |
if (!sv2 || !*sv2) { |
| 1037 |
myfree(segs); |
| 1038 |
croak("i_fountain: XS error"); |
| 1039 |
} |
| 1040 |
worki[j] = SvIV(*sv2); |
| 1041 |
} |
| 1042 |
segs[i].type = worki[0]; |
| 1043 |
segs[i].color = worki[1]; |
| 1044 |
} |
| 1045 |
|
| 1046 |
return segs; |
| 1047 |
} |
| 1048 |
|
| 1049 |
/* validates the indexes supplied to i_ppal |
| 1050 |
|
| 1051 |
i_ppal() doesn't do that for speed, but I'm not comfortable doing that |
| 1052 |
for calls from perl. |
| 1053 |
|
| 1054 |
*/ |
| 1055 |
static void |
| 1056 |
validate_i_ppal(i_img *im, i_palidx const *indexes, int count) { |
| 1057 |
int color_count = i_colorcount(im); |
| 1058 |
int i; |
| 1059 |
|
| 1060 |
if (color_count == -1) |
| 1061 |
croak("i_plin() called on direct color image"); |
| 1062 |
|
| 1063 |
for (i = 0; i < count; ++i) { |
| 1064 |
if (indexes[i] >= color_count) { |
| 1065 |
croak("i_plin() called with out of range color index %d (max %d)", |
| 1066 |
indexes[i], color_count-1); |
| 1067 |
} |
| 1068 |
} |
| 1069 |
} |
| 1070 |
|
| 1071 |
/* I don't think ICLF_* names belong at the C interface |
| 1072 |
this makes the XS code think we have them, to let us avoid |
| 1073 |
putting function bodies in the XS code |
| 1074 |
*/ |
| 1075 |
#define ICLF_new_internal(r, g, b, a) i_fcolor_new((r), (g), (b), (a)) |
| 1076 |
#define ICLF_DESTROY(cl) i_fcolor_destroy(cl) |
| 1077 |
|
| 1078 |
#ifdef IMAGER_LOG |
| 1079 |
#define i_log_enabled() 1 |
| 1080 |
#else |
| 1081 |
#define i_log_enabled() 0 |
| 1082 |
#endif |
| 1083 |
|
| 1084 |
#if i_int_hlines_testing() |
| 1085 |
|
| 1086 |
typedef i_int_hlines *Imager__Internal__Hlines; |
| 1087 |
|
| 1088 |
static i_int_hlines * |
| 1089 |
i_int_hlines_new(i_img_dim start_y, i_img_dim count_y, i_img_dim start_x, i_img_dim count_x) { |
| 1090 |
i_int_hlines *result = mymalloc(sizeof(i_int_hlines)); |
| 1091 |
i_int_init_hlines(result, start_y, count_y, start_x, count_x); |
| 1092 |
|
| 1093 |
return result; |
| 1094 |
} |
| 1095 |
|
| 1096 |
static i_int_hlines * |
| 1097 |
i_int_hlines_new_img(i_img *im) { |
| 1098 |
i_int_hlines *result = mymalloc(sizeof(i_int_hlines)); |
| 1099 |
i_int_init_hlines_img(result, im); |
| 1100 |
|
| 1101 |
return result; |
| 1102 |
} |
| 1103 |
|
| 1104 |
static void |
| 1105 |
i_int_hlines_DESTROY(i_int_hlines *hlines) { |
| 1106 |
i_int_hlines_destroy(hlines); |
| 1107 |
myfree(hlines); |
| 1108 |
} |
| 1109 |
|
| 1110 |
#define i_int_hlines_CLONE_SKIP(cls) 1 |
| 1111 |
|
| 1112 |
static int seg_compare(const void *vleft, const void *vright) { |
| 1113 |
const i_int_hline_seg *left = vleft; |
| 1114 |
const i_int_hline_seg *right = vright; |
| 1115 |
|
| 1116 |
return left->minx - right->minx; |
| 1117 |
} |
| 1118 |
|
| 1119 |
static SV * |
| 1120 |
i_int_hlines_dump(i_int_hlines *hlines) { |
| 1121 |
dTHX; |
| 1122 |
SV *dump = newSVpvf("start_y: %" i_DF " limit_y: %" i_DF " start_x: %" i_DF " limit_x: %" i_DF"\n", |
| 1123 |
i_DFc(hlines->start_y), i_DFc(hlines->limit_y), i_DFc(hlines->start_x), i_DFc(hlines->limit_x)); |
| 1124 |
i_img_dim y; |
| 1125 |
|
| 1126 |
for (y = hlines->start_y; y < hlines->limit_y; ++y) { |
| 1127 |
i_int_hline_entry *entry = hlines->entries[y-hlines->start_y]; |
| 1128 |
if (entry) { |
| 1129 |
int i; |
| 1130 |
/* sort the segments, if any */ |
| 1131 |
if (entry->count) |
| 1132 |
qsort(entry->segs, entry->count, sizeof(i_int_hline_seg), seg_compare); |
| 1133 |
|
| 1134 |
sv_catpvf(dump, " %" i_DF " (%" i_DF "):", i_DFc(y), i_DFc(entry->count)); |
| 1135 |
for (i = 0; i < entry->count; ++i) { |
| 1136 |
sv_catpvf(dump, " [%" i_DF ", %" i_DF ")", i_DFc(entry->segs[i].minx), |
| 1137 |
i_DFc(entry->segs[i].x_limit)); |
| 1138 |
} |
| 1139 |
sv_catpv(dump, "\n"); |
| 1140 |
} |
| 1141 |
} |
| 1142 |
|
| 1143 |
return dump; |
| 1144 |
} |
| 1145 |
|
| 1146 |
#endif |
| 1147 |
|
| 1148 |
static off_t |
| 1149 |
i_sv_off_t(pTHX_ SV *sv) { |
| 1150 |
#if LSEEKSIZE > IVSIZE |
| 1151 |
return (off_t)SvNV(sv); |
| 1152 |
#else |
| 1153 |
return (off_t)SvIV(sv); |
| 1154 |
#endif |
| 1155 |
} |
| 1156 |
|
| 1157 |
static SV * |
| 1158 |
i_new_sv_off_t(pTHX_ off_t off) { |
| 1159 |
#if LSEEKSIZE > IVSIZE |
| 1160 |
return newSVnv(off); |
| 1161 |
#else |
| 1162 |
return newSViv(off); |
| 1163 |
#endif |
| 1164 |
} |
| 1165 |
|
| 1166 |
static im_pl_ext_funcs im_perl_funcs = |
| 1167 |
{ |
| 1168 |
IMAGER_PL_API_VERSION, |
| 1169 |
IMAGER_PL_API_LEVEL, |
| 1170 |
ip_handle_quant_opts, |
| 1171 |
ip_cleanup_quant_opts, |
| 1172 |
ip_copy_colors_back, |
| 1173 |
ip_handle_quant_opts2 |
| 1174 |
}; |
| 1175 |
|
| 1176 |
#define trim_color_list__new() S_trim_color_list__new(aTHX) |
| 1177 |
static i_trim_color_list |
| 1178 |
S_trim_color_list__new(pTHX) { |
| 1179 |
i_trim_color_list r; |
| 1180 |
|
| 1181 |
r.count = 0; |
| 1182 |
r.rsv = newSV(0); |
| 1183 |
sv_setref_pvn(r.rsv, "Imager::TrimColorList", "", 0); |
| 1184 |
r.sv = SvRV(r.rsv); |
| 1185 |
r.colors = (i_trim_colors_t *)SvPVX(r.sv); |
| 1186 |
|
| 1187 |
return r; |
| 1188 |
} |
| 1189 |
|
| 1190 |
static int |
| 1191 |
trim_color_list_grow(pTHX_ i_trim_color_list *t) { |
| 1192 |
STRLEN old_cur = SvCUR(t->sv); |
| 1193 |
char *p; |
| 1194 |
SvGROW(t->sv, SvCUR(t->sv)+sizeof(i_trim_colors_t)+1); |
| 1195 |
p = SvPVX(t->sv); |
| 1196 |
memset(p+old_cur, 0, sizeof(i_trim_colors_t)); |
| 1197 |
t->colors = (i_trim_colors_t *)p; |
| 1198 |
|
| 1199 |
return 1; |
| 1200 |
} |
| 1201 |
|
| 1202 |
#define trim_color_list_add_color(t, c1, c2) S_trim_color_list_add_color(aTHX_ (t), (c1), (c2)) |
| 1203 |
static int |
| 1204 |
S_trim_color_list_add_color(pTHX_ i_trim_color_list t, const i_color *c1, const i_color *c2) { |
| 1205 |
i_trim_colors_t *e; |
| 1206 |
if (!trim_color_list_grow(aTHX_ &t)) |
| 1207 |
return 0; |
| 1208 |
|
| 1209 |
e = t.colors + t.count; |
| 1210 |
|
| 1211 |
e->is_float = 0; |
| 1212 |
e->c1 = *c1; |
| 1213 |
e->c2 = *c2; |
| 1214 |
|
| 1215 |
++t.count; |
| 1216 |
SvCUR_set(t.sv, t.count * sizeof(i_trim_colors_t)); |
| 1217 |
*SvEND(t.sv) = '\0'; |
| 1218 |
|
| 1219 |
return 1; |
| 1220 |
} |
| 1221 |
|
| 1222 |
#define trim_color_list_add_fcolor(t, c1, c2) S_trim_color_list_add_fcolor(aTHX_ (t), (c1), (c2)) |
| 1223 |
static int |
| 1224 |
S_trim_color_list_add_fcolor(pTHX_ i_trim_color_list t, const i_fcolor *c1, const i_fcolor *c2) { |
| 1225 |
i_trim_colors_t *e; |
| 1226 |
if (!trim_color_list_grow(aTHX_ &t)) |
| 1227 |
return 0; |
| 1228 |
|
| 1229 |
e = t.colors + t.count; |
| 1230 |
|
| 1231 |
e->is_float = 1; |
| 1232 |
e->cf1 = *c1; |
| 1233 |
e->cf2 = *c2; |
| 1234 |
|
| 1235 |
++t.count; |
| 1236 |
SvCUR_set(t.sv, t.count * sizeof(i_trim_colors_t)); |
| 1237 |
*SvEND(t.sv) = '\0'; |
| 1238 |
|
| 1239 |
return 1; |
| 1240 |
} |
| 1241 |
|
| 1242 |
#define trim_color_list_get(t, i) S_trim_color_list_get(aTHX_ (t), (i)) |
| 1243 |
static SV * |
| 1244 |
S_trim_color_list_get(pTHX_ i_trim_color_list t, IV i) { |
| 1245 |
SV *r; |
| 1246 |
AV *av; |
| 1247 |
const i_trim_colors_t *e; |
| 1248 |
|
| 1249 |
if (i < 0 || (size_t)i >= t.count) { |
| 1250 |
return &PL_sv_undef; |
| 1251 |
} |
| 1252 |
|
| 1253 |
av = newAV(); |
| 1254 |
r = newRV_noinc((SV*)av); |
| 1255 |
e = t.colors+i; |
| 1256 |
|
| 1257 |
if (e->is_float) { |
| 1258 |
av_push(av, make_i_fcolor_sv(aTHX_ &e->cf1)); |
| 1259 |
av_push(av, make_i_fcolor_sv(aTHX_ &e->cf2)); |
| 1260 |
} |
| 1261 |
else { |
| 1262 |
av_push(av, make_i_color_sv(aTHX_ &e->c1)); |
| 1263 |
av_push(av, make_i_color_sv(aTHX_ &e->c2)); |
| 1264 |
} |
| 1265 |
|
| 1266 |
return r; |
| 1267 |
} |
| 1268 |
|
| 1269 |
/* given a ref to an Imager::TrimColorList fill in an i_trim_color_list structure */ |
| 1270 |
static bool |
| 1271 |
S_get_trim_color_list(pTHX_ SV *sv, i_trim_color_list *t) { |
| 1272 |
STRLEN len; |
| 1273 |
t->rsv = sv; |
| 1274 |
SvGETMAGIC(sv); |
| 1275 |
if (!SvROK(sv)) |
| 1276 |
return FALSE; |
| 1277 |
t->sv = SvRV(sv); |
| 1278 |
if (!SvPOK(t->sv) || SvMAGIC(t->sv)) |
| 1279 |
return FALSE; |
| 1280 |
len = SvCUR(t->sv); |
| 1281 |
if (len % sizeof(i_trim_colors_t) != 0) |
| 1282 |
return FALSE; |
| 1283 |
t->colors = (i_trim_colors_t *)SvPVX(t->sv); |
| 1284 |
t->count = len / sizeof(i_trim_colors_t); |
| 1285 |
|
| 1286 |
return TRUE; |
| 1287 |
} |
| 1288 |
|
| 1289 |
typedef i_trim_color_list Imager__TrimColorList; |
| 1290 |
#define trim_color_list_count(t) ((t).count) |
| 1291 |
|
| 1292 |
#define PERL_PL_SET_GLOBAL_CALLBACKS \ |
| 1293 |
sv_setiv(get_sv(PERL_PL_FUNCTION_TABLE_NAME, 1), PTR2IV(&im_perl_funcs)); |
| 1294 |
|
| 1295 |
#define IIM_new i_img_8_new |
| 1296 |
#define IIM_DESTROY i_img_destroy |
| 1297 |
typedef int SysRet; |
| 1298 |
|
| 1299 |
#ifdef IMEXIF_ENABLE |
| 1300 |
#define i_exif_enabled() 1 |
| 1301 |
#else |
| 1302 |
#define i_exif_enabled() 0 |
| 1303 |
#endif |
| 1304 |
|
| 1305 |
/* trying to use more C style names, map them here */ |
| 1306 |
#define i_io_DESTROY(ig) io_glue_destroy(ig) |
| 1307 |
|
| 1308 |
#define i_img_get_width(im) ((im)->xsize) |
| 1309 |
#define i_img_get_height(im) ((im)->ysize) |
| 1310 |
|
| 1311 |
#define i_img_epsilonf() (DBL_EPSILON * 4) |
| 1312 |
|
| 1313 |
/* avoid some xsubpp strangeness */ |
| 1314 |
#define NEWLINE '\n' |
| 1315 |
|
| 1316 |
#define ICL_red(c) ((c)->rgba.r) |
| 1317 |
#define ICL_green(c) ((c)->rgba.g) |
| 1318 |
#define ICL_blue(c) ((c)->rgba.b) |
| 1319 |
#define ICL_alpha(c) ((c)->rgba.a) |
| 1320 |
|
| 1321 |
#define ICLF_red(c) ((c)->rgba.r) |
| 1322 |
#define ICLF_green(c) ((c)->rgba.g) |
| 1323 |
#define ICLF_blue(c) ((c)->rgba.b) |
| 1324 |
#define ICLF_alpha(c) ((c)->rgba.a) |
| 1325 |
|
| 1326 |
MODULE = Imager PACKAGE = Imager::Color PREFIX = ICL_ |
| 1327 |
|
| 1328 |
Imager::Color |
| 1329 |
ICL_new_internal(r,g,b,a) |
| 1330 |
unsigned char r |
| 1331 |
unsigned char g |
| 1332 |
unsigned char b |
| 1333 |
unsigned char a |
| 1334 |
|
| 1335 |
void |
| 1336 |
ICL_DESTROY(cl) |
| 1337 |
Imager::Color cl |
| 1338 |
|
| 1339 |
|
| 1340 |
void |
| 1341 |
ICL_set_internal(cl,r,g,b,a) |
| 1342 |
Imager::Color cl |
| 1343 |
unsigned char r |
| 1344 |
unsigned char g |
| 1345 |
unsigned char b |
| 1346 |
unsigned char a |
| 1347 |
PPCODE: |
| 1348 |
cl->rgba.r = r; |
| 1349 |
cl->rgba.g = g; |
| 1350 |
cl->rgba.b = b; |
| 1351 |
cl->rgba.a = a; |
| 1352 |
EXTEND(SP, 1); |
| 1353 |
PUSHs(ST(0)); |
| 1354 |
|
| 1355 |
void |
| 1356 |
ICL_info(cl) |
| 1357 |
Imager::Color cl |
| 1358 |
|
| 1359 |
|
| 1360 |
void |
| 1361 |
ICL_rgba(cl) |
| 1362 |
Imager::Color cl |
| 1363 |
PPCODE: |
| 1364 |
EXTEND(SP, 4); |
| 1365 |
PUSHs(sv_2mortal(newSViv(cl->rgba.r))); |
| 1366 |
PUSHs(sv_2mortal(newSViv(cl->rgba.g))); |
| 1367 |
PUSHs(sv_2mortal(newSViv(cl->rgba.b))); |
| 1368 |
PUSHs(sv_2mortal(newSViv(cl->rgba.a))); |
| 1369 |
|
| 1370 |
Imager::Color |
| 1371 |
i_hsv_to_rgb(c) |
| 1372 |
Imager::Color c |
| 1373 |
CODE: |
| 1374 |
RETVAL = mymalloc(sizeof(i_color)); |
| 1375 |
*RETVAL = *c; |
| 1376 |
i_hsv_to_rgb(RETVAL); |
| 1377 |
OUTPUT: |
| 1378 |
RETVAL |
| 1379 |
|
| 1380 |
Imager::Color |
| 1381 |
i_rgb_to_hsv(c) |
| 1382 |
Imager::Color c |
| 1383 |
CODE: |
| 1384 |
RETVAL = mymalloc(sizeof(i_color)); |
| 1385 |
*RETVAL = *c; |
| 1386 |
i_rgb_to_hsv(RETVAL); |
| 1387 |
OUTPUT: |
| 1388 |
RETVAL |
| 1389 |
|
| 1390 |
int |
| 1391 |
ICL_red(c) |
| 1392 |
Imager::Color c |
| 1393 |
|
| 1394 |
int |
| 1395 |
ICL_green(c) |
| 1396 |
Imager::Color c |
| 1397 |
|
| 1398 |
int |
| 1399 |
ICL_blue(c) |
| 1400 |
Imager::Color c |
| 1401 |
|
| 1402 |
int |
| 1403 |
ICL_alpha(c) |
| 1404 |
Imager::Color c |
| 1405 |
|
| 1406 |
MODULE = Imager PACKAGE = Imager::Color::Float PREFIX=ICLF_ |
| 1407 |
|
| 1408 |
Imager::Color::Float |
| 1409 |
ICLF_new_internal(r, g, b, a) |
| 1410 |
im_double r |
| 1411 |
im_double g |
| 1412 |
im_double b |
| 1413 |
im_double a |
| 1414 |
|
| 1415 |
void |
| 1416 |
ICLF_DESTROY(cl) |
| 1417 |
Imager::Color::Float cl |
| 1418 |
|
| 1419 |
void |
| 1420 |
ICLF_rgba(cl) |
| 1421 |
Imager::Color::Float cl |
| 1422 |
PREINIT: |
| 1423 |
int ch; |
| 1424 |
PPCODE: |
| 1425 |
EXTEND(SP, MAXCHANNELS); |
| 1426 |
for (ch = 0; ch < MAXCHANNELS; ++ch) { |
| 1427 |
/* printf("%d: %g\n", ch, cl->channel[ch]); */ |
| 1428 |
PUSHs(sv_2mortal(newSVnv(cl->channel[ch]))); |
| 1429 |
} |
| 1430 |
|
| 1431 |
void |
| 1432 |
ICLF_set_internal(cl,r,g,b,a) |
| 1433 |
Imager::Color::Float cl |
| 1434 |
im_double r |
| 1435 |
im_double g |
| 1436 |
im_double b |
| 1437 |
im_double a |
| 1438 |
PPCODE: |
| 1439 |
cl->rgba.r = r; |
| 1440 |
cl->rgba.g = g; |
| 1441 |
cl->rgba.b = b; |
| 1442 |
cl->rgba.a = a; |
| 1443 |
EXTEND(SP, 1); |
| 1444 |
PUSHs(ST(0)); |
| 1445 |
|
| 1446 |
Imager::Color::Float |
| 1447 |
i_hsv_to_rgb(c) |
| 1448 |
Imager::Color::Float c |
| 1449 |
CODE: |
| 1450 |
RETVAL = mymalloc(sizeof(i_fcolor)); |
| 1451 |
*RETVAL = *c; |
| 1452 |
i_hsv_to_rgbf(RETVAL); |
| 1453 |
OUTPUT: |
| 1454 |
RETVAL |
| 1455 |
|
| 1456 |
Imager::Color::Float |
| 1457 |
i_rgb_to_hsv(c) |
| 1458 |
Imager::Color::Float c |
| 1459 |
CODE: |
| 1460 |
RETVAL = mymalloc(sizeof(i_fcolor)); |
| 1461 |
*RETVAL = *c; |
| 1462 |
i_rgb_to_hsvf(RETVAL); |
| 1463 |
OUTPUT: |
| 1464 |
RETVAL |
| 1465 |
|
| 1466 |
double |
| 1467 |
ICLF_red(c) |
| 1468 |
Imager::Color::Float c |
| 1469 |
|
| 1470 |
double |
| 1471 |
ICLF_green(c) |
| 1472 |
Imager::Color::Float c |
| 1473 |
|
| 1474 |
double |
| 1475 |
ICLF_blue(c) |
| 1476 |
Imager::Color::Float c |
| 1477 |
|
| 1478 |
double |
| 1479 |
ICLF_alpha(c) |
| 1480 |
Imager::Color::Float c |
| 1481 |
|
| 1482 |
MODULE = Imager PACKAGE = Imager::ImgRaw PREFIX = IIM_ |
| 1483 |
|
| 1484 |
Imager::ImgRaw |
| 1485 |
IIM_new(xsize,ysize,ch) |
| 1486 |
i_img_dim xsize |
| 1487 |
i_img_dim ysize |
| 1488 |
int ch |
| 1489 |
|
| 1490 |
void |
| 1491 |
IIM_DESTROY(im) |
| 1492 |
Imager::ImgRaw im |
| 1493 |
|
| 1494 |
|
| 1495 |
|
| 1496 |
MODULE = Imager PACKAGE = Imager |
| 1497 |
|
| 1498 |
PROTOTYPES: ENABLE |
| 1499 |
|
| 1500 |
|
| 1501 |
Imager::IO |
| 1502 |
io_new_fd(fd) |
| 1503 |
int fd |
| 1504 |
|
| 1505 |
Imager::IO |
| 1506 |
io_new_bufchain() |
| 1507 |
|
| 1508 |
|
| 1509 |
Imager::IO |
| 1510 |
io_new_buffer(data_sv) |
| 1511 |
SV *data_sv |
| 1512 |
CODE: |
| 1513 |
i_clear_error(); |
| 1514 |
RETVAL = do_io_new_buffer(aTHX_ data_sv); |
| 1515 |
if (!RETVAL) |
| 1516 |
XSRETURN(0); |
| 1517 |
OUTPUT: |
| 1518 |
RETVAL |
| 1519 |
|
| 1520 |
Imager::IO |
| 1521 |
io_new_cb(writecb, readcb, seekcb, closecb, maxwrite = CBDATA_BUFSIZE) |
| 1522 |
SV *writecb; |
| 1523 |
SV *readcb; |
| 1524 |
SV *seekcb; |
| 1525 |
SV *closecb; |
| 1526 |
CODE: |
| 1527 |
RETVAL = do_io_new_cb(aTHX_ writecb, readcb, seekcb, closecb); |
| 1528 |
OUTPUT: |
| 1529 |
RETVAL |
| 1530 |
|
| 1531 |
SV * |
| 1532 |
io_slurp(ig) |
| 1533 |
Imager::IO ig |
| 1534 |
PREINIT: |
| 1535 |
unsigned char* data; |
| 1536 |
size_t tlength; |
| 1537 |
CODE: |
| 1538 |
data = NULL; |
| 1539 |
tlength = io_slurp(ig, &data); |
| 1540 |
RETVAL = newSVpv((char *)data,tlength); |
| 1541 |
myfree(data); |
| 1542 |
OUTPUT: |
| 1543 |
RETVAL |
| 1544 |
|
| 1545 |
|
| 1546 |
undef_int |
| 1547 |
i_set_image_file_limits(width, height, bytes) |
| 1548 |
i_img_dim width |
| 1549 |
i_img_dim height |
| 1550 |
size_t bytes |
| 1551 |
|
| 1552 |
void |
| 1553 |
i_get_image_file_limits() |
| 1554 |
PREINIT: |
| 1555 |
i_img_dim width, height; |
| 1556 |
size_t bytes; |
| 1557 |
PPCODE: |
| 1558 |
if (i_get_image_file_limits(&width, &height, &bytes)) { |
| 1559 |
EXTEND(SP, 3); |
| 1560 |
PUSHs(sv_2mortal(newSViv(width))); |
| 1561 |
PUSHs(sv_2mortal(newSViv(height))); |
| 1562 |
PUSHs(sv_2mortal(newSVuv(bytes))); |
| 1563 |
} |
| 1564 |
|
| 1565 |
bool |
| 1566 |
i_int_check_image_file_limits(width, height, channels, sample_size) |
| 1567 |
i_img_dim width |
| 1568 |
i_img_dim height |
| 1569 |
int channels |
| 1570 |
size_t sample_size |
| 1571 |
PROTOTYPE: DISABLE |
| 1572 |
|
| 1573 |
void |
| 1574 |
i_trim_rect(Imager::ImgRaw im, double transp_threshold, Imager::TrimColorList cls) |
| 1575 |
PREINIT: |
| 1576 |
i_img_dim left, top, right, bottom; |
| 1577 |
PPCODE: |
| 1578 |
if (!i_trim_rect(im, transp_threshold, cls.count, cls.colors, &left, &top, &right, &bottom)) |
| 1579 |
XSRETURN(0); |
| 1580 |
EXTEND(SP, 4); |
| 1581 |
PUSHs(newSViv(left)); |
| 1582 |
PUSHs(newSViv(top)); |
| 1583 |
PUSHs(newSViv(right)); |
| 1584 |
PUSHs(newSViv(bottom)); |
| 1585 |
|
| 1586 |
MODULE = Imager PACKAGE = Imager::IO PREFIX = io_ |
| 1587 |
|
| 1588 |
Imager::IO |
| 1589 |
io_new_fd(class, fd) |
| 1590 |
int fd |
| 1591 |
CODE: |
| 1592 |
RETVAL = io_new_fd(fd); |
| 1593 |
OUTPUT: |
| 1594 |
RETVAL |
| 1595 |
|
| 1596 |
Imager::IO |
| 1597 |
io_new_buffer(class, data_sv) |
| 1598 |
SV *data_sv |
| 1599 |
CODE: |
| 1600 |
i_clear_error(); |
| 1601 |
RETVAL = do_io_new_buffer(aTHX_ data_sv); |
| 1602 |
if (!RETVAL) |
| 1603 |
XSRETURN(0); |
| 1604 |
OUTPUT: |
| 1605 |
RETVAL |
| 1606 |
|
| 1607 |
Imager::IO |
| 1608 |
io_new_cb(class, writecb, readcb, seekcb, closecb) |
| 1609 |
SV *writecb; |
| 1610 |
SV *readcb; |
| 1611 |
SV *seekcb; |
| 1612 |
SV *closecb; |
| 1613 |
CODE: |
| 1614 |
RETVAL = do_io_new_cb(aTHX_ writecb, readcb, seekcb, closecb); |
| 1615 |
OUTPUT: |
| 1616 |
RETVAL |
| 1617 |
|
| 1618 |
Imager::IO |
| 1619 |
io_new_bufchain(class) |
| 1620 |
CODE: |
| 1621 |
RETVAL = io_new_bufchain(); |
| 1622 |
OUTPUT: |
| 1623 |
RETVAL |
| 1624 |
|
| 1625 |
Imager::IO |
| 1626 |
io__new_perlio(class, io) |
| 1627 |
PerlIO *io |
| 1628 |
CODE: |
| 1629 |
RETVAL = im_io_new_perlio(aTHX_ io); |
| 1630 |
OUTPUT: |
| 1631 |
RETVAL |
| 1632 |
|
| 1633 |
SV * |
| 1634 |
io_slurp(class, ig) |
| 1635 |
Imager::IO ig |
| 1636 |
PREINIT: |
| 1637 |
unsigned char* data; |
| 1638 |
size_t tlength; |
| 1639 |
CODE: |
| 1640 |
data = NULL; |
| 1641 |
tlength = io_slurp(ig, &data); |
| 1642 |
RETVAL = newSVpv((char *)data,tlength); |
| 1643 |
myfree(data); |
| 1644 |
OUTPUT: |
| 1645 |
RETVAL |
| 1646 |
|
| 1647 |
MODULE = Imager PACKAGE = Imager::IO PREFIX = i_io_ |
| 1648 |
|
| 1649 |
IV |
| 1650 |
i_io_raw_write(ig, data_sv) |
| 1651 |
Imager::IO ig |
| 1652 |
SV *data_sv |
| 1653 |
PREINIT: |
| 1654 |
void *data; |
| 1655 |
STRLEN size; |
| 1656 |
CODE: |
| 1657 |
data = SvPVbyte(data_sv, size); |
| 1658 |
RETVAL = i_io_raw_write(ig, data, size); |
| 1659 |
OUTPUT: |
| 1660 |
RETVAL |
| 1661 |
|
| 1662 |
void |
| 1663 |
i_io_raw_read(ig, buffer_sv, size) |
| 1664 |
Imager::IO ig |
| 1665 |
SV *buffer_sv |
| 1666 |
IV size |
| 1667 |
PREINIT: |
| 1668 |
void *buffer; |
| 1669 |
ssize_t result; |
| 1670 |
PPCODE: |
| 1671 |
if (size <= 0) |
| 1672 |
croak("size %" IVdf " non-positive in call to i_io_raw_read()", size); |
| 1673 |
if (size >= SSize_t_MAX) |
| 1674 |
croak("size %" IVdf " too large in call to i_io_raw_read()", size); |
| 1675 |
/* prevent an undefined value warning if they supplied an |
| 1676 |
undef buffer. |
| 1677 |
Orginally conditional on !SvOK(), but this will prevent the |
| 1678 |
downgrade from croaking */ |
| 1679 |
sv_setpvn(buffer_sv, "", 0); |
| 1680 |
#ifdef SvUTF8 |
| 1681 |
if (SvUTF8(buffer_sv)) |
| 1682 |
sv_utf8_downgrade(buffer_sv, FALSE); |
| 1683 |
#endif |
| 1684 |
buffer = SvGROW(buffer_sv, (STRLEN)size+1); |
| 1685 |
result = i_io_raw_read(ig, buffer, size); |
| 1686 |
if (result >= 0) { |
| 1687 |
SvCUR_set(buffer_sv, result); |
| 1688 |
*SvEND(buffer_sv) = '\0'; |
| 1689 |
SvPOK_only(buffer_sv); |
| 1690 |
EXTEND(SP, 1); |
| 1691 |
PUSHs(sv_2mortal(newSViv(result))); |
| 1692 |
} |
| 1693 |
ST(1) = buffer_sv; |
| 1694 |
SvSETMAGIC(ST(1)); |
| 1695 |
|
| 1696 |
void |
| 1697 |
i_io_raw_read2(ig, size) |
| 1698 |
Imager::IO ig |
| 1699 |
IV size |
| 1700 |
PREINIT: |
| 1701 |
SV *buffer_sv; |
| 1702 |
void *buffer; |
| 1703 |
ssize_t result; |
| 1704 |
PPCODE: |
| 1705 |
if (size <= 0) |
| 1706 |
croak("size %" IVdf " negative in call to i_io_read2()", size); |
| 1707 |
if (size >= SSize_t_MAX) |
| 1708 |
croak("size %" IVdf " too large in i_io_read2()", size); |
| 1709 |
buffer_sv = newSV(size+1); |
| 1710 |
buffer = SvGROW(buffer_sv, (STRLEN)size+1); |
| 1711 |
result = i_io_raw_read(ig, buffer, size); |
| 1712 |
if (result >= 0) { |
| 1713 |
SvCUR_set(buffer_sv, result); |
| 1714 |
*SvEND(buffer_sv) = '\0'; |
| 1715 |
SvPOK_only(buffer_sv); |
| 1716 |
EXTEND(SP, 1); |
| 1717 |
PUSHs(sv_2mortal(buffer_sv)); |
| 1718 |
} |
| 1719 |
else { |
| 1720 |
/* discard it */ |
| 1721 |
SvREFCNT_dec(buffer_sv); |
| 1722 |
} |
| 1723 |
|
| 1724 |
off_t |
| 1725 |
i_io_raw_seek(ig, position, whence) |
| 1726 |
Imager::IO ig |
| 1727 |
off_t position |
| 1728 |
int whence |
| 1729 |
|
| 1730 |
int |
| 1731 |
i_io_raw_close(ig) |
| 1732 |
Imager::IO ig |
| 1733 |
|
| 1734 |
void |
| 1735 |
i_io_DESTROY(ig) |
| 1736 |
Imager::IO ig |
| 1737 |
|
| 1738 |
int |
| 1739 |
i_io_CLONE_SKIP(...) |
| 1740 |
CODE: |
| 1741 |
(void)items; /* avoid unused warning for XS variable */ |
| 1742 |
RETVAL = 1; |
| 1743 |
OUTPUT: |
| 1744 |
RETVAL |
| 1745 |
|
| 1746 |
int |
| 1747 |
i_io_getc(ig) |
| 1748 |
Imager::IO ig |
| 1749 |
|
| 1750 |
void |
| 1751 |
i_io_nextc(ig) |
| 1752 |
Imager::IO ig |
| 1753 |
|
| 1754 |
int |
| 1755 |
i_io_putc(ig, c) |
| 1756 |
Imager::IO ig |
| 1757 |
int c |
| 1758 |
|
| 1759 |
int |
| 1760 |
i_io_close(ig) |
| 1761 |
Imager::IO ig |
| 1762 |
|
| 1763 |
int |
| 1764 |
i_io_flush(ig) |
| 1765 |
Imager::IO ig |
| 1766 |
|
| 1767 |
int |
| 1768 |
i_io_peekc(ig) |
| 1769 |
Imager::IO ig |
| 1770 |
|
| 1771 |
int |
| 1772 |
i_io_seek(ig, off, whence) |
| 1773 |
Imager::IO ig |
| 1774 |
off_t off |
| 1775 |
int whence |
| 1776 |
|
| 1777 |
void |
| 1778 |
i_io_peekn(ig, size) |
| 1779 |
Imager::IO ig |
| 1780 |
STRLEN size |
| 1781 |
PREINIT: |
| 1782 |
SV *buffer_sv; |
| 1783 |
void *buffer; |
| 1784 |
ssize_t result; |
| 1785 |
PPCODE: |
| 1786 |
buffer_sv = newSV(size+1); |
| 1787 |
buffer = SvGROW(buffer_sv, size+1); |
| 1788 |
result = i_io_peekn(ig, buffer, size); |
| 1789 |
if (result >= 0) { |
| 1790 |
SvCUR_set(buffer_sv, result); |
| 1791 |
*SvEND(buffer_sv) = '\0'; |
| 1792 |
SvPOK_only(buffer_sv); |
| 1793 |
EXTEND(SP, 1); |
| 1794 |
PUSHs(sv_2mortal(buffer_sv)); |
| 1795 |
} |
| 1796 |
else { |
| 1797 |
/* discard it */ |
| 1798 |
SvREFCNT_dec(buffer_sv); |
| 1799 |
} |
| 1800 |
|
| 1801 |
void |
| 1802 |
i_io_read(ig, buffer_sv, size) |
| 1803 |
Imager::IO ig |
| 1804 |
SV *buffer_sv |
| 1805 |
IV size |
| 1806 |
PREINIT: |
| 1807 |
void *buffer; |
| 1808 |
ssize_t result; |
| 1809 |
PPCODE: |
| 1810 |
if (size <= 0) |
| 1811 |
croak("size negative in call to i_io_read()"); |
| 1812 |
if (size >= SSize_t_MAX) |
| 1813 |
croak("size too large in call to i_io_read()"); |
| 1814 |
/* prevent an undefined value warning if they supplied an |
| 1815 |
undef buffer. |
| 1816 |
Orginally conditional on !SvOK(), but this will prevent the |
| 1817 |
downgrade from croaking */ |
| 1818 |
sv_setpvn(buffer_sv, "", 0); |
| 1819 |
#ifdef SvUTF8 |
| 1820 |
if (SvUTF8(buffer_sv)) |
| 1821 |
sv_utf8_downgrade(buffer_sv, FALSE); |
| 1822 |
#endif |
| 1823 |
buffer = SvGROW(buffer_sv, (STRLEN)size+1); |
| 1824 |
result = i_io_read(ig, buffer, size); |
| 1825 |
if (result >= 0) { |
| 1826 |
SvCUR_set(buffer_sv, result); |
| 1827 |
*SvEND(buffer_sv) = '\0'; |
| 1828 |
SvPOK_only(buffer_sv); |
| 1829 |
EXTEND(SP, 1); |
| 1830 |
PUSHs(sv_2mortal(newSViv(result))); |
| 1831 |
} |
| 1832 |
ST(1) = buffer_sv; |
| 1833 |
SvSETMAGIC(ST(1)); |
| 1834 |
|
| 1835 |
void |
| 1836 |
i_io_read2(ig, size) |
| 1837 |
Imager::IO ig |
| 1838 |
STRLEN size |
| 1839 |
PREINIT: |
| 1840 |
SV *buffer_sv; |
| 1841 |
void *buffer; |
| 1842 |
ssize_t result; |
| 1843 |
PPCODE: |
| 1844 |
if (size == 0) |
| 1845 |
croak("size zero in call to read2()"); |
| 1846 |
buffer_sv = newSV(size); |
| 1847 |
buffer = SvGROW(buffer_sv, size+1); |
| 1848 |
result = i_io_read(ig, buffer, size); |
| 1849 |
if (result > 0) { |
| 1850 |
SvCUR_set(buffer_sv, result); |
| 1851 |
*SvEND(buffer_sv) = '\0'; |
| 1852 |
SvPOK_only(buffer_sv); |
| 1853 |
EXTEND(SP, 1); |
| 1854 |
PUSHs(sv_2mortal(buffer_sv)); |
| 1855 |
} |
| 1856 |
else { |
| 1857 |
/* discard it */ |
| 1858 |
SvREFCNT_dec(buffer_sv); |
| 1859 |
} |
| 1860 |
|
| 1861 |
void |
| 1862 |
i_io_gets(ig, size = 8192, eol = NEWLINE) |
| 1863 |
Imager::IO ig |
| 1864 |
STRLEN size |
| 1865 |
int eol |
| 1866 |
PREINIT: |
| 1867 |
SV *buffer_sv; |
| 1868 |
void *buffer; |
| 1869 |
ssize_t result; |
| 1870 |
PPCODE: |
| 1871 |
if (size < 2) |
| 1872 |
croak("size too small in call to gets()"); |
| 1873 |
buffer_sv = sv_2mortal(newSV(size+1)); |
| 1874 |
buffer = SvPVX(buffer_sv); |
| 1875 |
result = i_io_gets(ig, buffer, size+1, eol); |
| 1876 |
if (result > 0) { |
| 1877 |
SvCUR_set(buffer_sv, result); |
| 1878 |
*SvEND(buffer_sv) = '\0'; |
| 1879 |
SvPOK_only(buffer_sv); |
| 1880 |
EXTEND(SP, 1); |
| 1881 |
PUSHs(buffer_sv); |
| 1882 |
} |
| 1883 |
|
| 1884 |
IV |
| 1885 |
i_io_write(ig, data_sv) |
| 1886 |
Imager::IO ig |
| 1887 |
SV *data_sv |
| 1888 |
PREINIT: |
| 1889 |
void *data; |
| 1890 |
STRLEN size; |
| 1891 |
CODE: |
| 1892 |
data = SvPVbyte(data_sv, size); |
| 1893 |
RETVAL = i_io_write(ig, data, size); |
| 1894 |
OUTPUT: |
| 1895 |
RETVAL |
| 1896 |
|
| 1897 |
void |
| 1898 |
i_io_dump(ig, flags = I_IO_DUMP_DEFAULT) |
| 1899 |
Imager::IO ig |
| 1900 |
int flags |
| 1901 |
|
| 1902 |
bool |
| 1903 |
i_io_set_buffered(ig, flag = 1) |
| 1904 |
Imager::IO ig |
| 1905 |
int flag |
| 1906 |
|
| 1907 |
bool |
| 1908 |
i_io_is_buffered(ig) |
| 1909 |
Imager::IO ig |
| 1910 |
|
| 1911 |
bool |
| 1912 |
i_io_eof(ig) |
| 1913 |
Imager::IO ig |
| 1914 |
|
| 1915 |
bool |
| 1916 |
i_io_error(ig) |
| 1917 |
Imager::IO ig |
| 1918 |
|
| 1919 |
MODULE = Imager PACKAGE = Imager |
| 1920 |
|
| 1921 |
PROTOTYPES: ENABLE |
| 1922 |
|
| 1923 |
void |
| 1924 |
i_list_formats() |
| 1925 |
PREINIT: |
| 1926 |
char* item; |
| 1927 |
int i; |
| 1928 |
PPCODE: |
| 1929 |
i=0; |
| 1930 |
while( (item=i_format_list[i++]) != NULL ) { |
| 1931 |
EXTEND(SP, 1); |
| 1932 |
PUSHs(sv_2mortal(newSVpv(item,0))); |
| 1933 |
} |
| 1934 |
|
| 1935 |
Imager::ImgRaw |
| 1936 |
i_sametype(im, x, y) |
| 1937 |
Imager::ImgRaw im |
| 1938 |
i_img_dim x |
| 1939 |
i_img_dim y |
| 1940 |
|
| 1941 |
Imager::ImgRaw |
| 1942 |
i_sametype_chans(im, x, y, channels) |
| 1943 |
Imager::ImgRaw im |
| 1944 |
i_img_dim x |
| 1945 |
i_img_dim y |
| 1946 |
int channels |
| 1947 |
|
| 1948 |
int |
| 1949 |
i_init_log(name_sv,level) |
| 1950 |
SV* name_sv |
| 1951 |
int level |
| 1952 |
PREINIT: |
| 1953 |
const char *name = SvOK(name_sv) ? SvPV_nolen(name_sv) : NULL; |
| 1954 |
CODE: |
| 1955 |
RETVAL = i_init_log(name, level); |
| 1956 |
OUTPUT: |
| 1957 |
RETVAL |
| 1958 |
|
| 1959 |
void |
| 1960 |
i_log_entry(string,level) |
| 1961 |
char* string |
| 1962 |
int level |
| 1963 |
|
| 1964 |
int |
| 1965 |
i_log_enabled() |
| 1966 |
|
| 1967 |
void |
| 1968 |
i_img_info(im) |
| 1969 |
Imager::ImgRaw im |
| 1970 |
PREINIT: |
| 1971 |
i_img_dim info[4]; |
| 1972 |
PPCODE: |
| 1973 |
i_img_info(im,info); |
| 1974 |
EXTEND(SP, 4); |
| 1975 |
PUSHs(sv_2mortal(newSViv(info[0]))); |
| 1976 |
PUSHs(sv_2mortal(newSViv(info[1]))); |
| 1977 |
PUSHs(sv_2mortal(newSViv(info[2]))); |
| 1978 |
PUSHs(sv_2mortal(newSViv(info[3]))); |
| 1979 |
|
| 1980 |
|
| 1981 |
|
| 1982 |
|
| 1983 |
void |
| 1984 |
i_img_setmask(im,ch_mask) |
| 1985 |
Imager::ImgRaw im |
| 1986 |
int ch_mask |
| 1987 |
|
| 1988 |
int |
| 1989 |
i_img_getmask(im) |
| 1990 |
Imager::ImgRaw im |
| 1991 |
|
| 1992 |
int |
| 1993 |
i_img_getchannels(im) |
| 1994 |
Imager::ImgRaw im |
| 1995 |
|
| 1996 |
void |
| 1997 |
i_img_getdata(im) |
| 1998 |
Imager::ImgRaw im |
| 1999 |
PPCODE: |
| 2000 |
EXTEND(SP, 1); |
| 2001 |
PUSHs(im->idata ? |
| 2002 |
sv_2mortal(newSVpv((char *)im->idata, im->bytes)) |
| 2003 |
: &PL_sv_undef); |
| 2004 |
|
| 2005 |
IV |
| 2006 |
i_img_get_width(im) |
| 2007 |
Imager::ImgRaw im |
| 2008 |
|
| 2009 |
IV |
| 2010 |
i_img_get_height(im) |
| 2011 |
Imager::ImgRaw im |
| 2012 |
|
| 2013 |
int |
| 2014 |
i_img_color_model(im) |
| 2015 |
Imager::ImgRaw im |
| 2016 |
|
| 2017 |
int |
| 2018 |
i_img_color_channels(im) |
| 2019 |
Imager::ImgRaw im |
| 2020 |
|
| 2021 |
int |
| 2022 |
i_img_alpha_channel(im) |
| 2023 |
Imager::ImgRaw im |
| 2024 |
CODE: |
| 2025 |
if (!i_img_alpha_channel(im, &RETVAL)) |
| 2026 |
XSRETURN(0); |
| 2027 |
OUTPUT: |
| 2028 |
RETVAL |
| 2029 |
|
| 2030 |
void |
| 2031 |
i_img_is_monochrome(im) |
| 2032 |
Imager::ImgRaw im |
| 2033 |
PREINIT: |
| 2034 |
int zero_is_white; |
| 2035 |
int result; |
| 2036 |
PPCODE: |
| 2037 |
result = i_img_is_monochrome(im, &zero_is_white); |
| 2038 |
if (result) { |
| 2039 |
if (GIMME_V == G_ARRAY) { |
| 2040 |
EXTEND(SP, 2); |
| 2041 |
PUSHs(&PL_sv_yes); |
| 2042 |
PUSHs(sv_2mortal(newSViv(zero_is_white))); |
| 2043 |
} |
| 2044 |
else { |
| 2045 |
EXTEND(SP, 1); |
| 2046 |
PUSHs(&PL_sv_yes); |
| 2047 |
} |
| 2048 |
} |
| 2049 |
|
| 2050 |
void |
| 2051 |
i_line(im,x1,y1,x2,y2,val,endp) |
| 2052 |
Imager::ImgRaw im |
| 2053 |
i_img_dim x1 |
| 2054 |
i_img_dim y1 |
| 2055 |
i_img_dim x2 |
| 2056 |
i_img_dim y2 |
| 2057 |
Imager::Color val |
| 2058 |
int endp |
| 2059 |
|
| 2060 |
void |
| 2061 |
i_line_aa(im,x1,y1,x2,y2,val,endp) |
| 2062 |
Imager::ImgRaw im |
| 2063 |
i_img_dim x1 |
| 2064 |
i_img_dim y1 |
| 2065 |
i_img_dim x2 |
| 2066 |
i_img_dim y2 |
| 2067 |
Imager::Color val |
| 2068 |
int endp |
| 2069 |
|
| 2070 |
void |
| 2071 |
i_box(im,x1,y1,x2,y2,val) |
| 2072 |
Imager::ImgRaw im |
| 2073 |
i_img_dim x1 |
| 2074 |
i_img_dim y1 |
| 2075 |
i_img_dim x2 |
| 2076 |
i_img_dim y2 |
| 2077 |
Imager::Color val |
| 2078 |
|
| 2079 |
void |
| 2080 |
i_box_filled(im,x1,y1,x2,y2,val) |
| 2081 |
Imager::ImgRaw im |
| 2082 |
i_img_dim x1 |
| 2083 |
i_img_dim y1 |
| 2084 |
i_img_dim x2 |
| 2085 |
i_img_dim y2 |
| 2086 |
Imager::Color val |
| 2087 |
|
| 2088 |
int |
| 2089 |
i_box_filledf(im,x1,y1,x2,y2,val) |
| 2090 |
Imager::ImgRaw im |
| 2091 |
i_img_dim x1 |
| 2092 |
i_img_dim y1 |
| 2093 |
i_img_dim x2 |
| 2094 |
i_img_dim y2 |
| 2095 |
Imager::Color::Float val |
| 2096 |
|
| 2097 |
void |
| 2098 |
i_box_cfill(im,x1,y1,x2,y2,fill) |
| 2099 |
Imager::ImgRaw im |
| 2100 |
i_img_dim x1 |
| 2101 |
i_img_dim y1 |
| 2102 |
i_img_dim x2 |
| 2103 |
i_img_dim y2 |
| 2104 |
Imager::FillHandle fill |
| 2105 |
|
| 2106 |
void |
| 2107 |
i_arc(im,x,y,rad,d1,d2,val) |
| 2108 |
Imager::ImgRaw im |
| 2109 |
i_img_dim x |
| 2110 |
i_img_dim y |
| 2111 |
im_double rad |
| 2112 |
im_double d1 |
| 2113 |
im_double d2 |
| 2114 |
Imager::Color val |
| 2115 |
|
| 2116 |
void |
| 2117 |
i_arc_aa(im,x,y,rad,d1,d2,val) |
| 2118 |
Imager::ImgRaw im |
| 2119 |
im_double x |
| 2120 |
im_double y |
| 2121 |
im_double rad |
| 2122 |
im_double d1 |
| 2123 |
im_double d2 |
| 2124 |
Imager::Color val |
| 2125 |
|
| 2126 |
void |
| 2127 |
i_arc_cfill(im,x,y,rad,d1,d2,fill) |
| 2128 |
Imager::ImgRaw im |
| 2129 |
i_img_dim x |
| 2130 |
i_img_dim y |
| 2131 |
im_double rad |
| 2132 |
im_double d1 |
| 2133 |
im_double d2 |
| 2134 |
Imager::FillHandle fill |
| 2135 |
|
| 2136 |
void |
| 2137 |
i_arc_aa_cfill(im,x,y,rad,d1,d2,fill) |
| 2138 |
Imager::ImgRaw im |
| 2139 |
im_double x |
| 2140 |
im_double y |
| 2141 |
im_double rad |
| 2142 |
im_double d1 |
| 2143 |
im_double d2 |
| 2144 |
Imager::FillHandle fill |
| 2145 |
|
| 2146 |
|
| 2147 |
void |
| 2148 |
i_circle_aa(im,x,y,rad,val) |
| 2149 |
Imager::ImgRaw im |
| 2150 |
im_double x |
| 2151 |
im_double y |
| 2152 |
im_double rad |
| 2153 |
Imager::Color val |
| 2154 |
|
| 2155 |
void |
| 2156 |
i_circle_aa_fill(im,x,y,rad,fill) |
| 2157 |
Imager::ImgRaw im |
| 2158 |
im_double x |
| 2159 |
im_double y |
| 2160 |
im_double rad |
| 2161 |
Imager::FillHandle fill |
| 2162 |
|
| 2163 |
int |
| 2164 |
i_circle_out(im,x,y,rad,val) |
| 2165 |
Imager::ImgRaw im |
| 2166 |
i_img_dim x |
| 2167 |
i_img_dim y |
| 2168 |
i_img_dim rad |
| 2169 |
Imager::Color val |
| 2170 |
|
| 2171 |
int |
| 2172 |
i_circle_out_aa(im,x,y,rad,val) |
| 2173 |
Imager::ImgRaw im |
| 2174 |
i_img_dim x |
| 2175 |
i_img_dim y |
| 2176 |
i_img_dim rad |
| 2177 |
Imager::Color val |
| 2178 |
|
| 2179 |
int |
| 2180 |
i_arc_out(im,x,y,rad,d1,d2,val) |
| 2181 |
Imager::ImgRaw im |
| 2182 |
i_img_dim x |
| 2183 |
i_img_dim y |
| 2184 |
i_img_dim rad |
| 2185 |
im_double d1 |
| 2186 |
im_double d2 |
| 2187 |
Imager::Color val |
| 2188 |
|
| 2189 |
int |
| 2190 |
i_arc_out_aa(im,x,y,rad,d1,d2,val) |
| 2191 |
Imager::ImgRaw im |
| 2192 |
i_img_dim x |
| 2193 |
i_img_dim y |
| 2194 |
i_img_dim rad |
| 2195 |
im_double d1 |
| 2196 |
im_double d2 |
| 2197 |
Imager::Color val |
| 2198 |
|
| 2199 |
|
| 2200 |
void |
| 2201 |
i_bezier_multi(im,x,y,val) |
| 2202 |
Imager::ImgRaw im |
| 2203 |
double *x |
| 2204 |
double *y |
| 2205 |
Imager::Color val |
| 2206 |
PREINIT: |
| 2207 |
STRLEN size_x; |
| 2208 |
STRLEN size_y; |
| 2209 |
PPCODE: |
| 2210 |
if (size_x != size_y) |
| 2211 |
croak("Imager: x and y arrays to i_bezier_multi must be equal length\n"); |
| 2212 |
i_bezier_multi(im,size_x,x,y,val); |
| 2213 |
|
| 2214 |
int |
| 2215 |
i_poly_aa_m(im,x,y,mode,val) |
| 2216 |
Imager::ImgRaw im |
| 2217 |
double *x |
| 2218 |
double *y |
| 2219 |
i_poly_fill_mode_t mode |
| 2220 |
Imager::Color val |
| 2221 |
PREINIT: |
| 2222 |
STRLEN size_x; |
| 2223 |
STRLEN size_y; |
| 2224 |
CODE: |
| 2225 |
if (size_x != size_y) |
| 2226 |
croak("Imager: x and y arrays to i_poly_aa must be equal length\n"); |
| 2227 |
RETVAL = i_poly_aa_m(im, size_x, x, y, mode, val); |
| 2228 |
OUTPUT: |
| 2229 |
RETVAL |
| 2230 |
|
| 2231 |
int |
| 2232 |
i_poly_aa_cfill_m(im, x, y, mode, fill) |
| 2233 |
Imager::ImgRaw im |
| 2234 |
double *x |
| 2235 |
double *y |
| 2236 |
i_poly_fill_mode_t mode |
| 2237 |
Imager::FillHandle fill |
| 2238 |
PREINIT: |
| 2239 |
STRLEN size_x; |
| 2240 |
STRLEN size_y; |
| 2241 |
CODE: |
| 2242 |
if (size_x != size_y) |
| 2243 |
croak("Imager: x and y arrays to i_poly_aa_cfill must be equal length\n"); |
| 2244 |
RETVAL = i_poly_aa_cfill_m(im, size_x, x, y, mode, fill); |
| 2245 |
OUTPUT: |
| 2246 |
RETVAL |
| 2247 |
|
| 2248 |
int |
| 2249 |
i_poly_poly_aa(im, polys, mode, color) |
| 2250 |
Imager::ImgRaw im |
| 2251 |
i_polygon_list polys |
| 2252 |
i_poly_fill_mode_t mode |
| 2253 |
Imager::Color color |
| 2254 |
CODE: |
| 2255 |
RETVAL = i_poly_poly_aa(im, polys.count, polys.polygons, mode, color); |
| 2256 |
OUTPUT: |
| 2257 |
RETVAL |
| 2258 |
|
| 2259 |
int |
| 2260 |
i_poly_poly_aa_cfill(im, polys, mode, fill) |
| 2261 |
Imager::ImgRaw im |
| 2262 |
i_polygon_list polys |
| 2263 |
i_poly_fill_mode_t mode |
| 2264 |
Imager::FillHandle fill |
| 2265 |
CODE: |
| 2266 |
RETVAL = i_poly_poly_aa_cfill(im, polys.count, polys.polygons, mode, fill); |
| 2267 |
OUTPUT: |
| 2268 |
RETVAL |
| 2269 |
|
| 2270 |
undef_int |
| 2271 |
i_flood_fill(im,seedx,seedy,dcol) |
| 2272 |
Imager::ImgRaw im |
| 2273 |
i_img_dim seedx |
| 2274 |
i_img_dim seedy |
| 2275 |
Imager::Color dcol |
| 2276 |
|
| 2277 |
undef_int |
| 2278 |
i_flood_cfill(im,seedx,seedy,fill) |
| 2279 |
Imager::ImgRaw im |
| 2280 |
i_img_dim seedx |
| 2281 |
i_img_dim seedy |
| 2282 |
Imager::FillHandle fill |
| 2283 |
|
| 2284 |
undef_int |
| 2285 |
i_flood_fill_border(im,seedx,seedy,dcol, border) |
| 2286 |
Imager::ImgRaw im |
| 2287 |
i_img_dim seedx |
| 2288 |
i_img_dim seedy |
| 2289 |
Imager::Color dcol |
| 2290 |
Imager::Color border |
| 2291 |
|
| 2292 |
undef_int |
| 2293 |
i_flood_cfill_border(im,seedx,seedy,fill, border) |
| 2294 |
Imager::ImgRaw im |
| 2295 |
i_img_dim seedx |
| 2296 |
i_img_dim seedy |
| 2297 |
Imager::FillHandle fill |
| 2298 |
Imager::Color border |
| 2299 |
|
| 2300 |
|
| 2301 |
void |
| 2302 |
i_copyto(im,src,x1,y1,x2,y2,tx,ty) |
| 2303 |
Imager::ImgRaw im |
| 2304 |
Imager::ImgRaw src |
| 2305 |
i_img_dim x1 |
| 2306 |
i_img_dim y1 |
| 2307 |
i_img_dim x2 |
| 2308 |
i_img_dim y2 |
| 2309 |
i_img_dim tx |
| 2310 |
i_img_dim ty |
| 2311 |
|
| 2312 |
|
| 2313 |
void |
| 2314 |
i_copyto_trans(im,src,x1,y1,x2,y2,tx,ty,trans) |
| 2315 |
Imager::ImgRaw im |
| 2316 |
Imager::ImgRaw src |
| 2317 |
i_img_dim x1 |
| 2318 |
i_img_dim y1 |
| 2319 |
i_img_dim x2 |
| 2320 |
i_img_dim y2 |
| 2321 |
i_img_dim tx |
| 2322 |
i_img_dim ty |
| 2323 |
Imager::Color trans |
| 2324 |
|
| 2325 |
Imager::ImgRaw |
| 2326 |
i_copy(src) |
| 2327 |
Imager::ImgRaw src |
| 2328 |
|
| 2329 |
|
| 2330 |
undef_int |
| 2331 |
i_rubthru(im,src,tx,ty,src_minx,src_miny,src_maxx,src_maxy) |
| 2332 |
Imager::ImgRaw im |
| 2333 |
Imager::ImgRaw src |
| 2334 |
i_img_dim tx |
| 2335 |
i_img_dim ty |
| 2336 |
i_img_dim src_minx |
| 2337 |
i_img_dim src_miny |
| 2338 |
i_img_dim src_maxx |
| 2339 |
i_img_dim src_maxy |
| 2340 |
|
| 2341 |
undef_int |
| 2342 |
i_compose(out, src, out_left, out_top, src_left, src_top, width, height, combine = ic_normal, opacity = 0.0) |
| 2343 |
Imager::ImgRaw out |
| 2344 |
Imager::ImgRaw src |
| 2345 |
i_img_dim out_left |
| 2346 |
i_img_dim out_top |
| 2347 |
i_img_dim src_left |
| 2348 |
i_img_dim src_top |
| 2349 |
i_img_dim width |
| 2350 |
i_img_dim height |
| 2351 |
int combine |
| 2352 |
im_double opacity |
| 2353 |
|
| 2354 |
undef_int |
| 2355 |
i_compose_mask(out, src, mask, out_left, out_top, src_left, src_top, mask_left, mask_top, width, height, combine = ic_normal, opacity = 0.0) |
| 2356 |
Imager::ImgRaw out |
| 2357 |
Imager::ImgRaw src |
| 2358 |
Imager::ImgRaw mask |
| 2359 |
i_img_dim out_left |
| 2360 |
i_img_dim out_top |
| 2361 |
i_img_dim src_left |
| 2362 |
i_img_dim src_top |
| 2363 |
i_img_dim mask_left |
| 2364 |
i_img_dim mask_top |
| 2365 |
i_img_dim width |
| 2366 |
i_img_dim height |
| 2367 |
int combine |
| 2368 |
im_double opacity |
| 2369 |
|
| 2370 |
Imager::ImgRaw |
| 2371 |
i_combine(src_av, channels_av = NULL) |
| 2372 |
AV *src_av |
| 2373 |
AV *channels_av |
| 2374 |
PREINIT: |
| 2375 |
i_img **imgs = NULL; |
| 2376 |
STRLEN in_count; |
| 2377 |
int *channels = NULL; |
| 2378 |
IV tmp; |
| 2379 |
CODE: |
| 2380 |
in_count = av_len(src_av) + 1; |
| 2381 |
if (in_count > 0) { |
| 2382 |
unsigned i; |
| 2383 |
imgs = mymalloc(sizeof(i_img*) * in_count); |
| 2384 |
channels = mymalloc(sizeof(int) * in_count); |
| 2385 |
for (i = 0; i < in_count; ++i) { |
| 2386 |
SV **psv = av_fetch(src_av, i, 0); |
| 2387 |
if (!psv || !*psv || !sv_derived_from(*psv, "Imager::ImgRaw")) { |
| 2388 |
myfree(imgs); |
| 2389 |
myfree(channels); |
| 2390 |
croak("imgs must contain only images"); |
| 2391 |
} |
| 2392 |
tmp = SvIV((SV*)SvRV(*psv)); |
| 2393 |
imgs[i] = INT2PTR(i_img*, tmp); |
| 2394 |
if (channels_av && |
| 2395 |
(psv = av_fetch(channels_av, i, 0)) != NULL && |
| 2396 |
*psv) { |
| 2397 |
channels[i] = SvIV(*psv); |
| 2398 |
} |
| 2399 |
else { |
| 2400 |
channels[i] = 0; |
| 2401 |
} |
| 2402 |
} |
| 2403 |
} |
| 2404 |
RETVAL = i_combine(imgs, channels, in_count); |
| 2405 |
myfree(imgs); |
| 2406 |
myfree(channels); |
| 2407 |
OUTPUT: |
| 2408 |
RETVAL |
| 2409 |
|
| 2410 |
undef_int |
| 2411 |
i_flipxy(im, direction) |
| 2412 |
Imager::ImgRaw im |
| 2413 |
int direction |
| 2414 |
|
| 2415 |
Imager::ImgRaw |
| 2416 |
i_rotate90(im, degrees) |
| 2417 |
Imager::ImgRaw im |
| 2418 |
int degrees |
| 2419 |
|
| 2420 |
Imager::ImgRaw |
| 2421 |
i_rotate_exact(im, amount, ...) |
| 2422 |
Imager::ImgRaw im |
| 2423 |
im_double amount |
| 2424 |
PREINIT: |
| 2425 |
i_color *backp = NULL; |
| 2426 |
i_fcolor *fbackp = NULL; |
| 2427 |
int i; |
| 2428 |
SV * sv1; |
| 2429 |
CODE: |
| 2430 |
/* extract the bg colors if any */ |
| 2431 |
/* yes, this is kind of strange */ |
| 2432 |
for (i = 2; i < items; ++i) { |
| 2433 |
sv1 = ST(i); |
| 2434 |
if (sv_derived_from(sv1, "Imager::Color")) { |
| 2435 |
IV tmp = SvIV((SV*)SvRV(sv1)); |
| 2436 |
backp = INT2PTR(i_color *, tmp); |
| 2437 |
} |
| 2438 |
else if (sv_derived_from(sv1, "Imager::Color::Float")) { |
| 2439 |
IV tmp = SvIV((SV*)SvRV(sv1)); |
| 2440 |
fbackp = INT2PTR(i_fcolor *, tmp); |
| 2441 |
} |
| 2442 |
} |
| 2443 |
RETVAL = i_rotate_exact_bg(im, amount, backp, fbackp); |
| 2444 |
OUTPUT: |
| 2445 |
RETVAL |
| 2446 |
|
| 2447 |
Imager::ImgRaw |
| 2448 |
i_matrix_transform(im, xsize, ysize, matrix_av, ...) |
| 2449 |
Imager::ImgRaw im |
| 2450 |
i_img_dim xsize |
| 2451 |
i_img_dim ysize |
| 2452 |
AV *matrix_av |
| 2453 |
PREINIT: |
| 2454 |
double matrix[9]; |
| 2455 |
STRLEN len; |
| 2456 |
SV *sv1; |
| 2457 |
int item_index; |
| 2458 |
unsigned coeff_index; |
| 2459 |
i_color *backp = NULL; |
| 2460 |
i_fcolor *fbackp = NULL; |
| 2461 |
CODE: |
| 2462 |
len=av_len(matrix_av)+1; |
| 2463 |
if (len > 9) |
| 2464 |
len = 9; |
| 2465 |
for (coeff_index = 0; coeff_index < len; ++coeff_index) { |
| 2466 |
sv1=(*(av_fetch(matrix_av, coeff_index, 0))); |
| 2467 |
matrix[coeff_index] = SvNV(sv1); |
| 2468 |
} |
| 2469 |
for (; coeff_index < 9; ++coeff_index) |
| 2470 |
matrix[coeff_index] = 0; |
| 2471 |
/* extract the bg colors if any */ |
| 2472 |
/* yes, this is kind of strange */ |
| 2473 |
for (item_index = 4; item_index < items; ++item_index) { |
| 2474 |
sv1 = ST(item_index); |
| 2475 |
if (sv_derived_from(sv1, "Imager::Color")) { |
| 2476 |
IV tmp = SvIV((SV*)SvRV(sv1)); |
| 2477 |
backp = INT2PTR(i_color *, tmp); |
| 2478 |
} |
| 2479 |
else if (sv_derived_from(sv1, "Imager::Color::Float")) { |
| 2480 |
IV tmp = SvIV((SV*)SvRV(sv1)); |
| 2481 |
fbackp = INT2PTR(i_fcolor *, tmp); |
| 2482 |
} |
| 2483 |
} |
| 2484 |
RETVAL = i_matrix_transform_bg(im, xsize, ysize, matrix, backp, fbackp); |
| 2485 |
OUTPUT: |
| 2486 |
RETVAL |
| 2487 |
|
| 2488 |
undef_int |
| 2489 |
i_gaussian(im,stddev) |
| 2490 |
Imager::ImgRaw im |
| 2491 |
im_double stddev |
| 2492 |
|
| 2493 |
undef_int |
| 2494 |
i_gaussian2(im,stddevX,stddevY) |
| 2495 |
Imager::ImgRaw im |
| 2496 |
im_double stddevX |
| 2497 |
im_double stddevY |
| 2498 |
|
| 2499 |
void |
| 2500 |
i_unsharp_mask(im,stdev,scale) |
| 2501 |
Imager::ImgRaw im |
| 2502 |
im_double stdev |
| 2503 |
im_double scale |
| 2504 |
|
| 2505 |
int |
| 2506 |
i_conv(im,coef) |
| 2507 |
Imager::ImgRaw im |
| 2508 |
AV *coef |
| 2509 |
PREINIT: |
| 2510 |
double* c_coef; |
| 2511 |
int len; |
| 2512 |
SV* sv1; |
| 2513 |
int i; |
| 2514 |
CODE: |
| 2515 |
len = av_len(coef) + 1; |
| 2516 |
c_coef=mymalloc( len * sizeof(double) ); |
| 2517 |
for(i = 0; i < len; i++) { |
| 2518 |
sv1 = (*(av_fetch(coef, i, 0))); |
| 2519 |
c_coef[i] = (double)SvNV(sv1); |
| 2520 |
} |
| 2521 |
RETVAL = i_conv(im, c_coef, len); |
| 2522 |
myfree(c_coef); |
| 2523 |
OUTPUT: |
| 2524 |
RETVAL |
| 2525 |
|
| 2526 |
Imager::ImgRaw |
| 2527 |
i_convert(src, avmain) |
| 2528 |
Imager::ImgRaw src |
| 2529 |
AV *avmain |
| 2530 |
PREINIT: |
| 2531 |
double *coeff; |
| 2532 |
int outchan; |
| 2533 |
int inchan; |
| 2534 |
SV **temp; |
| 2535 |
AV *avsub; |
| 2536 |
int len; |
| 2537 |
int i, j; |
| 2538 |
CODE: |
| 2539 |
outchan = av_len(avmain)+1; |
| 2540 |
/* find the biggest */ |
| 2541 |
inchan = 0; |
| 2542 |
for (j=0; j < outchan; ++j) { |
| 2543 |
temp = av_fetch(avmain, j, 0); |
| 2544 |
if (temp && SvROK(*temp) && SvTYPE(SvRV(*temp)) == SVt_PVAV) { |
| 2545 |
avsub = (AV*)SvRV(*temp); |
| 2546 |
len = av_len(avsub)+1; |
| 2547 |
if (len > inchan) |
| 2548 |
inchan = len; |
| 2549 |
} |
| 2550 |
else { |
| 2551 |
i_push_errorf(0, "invalid matrix: element %d is not an array ref", j); |
| 2552 |
XSRETURN(0); |
| 2553 |
} |
| 2554 |
} |
| 2555 |
coeff = mymalloc(sizeof(double) * outchan * inchan); |
| 2556 |
for (j = 0; j < outchan; ++j) { |
| 2557 |
avsub = (AV*)SvRV(*av_fetch(avmain, j, 0)); |
| 2558 |
len = av_len(avsub)+1; |
| 2559 |
for (i = 0; i < len; ++i) { |
| 2560 |
temp = av_fetch(avsub, i, 0); |
| 2561 |
if (temp) |
| 2562 |
coeff[i+j*inchan] = SvNV(*temp); |
| 2563 |
else |
| 2564 |
coeff[i+j*inchan] = 0; |
| 2565 |
} |
| 2566 |
while (i < inchan) |
| 2567 |
coeff[i++ + j*inchan] = 0; |
| 2568 |
} |
| 2569 |
RETVAL = i_convert(src, coeff, outchan, inchan); |
| 2570 |
myfree(coeff); |
| 2571 |
OUTPUT: |
| 2572 |
RETVAL |
| 2573 |
|
| 2574 |
|
| 2575 |
undef_int |
| 2576 |
i_map(im, pmaps_av) |
| 2577 |
Imager::ImgRaw im |
| 2578 |
AV *pmaps_av |
| 2579 |
PREINIT: |
| 2580 |
unsigned int mask = 0; |
| 2581 |
AV *avsub; |
| 2582 |
SV **temp; |
| 2583 |
int len; |
| 2584 |
int i, j; |
| 2585 |
unsigned char (*maps)[256]; |
| 2586 |
CODE: |
| 2587 |
len = av_len(pmaps_av)+1; |
| 2588 |
if (im->channels < len) |
| 2589 |
len = im->channels; |
| 2590 |
maps = mymalloc( len * sizeof(unsigned char [256]) ); |
| 2591 |
for (j=0; j<len ; j++) { |
| 2592 |
temp = av_fetch(pmaps_av, j, 0); |
| 2593 |
if (temp && SvROK(*temp) && (SvTYPE(SvRV(*temp)) == SVt_PVAV) ) { |
| 2594 |
avsub = (AV*)SvRV(*temp); |
| 2595 |
if(av_len(avsub) != 255) |
| 2596 |
continue; |
| 2597 |
mask |= 1<<j; |
| 2598 |
for (i=0; i<256 ; i++) { |
| 2599 |
int val; |
| 2600 |
temp = av_fetch(avsub, i, 0); |
| 2601 |
val = temp ? SvIV(*temp) : 0; |
| 2602 |
if (val<0) val = 0; |
| 2603 |
if (val>255) val = 255; |
| 2604 |
maps[j][i] = val; |
| 2605 |
} |
| 2606 |
} |
| 2607 |
} |
| 2608 |
i_map(im, maps, mask); |
| 2609 |
myfree(maps); |
| 2610 |
RETVAL = 1; |
| 2611 |
OUTPUT: |
| 2612 |
RETVAL |
| 2613 |
|
| 2614 |
float |
| 2615 |
i_img_diff(im1,im2) |
| 2616 |
Imager::ImgRaw im1 |
| 2617 |
Imager::ImgRaw im2 |
| 2618 |
|
| 2619 |
double |
| 2620 |
i_img_diffd(im1,im2) |
| 2621 |
Imager::ImgRaw im1 |
| 2622 |
Imager::ImgRaw im2 |
| 2623 |
|
| 2624 |
int |
| 2625 |
i_img_samef(im1, im2, epsilon = i_img_epsilonf(), what=NULL) |
| 2626 |
Imager::ImgRaw im1 |
| 2627 |
Imager::ImgRaw im2 |
| 2628 |
im_double epsilon |
| 2629 |
const char *what |
| 2630 |
|
| 2631 |
double |
| 2632 |
i_img_epsilonf() |
| 2633 |
|
| 2634 |
bool |
| 2635 |
_is_color_object(sv) |
| 2636 |
SV* sv |
| 2637 |
CODE: |
| 2638 |
SvGETMAGIC(sv); |
| 2639 |
RETVAL = SvOK(sv) && SvROK(sv) && |
| 2640 |
(sv_derived_from(sv, "Imager::Color") |
| 2641 |
|| sv_derived_from(sv, "Imager::Color::Float")); |
| 2642 |
OUTPUT: |
| 2643 |
RETVAL |
| 2644 |
|
| 2645 |
#ifdef HAVE_LIBTT |
| 2646 |
|
| 2647 |
|
| 2648 |
Imager::Font::TT |
| 2649 |
i_tt_new(fontname) |
| 2650 |
char* fontname |
| 2651 |
|
| 2652 |
|
| 2653 |
MODULE = Imager PACKAGE = Imager::Font::TT PREFIX=TT_ |
| 2654 |
|
| 2655 |
#define TT_DESTROY(handle) i_tt_destroy(handle) |
| 2656 |
|
| 2657 |
void |
| 2658 |
TT_DESTROY(handle) |
| 2659 |
Imager::Font::TT handle |
| 2660 |
|
| 2661 |
int |
| 2662 |
TT_CLONE_SKIP(...) |
| 2663 |
CODE: |
| 2664 |
(void)items; /* avoid unused warning */ |
| 2665 |
RETVAL = 1; |
| 2666 |
OUTPUT: |
| 2667 |
RETVAL |
| 2668 |
|
| 2669 |
|
| 2670 |
MODULE = Imager PACKAGE = Imager |
| 2671 |
|
| 2672 |
|
| 2673 |
undef_int |
| 2674 |
i_tt_text(handle,im,xb,yb,cl,points,str_sv,smooth,utf8,align=1) |
| 2675 |
Imager::Font::TT handle |
| 2676 |
Imager::ImgRaw im |
| 2677 |
i_img_dim xb |
| 2678 |
i_img_dim yb |
| 2679 |
Imager::Color cl |
| 2680 |
im_double points |
| 2681 |
SV * str_sv |
| 2682 |
int smooth |
| 2683 |
int utf8 |
| 2684 |
int align |
| 2685 |
PREINIT: |
| 2686 |
char *str; |
| 2687 |
STRLEN len; |
| 2688 |
CODE: |
| 2689 |
str = SvPV(str_sv, len); |
| 2690 |
#ifdef SvUTF8 |
| 2691 |
if (SvUTF8(str_sv)) |
| 2692 |
utf8 = 1; |
| 2693 |
#endif |
| 2694 |
RETVAL = i_tt_text(handle, im, xb, yb, cl, points, str, |
| 2695 |
len, smooth, utf8, align); |
| 2696 |
OUTPUT: |
| 2697 |
RETVAL |
| 2698 |
|
| 2699 |
|
| 2700 |
undef_int |
| 2701 |
i_tt_cp(handle,im,xb,yb,channel,points,str_sv,smooth,utf8,align=1) |
| 2702 |
Imager::Font::TT handle |
| 2703 |
Imager::ImgRaw im |
| 2704 |
i_img_dim xb |
| 2705 |
i_img_dim yb |
| 2706 |
int channel |
| 2707 |
im_double points |
| 2708 |
SV * str_sv |
| 2709 |
int smooth |
| 2710 |
int utf8 |
| 2711 |
int align |
| 2712 |
PREINIT: |
| 2713 |
char *str; |
| 2714 |
STRLEN len; |
| 2715 |
CODE: |
| 2716 |
str = SvPV(str_sv, len); |
| 2717 |
#ifdef SvUTF8 |
| 2718 |
if (SvUTF8(str_sv)) |
| 2719 |
utf8 = 1; |
| 2720 |
#endif |
| 2721 |
RETVAL = i_tt_cp(handle, im, xb, yb, channel, points, str, len, |
| 2722 |
smooth, utf8, align); |
| 2723 |
OUTPUT: |
| 2724 |
RETVAL |
| 2725 |
|
| 2726 |
|
| 2727 |
void |
| 2728 |
i_tt_bbox(handle,point,str_sv,utf8) |
| 2729 |
Imager::Font::TT handle |
| 2730 |
im_double point |
| 2731 |
SV* str_sv |
| 2732 |
int utf8 |
| 2733 |
PREINIT: |
| 2734 |
i_img_dim cords[BOUNDING_BOX_COUNT]; |
| 2735 |
int rc; |
| 2736 |
char * str; |
| 2737 |
STRLEN len; |
| 2738 |
int i; |
| 2739 |
PPCODE: |
| 2740 |
str = SvPV(str_sv, len); |
| 2741 |
#ifdef SvUTF8 |
| 2742 |
if (SvUTF8(ST(2))) |
| 2743 |
utf8 = 1; |
| 2744 |
#endif |
| 2745 |
if ((rc=i_tt_bbox(handle,point,str,len,cords, utf8))) { |
| 2746 |
EXTEND(SP, rc); |
| 2747 |
for (i = 0; i < rc; ++i) { |
| 2748 |
PUSHs(sv_2mortal(newSViv(cords[i]))); |
| 2749 |
} |
| 2750 |
} |
| 2751 |
|
| 2752 |
void |
| 2753 |
i_tt_has_chars(handle, text_sv, utf8) |
| 2754 |
Imager::Font::TT handle |
| 2755 |
SV *text_sv |
| 2756 |
int utf8 |
| 2757 |
PREINIT: |
| 2758 |
char const *text; |
| 2759 |
STRLEN len; |
| 2760 |
char *work; |
| 2761 |
size_t count; |
| 2762 |
size_t i; |
| 2763 |
PPCODE: |
| 2764 |
i_clear_error(); |
| 2765 |
text = SvPV(text_sv, len); |
| 2766 |
#ifdef SvUTF8 |
| 2767 |
if (SvUTF8(text_sv)) |
| 2768 |
utf8 = 1; |
| 2769 |
#endif |
| 2770 |
work = mymalloc(len); |
| 2771 |
count = i_tt_has_chars(handle, text, len, utf8, work); |
| 2772 |
if (GIMME_V == G_ARRAY) { |
| 2773 |
if (count) { |
| 2774 |
EXTEND(SP, count); |
| 2775 |
for (i = 0; i < count; ++i) { |
| 2776 |
PUSHs(boolSV(work[i])); |
| 2777 |
} |
| 2778 |
} |
| 2779 |
} |
| 2780 |
else { |
| 2781 |
EXTEND(SP, 1); |
| 2782 |
PUSHs(sv_2mortal(newSVpv(work, count))); |
| 2783 |
} |
| 2784 |
myfree(work); |
| 2785 |
|
| 2786 |
void |
| 2787 |
i_tt_dump_names(handle) |
| 2788 |
Imager::Font::TT handle |
| 2789 |
|
| 2790 |
void |
| 2791 |
i_tt_face_name(handle) |
| 2792 |
Imager::Font::TT handle |
| 2793 |
PREINIT: |
| 2794 |
char name[255]; |
| 2795 |
size_t len; |
| 2796 |
PPCODE: |
| 2797 |
len = i_tt_face_name(handle, name, sizeof(name)); |
| 2798 |
if (len) { |
| 2799 |
EXTEND(SP, 1); |
| 2800 |
PUSHs(sv_2mortal(newSVpv(name, len-1))); |
| 2801 |
} |
| 2802 |
|
| 2803 |
void |
| 2804 |
i_tt_glyph_name(handle, text_sv, utf8 = 0) |
| 2805 |
Imager::Font::TT handle |
| 2806 |
SV *text_sv |
| 2807 |
int utf8 |
| 2808 |
PREINIT: |
| 2809 |
char const *text; |
| 2810 |
STRLEN work_len; |
| 2811 |
size_t len; |
| 2812 |
size_t outsize; |
| 2813 |
char name[255]; |
| 2814 |
PPCODE: |
| 2815 |
i_clear_error(); |
| 2816 |
text = SvPV(text_sv, work_len); |
| 2817 |
#ifdef SvUTF8 |
| 2818 |
if (SvUTF8(text_sv)) |
| 2819 |
utf8 = 1; |
| 2820 |
#endif |
| 2821 |
len = work_len; |
| 2822 |
while (len) { |
| 2823 |
unsigned long ch; |
| 2824 |
if (utf8) { |
| 2825 |
ch = i_utf8_advance(&text, &len); |
| 2826 |
if (ch == ~0UL) { |
| 2827 |
i_push_error(0, "invalid UTF8 character"); |
| 2828 |
XSRETURN_EMPTY; |
| 2829 |
} |
| 2830 |
} |
| 2831 |
else { |
| 2832 |
ch = *text++; |
| 2833 |
--len; |
| 2834 |
} |
| 2835 |
EXTEND(SP, 1); |
| 2836 |
if ((outsize = i_tt_glyph_name(handle, ch, name, sizeof(name))) != 0) { |
| 2837 |
PUSHs(sv_2mortal(newSVpv(name, 0))); |
| 2838 |
} |
| 2839 |
else { |
| 2840 |
PUSHs(&PL_sv_undef); |
| 2841 |
} |
| 2842 |
} |
| 2843 |
|
| 2844 |
#endif |
| 2845 |
|
| 2846 |
const char * |
| 2847 |
i_test_format_probe(ig, length) |
| 2848 |
Imager::IO ig |
| 2849 |
int length |
| 2850 |
|
| 2851 |
int |
| 2852 |
i_add_file_magic(name, bits_sv, mask_sv) |
| 2853 |
const char *name |
| 2854 |
SV *bits_sv |
| 2855 |
SV *mask_sv |
| 2856 |
PREINIT: |
| 2857 |
const unsigned char *bits; |
| 2858 |
const unsigned char *mask; |
| 2859 |
size_t bits_size; |
| 2860 |
size_t mask_size; |
| 2861 |
CODE: |
| 2862 |
i_clear_error(); |
| 2863 |
bits = (const unsigned char *)SvPV(bits_sv, bits_size); |
| 2864 |
mask = (const unsigned char *)SvPV(mask_sv, mask_size); |
| 2865 |
if (bits_size == 0) { |
| 2866 |
i_push_error(0, "bits must be non-empty"); |
| 2867 |
XSRETURN_EMPTY; |
| 2868 |
} |
| 2869 |
if (mask_size == 0) { |
| 2870 |
i_push_error(0, "mask must be non-empty"); |
| 2871 |
XSRETURN_EMPTY; |
| 2872 |
} |
| 2873 |
if (bits_size != mask_size) { |
| 2874 |
i_push_error(0, "bits and mask must be the same length"); |
| 2875 |
XSRETURN_EMPTY; |
| 2876 |
} |
| 2877 |
if (!*name) { |
| 2878 |
i_push_error(0, "name must be non-empty"); |
| 2879 |
XSRETURN_EMPTY; |
| 2880 |
} |
| 2881 |
RETVAL = i_add_file_magic(name, bits, mask, bits_size); |
| 2882 |
OUTPUT: |
| 2883 |
RETVAL |
| 2884 |
|
| 2885 |
Imager::ImgRaw |
| 2886 |
i_readpnm_wiol(ig, allow_incomplete) |
| 2887 |
Imager::IO ig |
| 2888 |
int allow_incomplete |
| 2889 |
|
| 2890 |
|
| 2891 |
void |
| 2892 |
i_readpnm_multi_wiol(ig, allow_incomplete) |
| 2893 |
Imager::IO ig |
| 2894 |
int allow_incomplete |
| 2895 |
PREINIT: |
| 2896 |
i_img **imgs; |
| 2897 |
int count=0; |
| 2898 |
int i; |
| 2899 |
PPCODE: |
| 2900 |
imgs = i_readpnm_multi_wiol(ig, &count, allow_incomplete); |
| 2901 |
if (imgs) { |
| 2902 |
EXTEND(SP, count); |
| 2903 |
for (i = 0; i < count; ++i) { |
| 2904 |
SV *sv = sv_newmortal(); |
| 2905 |
sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]); |
| 2906 |
PUSHs(sv); |
| 2907 |
} |
| 2908 |
myfree(imgs); |
| 2909 |
} |
| 2910 |
|
| 2911 |
undef_int |
| 2912 |
i_writeppm_wiol(im, ig) |
| 2913 |
Imager::ImgRaw im |
| 2914 |
Imager::IO ig |
| 2915 |
|
| 2916 |
|
| 2917 |
|
| 2918 |
|
| 2919 |
|
| 2920 |
Imager::ImgRaw |
| 2921 |
i_readraw_wiol(ig,x,y,datachannels,storechannels,intrl) |
| 2922 |
Imager::IO ig |
| 2923 |
i_img_dim x |
| 2924 |
i_img_dim y |
| 2925 |
int datachannels |
| 2926 |
int storechannels |
| 2927 |
int intrl |
| 2928 |
|
| 2929 |
undef_int |
| 2930 |
i_writeraw_wiol(im,ig) |
| 2931 |
Imager::ImgRaw im |
| 2932 |
Imager::IO ig |
| 2933 |
|
| 2934 |
undef_int |
| 2935 |
i_writebmp_wiol(im,ig) |
| 2936 |
Imager::ImgRaw im |
| 2937 |
Imager::IO ig |
| 2938 |
|
| 2939 |
Imager::ImgRaw |
| 2940 |
i_readbmp_wiol(ig, allow_incomplete=0) |
| 2941 |
Imager::IO ig |
| 2942 |
int allow_incomplete |
| 2943 |
|
| 2944 |
|
| 2945 |
undef_int |
| 2946 |
i_writetga_wiol(im,ig, wierdpack, compress, idstring) |
| 2947 |
Imager::ImgRaw im |
| 2948 |
Imager::IO ig |
| 2949 |
int wierdpack |
| 2950 |
int compress |
| 2951 |
char* idstring |
| 2952 |
PREINIT: |
| 2953 |
int idlen; |
| 2954 |
CODE: |
| 2955 |
idlen = SvCUR(ST(4)); |
| 2956 |
RETVAL = i_writetga_wiol(im, ig, wierdpack, compress, idstring, idlen); |
| 2957 |
OUTPUT: |
| 2958 |
RETVAL |
| 2959 |
|
| 2960 |
|
| 2961 |
Imager::ImgRaw |
| 2962 |
i_readtga_wiol(ig, length) |
| 2963 |
Imager::IO ig |
| 2964 |
int length |
| 2965 |
|
| 2966 |
|
| 2967 |
|
| 2968 |
|
| 2969 |
Imager::ImgRaw |
| 2970 |
i_scaleaxis(im,Value,Axis) |
| 2971 |
Imager::ImgRaw im |
| 2972 |
im_double Value |
| 2973 |
int Axis |
| 2974 |
|
| 2975 |
Imager::ImgRaw |
| 2976 |
i_scale_nn(im,scx,scy) |
| 2977 |
Imager::ImgRaw im |
| 2978 |
im_double scx |
| 2979 |
im_double scy |
| 2980 |
|
| 2981 |
Imager::ImgRaw |
| 2982 |
i_scale_mixing(im, width, height) |
| 2983 |
Imager::ImgRaw im |
| 2984 |
i_img_dim width |
| 2985 |
i_img_dim height |
| 2986 |
|
| 2987 |
Imager::ImgRaw |
| 2988 |
i_haar(im) |
| 2989 |
Imager::ImgRaw im |
| 2990 |
|
| 2991 |
int |
| 2992 |
i_count_colors(im,maxc) |
| 2993 |
Imager::ImgRaw im |
| 2994 |
int maxc |
| 2995 |
|
| 2996 |
void |
| 2997 |
i_get_anonymous_color_histo(im, maxc = 0x40000000) |
| 2998 |
Imager::ImgRaw im |
| 2999 |
int maxc |
| 3000 |
PREINIT: |
| 3001 |
int i; |
| 3002 |
unsigned int * col_usage = NULL; |
| 3003 |
int col_cnt; |
| 3004 |
PPCODE: |
| 3005 |
col_cnt = i_get_anonymous_color_histo(im, &col_usage, maxc); |
| 3006 |
if (col_cnt <= 0) { |
| 3007 |
XSRETURN_EMPTY; |
| 3008 |
} |
| 3009 |
EXTEND(SP, col_cnt); |
| 3010 |
for (i = 0; i < col_cnt; i++) { |
| 3011 |
PUSHs(sv_2mortal(newSViv( col_usage[i]))); |
| 3012 |
} |
| 3013 |
myfree(col_usage); |
| 3014 |
|
| 3015 |
|
| 3016 |
void |
| 3017 |
i_transform(im, opx, opy, parm) |
| 3018 |
Imager::ImgRaw im |
| 3019 |
int *opx |
| 3020 |
int *opy |
| 3021 |
double *parm |
| 3022 |
PREINIT: |
| 3023 |
STRLEN size_opx, size_opy, size_parm; |
| 3024 |
i_img *result; |
| 3025 |
PPCODE: |
| 3026 |
result=i_transform(im,opx,size_opx,opy,size_opy,parm,size_parm); |
| 3027 |
if (result) { |
| 3028 |
SV *result_sv = sv_newmortal(); |
| 3029 |
EXTEND(SP, 1); |
| 3030 |
sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result); |
| 3031 |
PUSHs(result_sv); |
| 3032 |
} |
| 3033 |
|
| 3034 |
void |
| 3035 |
i_transform2(sv_width,sv_height,channels,sv_ops,av_n_regs,av_c_regs,av_in_imgs) |
| 3036 |
SV *sv_width |
| 3037 |
SV *sv_height |
| 3038 |
SV *sv_ops |
| 3039 |
AV *av_n_regs |
| 3040 |
AV *av_c_regs |
| 3041 |
AV *av_in_imgs |
| 3042 |
int channels |
| 3043 |
PREINIT: |
| 3044 |
i_img_dim width; |
| 3045 |
i_img_dim height; |
| 3046 |
struct rm_op *ops; |
| 3047 |
STRLEN ops_len; |
| 3048 |
int ops_count; |
| 3049 |
double *n_regs; |
| 3050 |
int n_regs_count; |
| 3051 |
i_color *c_regs; |
| 3052 |
int c_regs_count; |
| 3053 |
int in_imgs_count; |
| 3054 |
i_img **in_imgs; |
| 3055 |
SV *sv1; |
| 3056 |
IV tmp; |
| 3057 |
int i; |
| 3058 |
i_img *result; |
| 3059 |
PPCODE: |
| 3060 |
|
| 3061 |
in_imgs_count = av_len(av_in_imgs)+1; |
| 3062 |
for (i = 0; i < in_imgs_count; ++i) { |
| 3063 |
sv1 = *av_fetch(av_in_imgs, i, 0); |
| 3064 |
if (!sv_derived_from(sv1, "Imager::ImgRaw")) { |
| 3065 |
croak("sv_in_img must contain only images"); |
| 3066 |
} |
| 3067 |
} |
| 3068 |
if (in_imgs_count > 0) { |
| 3069 |
in_imgs = mymalloc(in_imgs_count*sizeof(i_img*)); |
| 3070 |
for (i = 0; i < in_imgs_count; ++i) { |
| 3071 |
sv1 = *av_fetch(av_in_imgs,i,0); |
| 3072 |
if (!sv_derived_from(sv1, "Imager::ImgRaw")) { |
| 3073 |
croak("Parameter 5 must contain only images"); |
| 3074 |
} |
| 3075 |
tmp = SvIV((SV*)SvRV(sv1)); |
| 3076 |
in_imgs[i] = INT2PTR(i_img*, tmp); |
| 3077 |
} |
| 3078 |
} |
| 3079 |
else { |
| 3080 |
/* no input images */ |
| 3081 |
in_imgs = NULL; |
| 3082 |
} |
| 3083 |
/* default the output size from the first input if possible */ |
| 3084 |
if (SvOK(sv_width)) |
| 3085 |
width = SvIV(sv_width); |
| 3086 |
else if (in_imgs_count) |
| 3087 |
width = in_imgs[0]->xsize; |
| 3088 |
else |
| 3089 |
croak("No output image width supplied"); |
| 3090 |
|
| 3091 |
if (SvOK(sv_height)) |
| 3092 |
height = SvIV(sv_height); |
| 3093 |
else if (in_imgs_count) |
| 3094 |
height = in_imgs[0]->ysize; |
| 3095 |
else |
| 3096 |
croak("No output image height supplied"); |
| 3097 |
|
| 3098 |
ops = (struct rm_op *)SvPV(sv_ops, ops_len); |
| 3099 |
if (ops_len % sizeof(struct rm_op)) |
| 3100 |
croak("Imager: Parameter 3 must be a bitmap of regops\n"); |
| 3101 |
ops_count = ops_len / sizeof(struct rm_op); |
| 3102 |
|
| 3103 |
n_regs_count = av_len(av_n_regs)+1; |
| 3104 |
n_regs = mymalloc(n_regs_count * sizeof(double)); |
| 3105 |
for (i = 0; i < n_regs_count; ++i) { |
| 3106 |
sv1 = *av_fetch(av_n_regs,i,0); |
| 3107 |
if (SvOK(sv1)) |
| 3108 |
n_regs[i] = SvNV(sv1); |
| 3109 |
} |
| 3110 |
c_regs_count = av_len(av_c_regs)+1; |
| 3111 |
c_regs = mymalloc(c_regs_count * sizeof(i_color)); |
| 3112 |
/* I don't bother initializing the colou?r registers */ |
| 3113 |
|
| 3114 |
result=i_transform2(width, height, channels, ops, ops_count, |
| 3115 |
n_regs, n_regs_count, |
| 3116 |
c_regs, c_regs_count, in_imgs, in_imgs_count); |
| 3117 |
if (in_imgs) |
| 3118 |
myfree(in_imgs); |
| 3119 |
myfree(n_regs); |
| 3120 |
myfree(c_regs); |
| 3121 |
if (result) { |
| 3122 |
SV *result_sv = sv_newmortal(); |
| 3123 |
EXTEND(SP, 1); |
| 3124 |
sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result); |
| 3125 |
PUSHs(result_sv); |
| 3126 |
} |
| 3127 |
|
| 3128 |
|
| 3129 |
void |
| 3130 |
i_contrast(im,intensity) |
| 3131 |
Imager::ImgRaw im |
| 3132 |
im_float intensity |
| 3133 |
|
| 3134 |
void |
| 3135 |
i_hardinvert(im) |
| 3136 |
Imager::ImgRaw im |
| 3137 |
|
| 3138 |
void |
| 3139 |
i_hardinvertall(im) |
| 3140 |
Imager::ImgRaw im |
| 3141 |
|
| 3142 |
void |
| 3143 |
i_noise(im,amount,type) |
| 3144 |
Imager::ImgRaw im |
| 3145 |
im_float amount |
| 3146 |
unsigned char type |
| 3147 |
|
| 3148 |
void |
| 3149 |
i_bumpmap(im,bump,channel,light_x,light_y,strength) |
| 3150 |
Imager::ImgRaw im |
| 3151 |
Imager::ImgRaw bump |
| 3152 |
int channel |
| 3153 |
i_img_dim light_x |
| 3154 |
i_img_dim light_y |
| 3155 |
i_img_dim strength |
| 3156 |
|
| 3157 |
|
| 3158 |
void |
| 3159 |
i_bumpmap_complex(im,bump,channel,tx,ty,Lx,Ly,Lz,cd,cs,n,Ia,Il,Is) |
| 3160 |
Imager::ImgRaw im |
| 3161 |
Imager::ImgRaw bump |
| 3162 |
int channel |
| 3163 |
i_img_dim tx |
| 3164 |
i_img_dim ty |
| 3165 |
im_double Lx |
| 3166 |
im_double Ly |
| 3167 |
im_double Lz |
| 3168 |
im_float cd |
| 3169 |
im_float cs |
| 3170 |
im_float n |
| 3171 |
Imager::Color Ia |
| 3172 |
Imager::Color Il |
| 3173 |
Imager::Color Is |
| 3174 |
|
| 3175 |
|
| 3176 |
|
| 3177 |
void |
| 3178 |
i_postlevels(im,levels) |
| 3179 |
Imager::ImgRaw im |
| 3180 |
int levels |
| 3181 |
|
| 3182 |
void |
| 3183 |
i_mosaic(im,size) |
| 3184 |
Imager::ImgRaw im |
| 3185 |
i_img_dim size |
| 3186 |
|
| 3187 |
void |
| 3188 |
i_watermark(im,wmark,tx,ty,pixdiff) |
| 3189 |
Imager::ImgRaw im |
| 3190 |
Imager::ImgRaw wmark |
| 3191 |
i_img_dim tx |
| 3192 |
i_img_dim ty |
| 3193 |
int pixdiff |
| 3194 |
|
| 3195 |
|
| 3196 |
void |
| 3197 |
i_autolevels(im,lsat,usat,skew) |
| 3198 |
Imager::ImgRaw im |
| 3199 |
im_float lsat |
| 3200 |
im_float usat |
| 3201 |
im_float skew |
| 3202 |
|
| 3203 |
void |
| 3204 |
i_autolevels_mono(im,lsat,usat) |
| 3205 |
Imager::ImgRaw im |
| 3206 |
im_float lsat |
| 3207 |
im_float usat |
| 3208 |
|
| 3209 |
void |
| 3210 |
i_radnoise(im,xo,yo,rscale,ascale) |
| 3211 |
Imager::ImgRaw im |
| 3212 |
im_float xo |
| 3213 |
im_float yo |
| 3214 |
im_float rscale |
| 3215 |
im_float ascale |
| 3216 |
|
| 3217 |
void |
| 3218 |
i_turbnoise(im, xo, yo, scale) |
| 3219 |
Imager::ImgRaw im |
| 3220 |
im_float xo |
| 3221 |
im_float yo |
| 3222 |
im_float scale |
| 3223 |
|
| 3224 |
|
| 3225 |
void |
| 3226 |
i_gradgen(im, xo, yo, ac, dmeasure) |
| 3227 |
Imager::ImgRaw im |
| 3228 |
i_img_dim *xo |
| 3229 |
i_img_dim *yo |
| 3230 |
i_color *ac |
| 3231 |
int dmeasure |
| 3232 |
PREINIT: |
| 3233 |
STRLEN size_xo; |
| 3234 |
STRLEN size_yo; |
| 3235 |
STRLEN size_ac; |
| 3236 |
CODE: |
| 3237 |
if (size_xo != size_yo || size_xo != size_ac) |
| 3238 |
croak("i_gradgen: x, y and color arrays must be the same size"); |
| 3239 |
if (size_xo < 2) |
| 3240 |
croak("Usage: i_gradgen array refs must have more than 1 entry each"); |
| 3241 |
i_gradgen(im, size_xo, xo, yo, ac, dmeasure); |
| 3242 |
|
| 3243 |
Imager::ImgRaw |
| 3244 |
i_diff_image(im, im2, mindist=0) |
| 3245 |
Imager::ImgRaw im |
| 3246 |
Imager::ImgRaw im2 |
| 3247 |
im_double mindist |
| 3248 |
|
| 3249 |
Imager::ImgRaw |
| 3250 |
i_rgbdiff_image(im, im2) |
| 3251 |
Imager::ImgRaw im |
| 3252 |
Imager::ImgRaw im2 |
| 3253 |
|
| 3254 |
undef_int |
| 3255 |
i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs) |
| 3256 |
Imager::ImgRaw im |
| 3257 |
im_double xa |
| 3258 |
im_double ya |
| 3259 |
im_double xb |
| 3260 |
im_double yb |
| 3261 |
int type |
| 3262 |
int repeat |
| 3263 |
int combine |
| 3264 |
int super_sample |
| 3265 |
im_double ssample_param |
| 3266 |
PREINIT: |
| 3267 |
AV *asegs; |
| 3268 |
int count; |
| 3269 |
i_fountain_seg *segs; |
| 3270 |
CODE: |
| 3271 |
if (!SvROK(ST(10)) || ! SvTYPE(SvRV(ST(10)))) |
| 3272 |
croak("i_fountain: argument 11 must be an array ref"); |
| 3273 |
|
| 3274 |
asegs = (AV *)SvRV(ST(10)); |
| 3275 |
segs = load_fount_segs(aTHX_ asegs, &count); |
| 3276 |
RETVAL = i_fountain(im, xa, ya, xb, yb, type, repeat, combine, |
| 3277 |
super_sample, ssample_param, count, segs); |
| 3278 |
myfree(segs); |
| 3279 |
OUTPUT: |
| 3280 |
RETVAL |
| 3281 |
|
| 3282 |
Imager::FillHandle |
| 3283 |
i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs) |
| 3284 |
im_double xa |
| 3285 |
im_double ya |
| 3286 |
im_double xb |
| 3287 |
im_double yb |
| 3288 |
int type |
| 3289 |
int repeat |
| 3290 |
int combine |
| 3291 |
int super_sample |
| 3292 |
im_double ssample_param |
| 3293 |
PREINIT: |
| 3294 |
AV *asegs; |
| 3295 |
int count; |
| 3296 |
i_fountain_seg *segs; |
| 3297 |
CODE: |
| 3298 |
if (!SvROK(ST(9)) || ! SvTYPE(SvRV(ST(9)))) |
| 3299 |
croak("i_fountain: argument 11 must be an array ref"); |
| 3300 |
|
| 3301 |
asegs = (AV *)SvRV(ST(9)); |
| 3302 |
segs = load_fount_segs(aTHX_ asegs, &count); |
| 3303 |
RETVAL = i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, |
| 3304 |
super_sample, ssample_param, count, segs); |
| 3305 |
myfree(segs); |
| 3306 |
OUTPUT: |
| 3307 |
RETVAL |
| 3308 |
|
| 3309 |
Imager::FillHandle |
| 3310 |
i_new_fill_opacity(other_fill, alpha_mult) |
| 3311 |
Imager::FillHandle other_fill |
| 3312 |
im_double alpha_mult |
| 3313 |
|
| 3314 |
void |
| 3315 |
i_errors() |
| 3316 |
PREINIT: |
| 3317 |
i_errmsg *errors; |
| 3318 |
int i; |
| 3319 |
AV *av; |
| 3320 |
SV *sv; |
| 3321 |
PPCODE: |
| 3322 |
errors = i_errors(); |
| 3323 |
i = 0; |
| 3324 |
while (errors[i].msg) { |
| 3325 |
av = newAV(); |
| 3326 |
sv = newSVpv(errors[i].msg, strlen(errors[i].msg)); |
| 3327 |
if (!av_store(av, 0, sv)) { |
| 3328 |
SvREFCNT_dec(sv); |
| 3329 |
} |
| 3330 |
sv = newSViv(errors[i].code); |
| 3331 |
if (!av_store(av, 1, sv)) { |
| 3332 |
SvREFCNT_dec(sv); |
| 3333 |
} |
| 3334 |
XPUSHs(sv_2mortal(newRV_noinc((SV*)av))); |
| 3335 |
++i; |
| 3336 |
} |
| 3337 |
|
| 3338 |
void |
| 3339 |
i_clear_error() |
| 3340 |
|
| 3341 |
void |
| 3342 |
i_push_error(code, msg) |
| 3343 |
int code |
| 3344 |
const char *msg |
| 3345 |
|
| 3346 |
undef_int |
| 3347 |
i_nearest_color(im, ...) |
| 3348 |
Imager::ImgRaw im |
| 3349 |
PREINIT: |
| 3350 |
int num; |
| 3351 |
i_img_dim *xo; |
| 3352 |
i_img_dim *yo; |
| 3353 |
i_color *ival; |
| 3354 |
int dmeasure; |
| 3355 |
int i; |
| 3356 |
SV *sv; |
| 3357 |
AV *axx; |
| 3358 |
AV *ayy; |
| 3359 |
AV *ac; |
| 3360 |
CODE: |
| 3361 |
if (items != 5) |
| 3362 |
croak("Usage: i_nearest_color(im, xo, yo, ival, dmeasure)"); |
| 3363 |
if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1)))) |
| 3364 |
croak("i_nearest_color: Second argument must be an array ref"); |
| 3365 |
if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2)))) |
| 3366 |
croak("i_nearest_color: Third argument must be an array ref"); |
| 3367 |
if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3)))) |
| 3368 |
croak("i_nearest_color: Fourth argument must be an array ref"); |
| 3369 |
axx = (AV *)SvRV(ST(1)); |
| 3370 |
ayy = (AV *)SvRV(ST(2)); |
| 3371 |
ac = (AV *)SvRV(ST(3)); |
| 3372 |
dmeasure = (int)SvIV(ST(4)); |
| 3373 |
|
| 3374 |
num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy); |
| 3375 |
num = num <= av_len(ac) ? num : av_len(ac); |
| 3376 |
num++; |
| 3377 |
if (num < 2) croak("Usage: i_nearest_color array refs must have more than 1 entry each"); |
| 3378 |
xo = malloc_temp(aTHX_ sizeof(i_img_dim) * num ); |
| 3379 |
yo = malloc_temp(aTHX_ sizeof(i_img_dim) * num ); |
| 3380 |
ival = malloc_temp(aTHX_ sizeof(i_color) * num ); |
| 3381 |
for(i = 0; i<num; i++) { |
| 3382 |
xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0)); |
| 3383 |
yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0)); |
| 3384 |
sv = *av_fetch(ac, i, 0); |
| 3385 |
if ( !sv_derived_from(sv, "Imager::Color") ) { |
| 3386 |
free(axx); free(ayy); free(ac); |
| 3387 |
croak("i_nearest_color: Element of fourth argument is not derived from Imager::Color"); |
| 3388 |
} |
| 3389 |
ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv))); |
| 3390 |
} |
| 3391 |
RETVAL = i_nearest_color(im, num, xo, yo, ival, dmeasure); |
| 3392 |
OUTPUT: |
| 3393 |
RETVAL |
| 3394 |
|
| 3395 |
void |
| 3396 |
malloc_state() |
| 3397 |
|
| 3398 |
void |
| 3399 |
DSO_open(filename) |
| 3400 |
char* filename |
| 3401 |
PREINIT: |
| 3402 |
void *rc; |
| 3403 |
char *evstr; |
| 3404 |
PPCODE: |
| 3405 |
rc=DSO_open(filename,&evstr); |
| 3406 |
if (rc!=NULL) { |
| 3407 |
if (evstr!=NULL) { |
| 3408 |
EXTEND(SP,2); |
| 3409 |
PUSHs(sv_2mortal(newSViv(PTR2IV(rc)))); |
| 3410 |
PUSHs(sv_2mortal(newSVpvn(evstr, strlen(evstr)))); |
| 3411 |
} else { |
| 3412 |
EXTEND(SP,1); |
| 3413 |
PUSHs(sv_2mortal(newSViv(PTR2IV(rc)))); |
| 3414 |
} |
| 3415 |
} |
| 3416 |
|
| 3417 |
|
| 3418 |
undef_int |
| 3419 |
DSO_close(dso_handle) |
| 3420 |
void* dso_handle |
| 3421 |
|
| 3422 |
void |
| 3423 |
DSO_funclist(dso_handle_v) |
| 3424 |
void* dso_handle_v |
| 3425 |
PREINIT: |
| 3426 |
int i; |
| 3427 |
DSO_handle *dso_handle; |
| 3428 |
func_ptr *functions; |
| 3429 |
PPCODE: |
| 3430 |
dso_handle=(DSO_handle*)dso_handle_v; |
| 3431 |
functions = DSO_funclist(dso_handle); |
| 3432 |
i=0; |
| 3433 |
while( functions[i].name != NULL) { |
| 3434 |
EXTEND(SP,1); |
| 3435 |
PUSHs(sv_2mortal(newSVpv(functions[i].name,0))); |
| 3436 |
EXTEND(SP,1); |
| 3437 |
PUSHs(sv_2mortal(newSVpv(functions[i++].pcode,0))); |
| 3438 |
} |
| 3439 |
|
| 3440 |
void |
| 3441 |
DSO_call(handle,func_index,hv) |
| 3442 |
void* handle |
| 3443 |
int func_index |
| 3444 |
HV *hv |
| 3445 |
PPCODE: |
| 3446 |
DSO_call( (DSO_handle *)handle,func_index,hv); |
| 3447 |
|
| 3448 |
Imager::Color |
| 3449 |
i_get_pixel(im, x, y) |
| 3450 |
Imager::ImgRaw im |
| 3451 |
i_img_dim x |
| 3452 |
i_img_dim y; |
| 3453 |
CODE: |
| 3454 |
RETVAL = (i_color *)mymalloc(sizeof(i_color)); |
| 3455 |
memset(RETVAL, 0, sizeof(*RETVAL)); |
| 3456 |
if (i_gpix(im, x, y, RETVAL) != 0) { |
| 3457 |
myfree(RETVAL); |
| 3458 |
XSRETURN_UNDEF; |
| 3459 |
} |
| 3460 |
OUTPUT: |
| 3461 |
RETVAL |
| 3462 |
|
| 3463 |
|
| 3464 |
int |
| 3465 |
i_ppix(im, x, y, cl) |
| 3466 |
Imager::ImgRaw im |
| 3467 |
i_img_dim x |
| 3468 |
i_img_dim y |
| 3469 |
Imager::Color cl |
| 3470 |
|
| 3471 |
Imager::ImgRaw |
| 3472 |
i_img_pal_new(x, y, channels, maxpal) |
| 3473 |
i_img_dim x |
| 3474 |
i_img_dim y |
| 3475 |
int channels |
| 3476 |
int maxpal |
| 3477 |
|
| 3478 |
Imager::ImgRaw |
| 3479 |
i_img_to_pal(src, quant_hv) |
| 3480 |
Imager::ImgRaw src |
| 3481 |
HV *quant_hv |
| 3482 |
PREINIT: |
| 3483 |
i_quantize quant; |
| 3484 |
CODE: |
| 3485 |
memset(&quant, 0, sizeof(quant)); |
| 3486 |
quant.version = 1; |
| 3487 |
quant.mc_size = 256; |
| 3488 |
i_clear_error(); |
| 3489 |
if (!ip_handle_quant_opts2(aTHX_ &quant, quant_hv)) { |
| 3490 |
XSRETURN_EMPTY; |
| 3491 |
} |
| 3492 |
RETVAL = i_img_to_pal(src, &quant); |
| 3493 |
if (RETVAL) { |
| 3494 |
ip_copy_colors_back(aTHX_ quant_hv, &quant); |
| 3495 |
} |
| 3496 |
ip_cleanup_quant_opts(aTHX_ &quant); |
| 3497 |
OUTPUT: |
| 3498 |
RETVAL |
| 3499 |
|
| 3500 |
Imager::ImgRaw |
| 3501 |
i_img_to_rgb(src) |
| 3502 |
Imager::ImgRaw src |
| 3503 |
|
| 3504 |
void |
| 3505 |
i_img_make_palette(HV *quant_hv, ...) |
| 3506 |
PREINIT: |
| 3507 |
ssize_t count = items - 1; |
| 3508 |
i_quantize quant; |
| 3509 |
i_img **imgs = NULL; |
| 3510 |
ssize_t color_index; |
| 3511 |
PPCODE: |
| 3512 |
if (count <= 0) |
| 3513 |
croak("Please supply at least one image (%zd)", count); |
| 3514 |
imgs = malloc_temp(aTHX_ count * sizeof(i_img *)); |
| 3515 |
for (color_index = 0; color_index < count; ++color_index) { |
| 3516 |
SV *img_sv = ST(color_index + 1); |
| 3517 |
if (SvROK(img_sv) && sv_derived_from(img_sv, "Imager::ImgRaw")) { |
| 3518 |
imgs[color_index] = INT2PTR(i_img *, SvIV((SV*)SvRV(img_sv))); |
| 3519 |
} |
| 3520 |
else { |
| 3521 |
croak("Image %zd is not an image object", color_index+1); |
| 3522 |
} |
| 3523 |
} |
| 3524 |
memset(&quant, 0, sizeof(quant)); |
| 3525 |
quant.version = 1; |
| 3526 |
quant.mc_size = 256; |
| 3527 |
if (!ip_handle_quant_opts2(aTHX_ &quant, quant_hv)) { |
| 3528 |
XSRETURN_EMPTY; |
| 3529 |
} |
| 3530 |
i_quant_makemap(&quant, imgs, count); |
| 3531 |
EXTEND(SP, quant.mc_count); |
| 3532 |
for (color_index = 0; color_index < quant.mc_count; ++color_index) { |
| 3533 |
SV *sv_c = make_i_color_sv_mortal(aTHX_ quant.mc_colors + color_index); |
| 3534 |
PUSHs(sv_c); |
| 3535 |
} |
| 3536 |
ip_cleanup_quant_opts(aTHX_ &quant); |
| 3537 |
|
| 3538 |
|
| 3539 |
void |
| 3540 |
i_gpal(im, l, r, y) |
| 3541 |
Imager::ImgRaw im |
| 3542 |
i_img_dim l |
| 3543 |
i_img_dim r |
| 3544 |
i_img_dim y |
| 3545 |
PREINIT: |
| 3546 |
i_palidx *work; |
| 3547 |
int count, i; |
| 3548 |
PPCODE: |
| 3549 |
if (l < r) { |
| 3550 |
work = mymalloc((r-l) * sizeof(i_palidx)); |
| 3551 |
count = i_gpal(im, l, r, y, work); |
| 3552 |
if (GIMME_V == G_ARRAY) { |
| 3553 |
EXTEND(SP, count); |
| 3554 |
for (i = 0; i < count; ++i) { |
| 3555 |
PUSHs(sv_2mortal(newSViv(work[i]))); |
| 3556 |
} |
| 3557 |
} |
| 3558 |
else { |
| 3559 |
EXTEND(SP, 1); |
| 3560 |
PUSHs(sv_2mortal(newSVpv((char *)work, count * sizeof(i_palidx)))); |
| 3561 |
} |
| 3562 |
myfree(work); |
| 3563 |
} |
| 3564 |
else { |
| 3565 |
if (GIMME_V != G_ARRAY) { |
| 3566 |
EXTEND(SP, 1); |
| 3567 |
PUSHs(&PL_sv_undef); |
| 3568 |
} |
| 3569 |
} |
| 3570 |
|
| 3571 |
int |
| 3572 |
i_ppal(im, l, y, ...) |
| 3573 |
Imager::ImgRaw im |
| 3574 |
i_img_dim l |
| 3575 |
i_img_dim y |
| 3576 |
PREINIT: |
| 3577 |
i_palidx *work; |
| 3578 |
i_img_dim i; |
| 3579 |
CODE: |
| 3580 |
if (items > 3) { |
| 3581 |
work = malloc_temp(aTHX_ sizeof(i_palidx) * (items-3)); |
| 3582 |
for (i=0; i < items-3; ++i) { |
| 3583 |
work[i] = SvIV(ST(i+3)); |
| 3584 |
} |
| 3585 |
validate_i_ppal(im, work, items - 3); |
| 3586 |
RETVAL = i_ppal(im, l, l+items-3, y, work); |
| 3587 |
} |
| 3588 |
else { |
| 3589 |
RETVAL = 0; |
| 3590 |
} |
| 3591 |
OUTPUT: |
| 3592 |
RETVAL |
| 3593 |
|
| 3594 |
int |
| 3595 |
i_ppal_p(im, l, y, data) |
| 3596 |
Imager::ImgRaw im |
| 3597 |
i_img_dim l |
| 3598 |
i_img_dim y |
| 3599 |
SV *data |
| 3600 |
PREINIT: |
| 3601 |
i_palidx const *work; |
| 3602 |
STRLEN len; |
| 3603 |
CODE: |
| 3604 |
work = (i_palidx const *)SvPV(data, len); |
| 3605 |
len /= sizeof(i_palidx); |
| 3606 |
if (len > 0) { |
| 3607 |
validate_i_ppal(im, work, len); |
| 3608 |
RETVAL = i_ppal(im, l, l+len, y, work); |
| 3609 |
} |
| 3610 |
else { |
| 3611 |
RETVAL = 0; |
| 3612 |
} |
| 3613 |
OUTPUT: |
| 3614 |
RETVAL |
| 3615 |
|
| 3616 |
SysRet |
| 3617 |
i_addcolors(im, ...) |
| 3618 |
Imager::ImgRaw im |
| 3619 |
PREINIT: |
| 3620 |
i_color *colors; |
| 3621 |
int i; |
| 3622 |
CODE: |
| 3623 |
if (items < 2) |
| 3624 |
croak("i_addcolors: no colors to add"); |
| 3625 |
colors = mymalloc((items-1) * sizeof(i_color)); |
| 3626 |
for (i=0; i < items-1; ++i) { |
| 3627 |
if (sv_isobject(ST(i+1)) |
| 3628 |
&& sv_derived_from(ST(i+1), "Imager::Color")) { |
| 3629 |
IV tmp = SvIV((SV *)SvRV(ST(i+1))); |
| 3630 |
colors[i] = *INT2PTR(i_color *, tmp); |
| 3631 |
} |
| 3632 |
else { |
| 3633 |
myfree(colors); |
| 3634 |
croak("i_addcolor: pixels must be Imager::Color objects"); |
| 3635 |
} |
| 3636 |
} |
| 3637 |
RETVAL = i_addcolors(im, colors, items-1); |
| 3638 |
myfree(colors); |
| 3639 |
OUTPUT: |
| 3640 |
RETVAL |
| 3641 |
|
| 3642 |
undef_int |
| 3643 |
i_setcolors(im, index, ...) |
| 3644 |
Imager::ImgRaw im |
| 3645 |
int index |
| 3646 |
PREINIT: |
| 3647 |
i_color *colors; |
| 3648 |
int i; |
| 3649 |
CODE: |
| 3650 |
if (items < 3) |
| 3651 |
croak("i_setcolors: no colors to add"); |
| 3652 |
colors = mymalloc((items-2) * sizeof(i_color)); |
| 3653 |
for (i=0; i < items-2; ++i) { |
| 3654 |
if (sv_isobject(ST(i+2)) |
| 3655 |
&& sv_derived_from(ST(i+2), "Imager::Color")) { |
| 3656 |
IV tmp = SvIV((SV *)SvRV(ST(i+2))); |
| 3657 |
colors[i] = *INT2PTR(i_color *, tmp); |
| 3658 |
} |
| 3659 |
else { |
| 3660 |
myfree(colors); |
| 3661 |
croak("i_setcolors: pixels must be Imager::Color objects"); |
| 3662 |
} |
| 3663 |
} |
| 3664 |
RETVAL = i_setcolors(im, index, colors, items-2); |
| 3665 |
myfree(colors); |
| 3666 |
OUTPUT: |
| 3667 |
RETVAL |
| 3668 |
|
| 3669 |
void |
| 3670 |
i_getcolors(im, index, count=1) |
| 3671 |
Imager::ImgRaw im |
| 3672 |
int index |
| 3673 |
int count |
| 3674 |
PREINIT: |
| 3675 |
i_color *colors; |
| 3676 |
int i; |
| 3677 |
PPCODE: |
| 3678 |
if (count < 1) |
| 3679 |
croak("i_getcolors: count must be positive"); |
| 3680 |
colors = malloc_temp(aTHX_ sizeof(i_color) * count); |
| 3681 |
if (i_getcolors(im, index, colors, count)) { |
| 3682 |
EXTEND(SP, count); |
| 3683 |
for (i = 0; i < count; ++i) { |
| 3684 |
SV *sv = make_i_color_sv_mortal(aTHX_ colors+i); |
| 3685 |
PUSHs(sv); |
| 3686 |
} |
| 3687 |
} |
| 3688 |
|
| 3689 |
undef_neg_int |
| 3690 |
i_colorcount(im) |
| 3691 |
Imager::ImgRaw im |
| 3692 |
|
| 3693 |
undef_neg_int |
| 3694 |
i_maxcolors(im) |
| 3695 |
Imager::ImgRaw im |
| 3696 |
|
| 3697 |
i_palidx |
| 3698 |
i_findcolor(im, color) |
| 3699 |
Imager::ImgRaw im |
| 3700 |
Imager::Color color |
| 3701 |
CODE: |
| 3702 |
if (!i_findcolor(im, color, &RETVAL)) { |
| 3703 |
XSRETURN_UNDEF; |
| 3704 |
} |
| 3705 |
OUTPUT: |
| 3706 |
RETVAL |
| 3707 |
|
| 3708 |
int |
| 3709 |
i_img_bits(im) |
| 3710 |
Imager::ImgRaw im |
| 3711 |
|
| 3712 |
int |
| 3713 |
i_img_type(im) |
| 3714 |
Imager::ImgRaw im |
| 3715 |
|
| 3716 |
int |
| 3717 |
i_img_virtual(im) |
| 3718 |
Imager::ImgRaw im |
| 3719 |
|
| 3720 |
void |
| 3721 |
i_gsamp(im, l, r, y, channels) |
| 3722 |
Imager::ImgRaw im |
| 3723 |
i_img_dim l |
| 3724 |
i_img_dim r |
| 3725 |
i_img_dim y |
| 3726 |
i_channel_list channels |
| 3727 |
PREINIT: |
| 3728 |
i_sample_t *data; |
| 3729 |
i_img_dim count, i; |
| 3730 |
PPCODE: |
| 3731 |
if (l < r) { |
| 3732 |
data = mymalloc(sizeof(i_sample_t) * (r-l) * channels.count); |
| 3733 |
count = i_gsamp(im, l, r, y, data, channels.channels, channels.count); |
| 3734 |
if (GIMME_V == G_ARRAY) { |
| 3735 |
EXTEND(SP, count); |
| 3736 |
for (i = 0; i < count; ++i) |
| 3737 |
PUSHs(sv_2mortal(newSViv(data[i]))); |
| 3738 |
} |
| 3739 |
else { |
| 3740 |
EXTEND(SP, 1); |
| 3741 |
PUSHs(sv_2mortal(newSVpv((char *)data, count * sizeof(i_sample_t)))); |
| 3742 |
} |
| 3743 |
myfree(data); |
| 3744 |
} |
| 3745 |
else { |
| 3746 |
if (GIMME_V != G_ARRAY) { |
| 3747 |
XSRETURN_UNDEF; |
| 3748 |
} |
| 3749 |
} |
| 3750 |
|
| 3751 |
undef_neg_int |
| 3752 |
i_gsamp_bits(im, l, r, y, bits, target, offset, channels) |
| 3753 |
Imager::ImgRaw im |
| 3754 |
i_img_dim l |
| 3755 |
i_img_dim r |
| 3756 |
i_img_dim y |
| 3757 |
int bits |
| 3758 |
AV *target |
| 3759 |
STRLEN offset |
| 3760 |
i_channel_list channels |
| 3761 |
PREINIT: |
| 3762 |
unsigned *data; |
| 3763 |
i_img_dim count, i; |
| 3764 |
CODE: |
| 3765 |
i_clear_error(); |
| 3766 |
if (items < 8) |
| 3767 |
croak("No channel numbers supplied to g_samp()"); |
| 3768 |
if (l < r) { |
| 3769 |
data = mymalloc(sizeof(unsigned) * (r-l) * channels.count); |
| 3770 |
count = i_gsamp_bits(im, l, r, y, data, channels.channels, channels.count, bits); |
| 3771 |
for (i = 0; i < count; ++i) { |
| 3772 |
av_store(target, i+offset, newSVuv(data[i])); |
| 3773 |
} |
| 3774 |
myfree(data); |
| 3775 |
RETVAL = count; |
| 3776 |
} |
| 3777 |
else { |
| 3778 |
RETVAL = 0; |
| 3779 |
} |
| 3780 |
OUTPUT: |
| 3781 |
RETVAL |
| 3782 |
|
| 3783 |
undef_neg_int |
| 3784 |
i_psamp_bits(im, l, y, bits, channels, data_av, data_offset = 0, pixel_count = -1) |
| 3785 |
Imager::ImgRaw im |
| 3786 |
i_img_dim l |
| 3787 |
i_img_dim y |
| 3788 |
int bits |
| 3789 |
i_channel_list channels |
| 3790 |
AV *data_av |
| 3791 |
i_img_dim data_offset |
| 3792 |
i_img_dim pixel_count |
| 3793 |
PREINIT: |
| 3794 |
STRLEN data_count; |
| 3795 |
size_t data_used; |
| 3796 |
unsigned *data; |
| 3797 |
size_t data_index; |
| 3798 |
CODE: |
| 3799 |
i_clear_error(); |
| 3800 |
|
| 3801 |
data_count = av_len(data_av) + 1; |
| 3802 |
if (data_offset < 0) { |
| 3803 |
croak("data_offset must be non-negative"); |
| 3804 |
} |
| 3805 |
if ((size_t)data_offset > data_count) { |
| 3806 |
croak("data_offset greater than number of samples supplied"); |
| 3807 |
} |
| 3808 |
if (pixel_count == -1 || |
| 3809 |
(size_t)data_offset + pixel_count * channels.count > data_count) { |
| 3810 |
pixel_count = (data_count - data_offset) / channels.count; |
| 3811 |
} |
| 3812 |
|
| 3813 |
data_used = pixel_count * channels.count; |
| 3814 |
data = mymalloc(sizeof(unsigned) * data_count); |
| 3815 |
for (data_index = 0; data_index < data_used; ++data_index) { |
| 3816 |
data[data_index] = |
| 3817 |
SvUV(*av_fetch(data_av, data_offset + data_index, 0)); |
| 3818 |
} |
| 3819 |
|
| 3820 |
RETVAL = i_psamp_bits(im, l, l + pixel_count, y, data, channels.channels, |
| 3821 |
channels.count, bits); |
| 3822 |
|
| 3823 |
if (data) |
| 3824 |
myfree(data); |
| 3825 |
OUTPUT: |
| 3826 |
RETVAL |
| 3827 |
|
| 3828 |
undef_neg_int |
| 3829 |
i_psamp(im, x, y, channels, data, offset = 0, width = -1) |
| 3830 |
Imager::ImgRaw im |
| 3831 |
i_img_dim x |
| 3832 |
i_img_dim y |
| 3833 |
i_channel_list channels |
| 3834 |
i_sample_list data |
| 3835 |
i_img_dim offset |
| 3836 |
i_img_dim width |
| 3837 |
PREINIT: |
| 3838 |
i_img_dim r; |
| 3839 |
CODE: |
| 3840 |
i_clear_error(); |
| 3841 |
if (offset < 0) { |
| 3842 |
i_push_error(0, "offset must be non-negative"); |
| 3843 |
XSRETURN_UNDEF; |
| 3844 |
} |
| 3845 |
if (offset > 0) { |
| 3846 |
if ((size_t)offset > data.count) { |
| 3847 |
i_push_error(0, "offset greater than number of samples supplied"); |
| 3848 |
XSRETURN_UNDEF; |
| 3849 |
} |
| 3850 |
data.samples += offset; |
| 3851 |
data.count -= offset; |
| 3852 |
} |
| 3853 |
if (width == -1 || |
| 3854 |
(size_t)width * channels.count > data.count) { |
| 3855 |
width = data.count / channels.count; |
| 3856 |
} |
| 3857 |
if (x >= im->xsize) { |
| 3858 |
i_push_error(0, "Image position outside of image"); |
| 3859 |
XSRETURN_UNDEF; |
| 3860 |
} |
| 3861 |
if (width <= 0) { |
| 3862 |
i_push_errorf(0, "i_psamp: width %zd negative or zero", width); |
| 3863 |
XSRETURN_UNDEF; |
| 3864 |
} |
| 3865 |
r = x + width; |
| 3866 |
RETVAL = i_psamp(im, x, r, y, data.samples, channels.channels, channels.count); |
| 3867 |
OUTPUT: |
| 3868 |
RETVAL |
| 3869 |
|
| 3870 |
undef_neg_int |
| 3871 |
i_psampf(im, x, y, channels, data, offset = 0, width = -1) |
| 3872 |
Imager::ImgRaw im |
| 3873 |
i_img_dim x |
| 3874 |
i_img_dim y |
| 3875 |
i_channel_list channels |
| 3876 |
i_fsample_list data |
| 3877 |
i_img_dim offset |
| 3878 |
i_img_dim width |
| 3879 |
PREINIT: |
| 3880 |
i_img_dim r; |
| 3881 |
CODE: |
| 3882 |
i_clear_error(); |
| 3883 |
if (offset < 0) { |
| 3884 |
i_push_error(0, "offset must be non-negative"); |
| 3885 |
XSRETURN_UNDEF; |
| 3886 |
} |
| 3887 |
if (offset > 0) { |
| 3888 |
if ((size_t)offset > data.count) { |
| 3889 |
i_push_error(0, "offset greater than number of samples supplied"); |
| 3890 |
XSRETURN_UNDEF; |
| 3891 |
} |
| 3892 |
data.samples += offset; |
| 3893 |
data.count -= offset; |
| 3894 |
} |
| 3895 |
if (width == -1 || |
| 3896 |
(size_t)width * channels.count > data.count) { |
| 3897 |
width = data.count / channels.count; |
| 3898 |
} |
| 3899 |
r = x + width; |
| 3900 |
RETVAL = i_psampf(im, x, r, y, data.samples, channels.channels, channels.count); |
| 3901 |
OUTPUT: |
| 3902 |
RETVAL |
| 3903 |
|
| 3904 |
Imager::ImgRaw |
| 3905 |
i_img_masked_new(targ, mask, x, y, w, h) |
| 3906 |
Imager::ImgRaw targ |
| 3907 |
i_img_dim x |
| 3908 |
i_img_dim y |
| 3909 |
i_img_dim w |
| 3910 |
i_img_dim h |
| 3911 |
PREINIT: |
| 3912 |
i_img *mask; |
| 3913 |
CODE: |
| 3914 |
if (SvOK(ST(1))) { |
| 3915 |
if (!sv_isobject(ST(1)) |
| 3916 |
|| !sv_derived_from(ST(1), "Imager::ImgRaw")) { |
| 3917 |
croak("i_img_masked_new: parameter 2 must undef or an image"); |
| 3918 |
} |
| 3919 |
mask = INT2PTR(i_img *, SvIV((SV *)SvRV(ST(1)))); |
| 3920 |
} |
| 3921 |
else |
| 3922 |
mask = NULL; |
| 3923 |
RETVAL = i_img_masked_new(targ, mask, x, y, w, h); |
| 3924 |
OUTPUT: |
| 3925 |
RETVAL |
| 3926 |
|
| 3927 |
int |
| 3928 |
i_plin(im, l, y, ...) |
| 3929 |
Imager::ImgRaw im |
| 3930 |
i_img_dim l |
| 3931 |
i_img_dim y |
| 3932 |
PREINIT: |
| 3933 |
i_color *work; |
| 3934 |
STRLEN len; |
| 3935 |
size_t count; |
| 3936 |
CODE: |
| 3937 |
if (items > 3) { |
| 3938 |
if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) { |
| 3939 |
/* supplied as a byte string */ |
| 3940 |
work = (i_color *)SvPV(ST(3), len); |
| 3941 |
count = len / sizeof(i_color); |
| 3942 |
if (count * sizeof(i_color) != len) { |
| 3943 |
croak("i_plin: length of scalar argument must be multiple of sizeof i_color"); |
| 3944 |
} |
| 3945 |
RETVAL = i_plin(im, l, l+count, y, work); |
| 3946 |
} |
| 3947 |
else { |
| 3948 |
I32 item_index; |
| 3949 |
work = mymalloc(sizeof(i_color) * (items-3)); |
| 3950 |
for (item_index = 0; item_index < items-3; ++item_index) { |
| 3951 |
if (sv_isobject(ST(item_index+3)) |
| 3952 |
&& sv_derived_from(ST(item_index+3), "Imager::Color")) { |
| 3953 |
IV tmp = SvIV((SV *)SvRV(ST(item_index+3))); |
| 3954 |
work[item_index] = *INT2PTR(i_color *, tmp); |
| 3955 |
} |
| 3956 |
else { |
| 3957 |
myfree(work); |
| 3958 |
croak("i_plin: pixels must be Imager::Color objects"); |
| 3959 |
} |
| 3960 |
} |
| 3961 |
RETVAL = i_plin(im, l, l+items-3, y, work); |
| 3962 |
myfree(work); |
| 3963 |
} |
| 3964 |
} |
| 3965 |
else { |
| 3966 |
RETVAL = 0; |
| 3967 |
} |
| 3968 |
OUTPUT: |
| 3969 |
RETVAL |
| 3970 |
|
| 3971 |
int |
| 3972 |
i_ppixf(im, x, y, cl) |
| 3973 |
Imager::ImgRaw im |
| 3974 |
i_img_dim x |
| 3975 |
i_img_dim y |
| 3976 |
Imager::Color::Float cl |
| 3977 |
|
| 3978 |
void |
| 3979 |
i_gsampf(im, l, r, y, channels) |
| 3980 |
Imager::ImgRaw im |
| 3981 |
i_img_dim l |
| 3982 |
i_img_dim r |
| 3983 |
i_img_dim y |
| 3984 |
i_channel_list channels |
| 3985 |
PREINIT: |
| 3986 |
i_fsample_t *data; |
| 3987 |
i_img_dim count, i; |
| 3988 |
PPCODE: |
| 3989 |
if (l < r) { |
| 3990 |
data = mymalloc(sizeof(i_fsample_t) * (r-l) * channels.count); |
| 3991 |
count = i_gsampf(im, l, r, y, data, channels.channels, channels.count); |
| 3992 |
if (GIMME_V == G_ARRAY) { |
| 3993 |
EXTEND(SP, count); |
| 3994 |
for (i = 0; i < count; ++i) |
| 3995 |
PUSHs(sv_2mortal(newSVnv(data[i]))); |
| 3996 |
} |
| 3997 |
else { |
| 3998 |
EXTEND(SP, 1); |
| 3999 |
PUSHs(sv_2mortal(newSVpv((void *)data, count * sizeof(i_fsample_t)))); |
| 4000 |
} |
| 4001 |
myfree(data); |
| 4002 |
} |
| 4003 |
else { |
| 4004 |
if (GIMME_V != G_ARRAY) { |
| 4005 |
XSRETURN_UNDEF; |
| 4006 |
} |
| 4007 |
} |
| 4008 |
|
| 4009 |
int |
| 4010 |
i_plinf(im, l, y, ...) |
| 4011 |
Imager::ImgRaw im |
| 4012 |
i_img_dim l |
| 4013 |
i_img_dim y |
| 4014 |
PREINIT: |
| 4015 |
i_fcolor *work; |
| 4016 |
i_img_dim i; |
| 4017 |
STRLEN len; |
| 4018 |
size_t count; |
| 4019 |
CODE: |
| 4020 |
if (items > 3) { |
| 4021 |
if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) { |
| 4022 |
/* supplied as a byte string */ |
| 4023 |
work = (i_fcolor *)SvPV(ST(3), len); |
| 4024 |
count = len / sizeof(i_fcolor); |
| 4025 |
if (count * sizeof(i_fcolor) != len) { |
| 4026 |
croak("i_plin: length of scalar argument must be multiple of sizeof i_fcolor"); |
| 4027 |
} |
| 4028 |
RETVAL = i_plinf(im, l, l+count, y, work); |
| 4029 |
} |
| 4030 |
else { |
| 4031 |
work = mymalloc(sizeof(i_fcolor) * (items-3)); |
| 4032 |
for (i=0; i < items-3; ++i) { |
| 4033 |
if (sv_isobject(ST(i+3)) |
| 4034 |
&& sv_derived_from(ST(i+3), "Imager::Color::Float")) { |
| 4035 |
IV tmp = SvIV((SV *)SvRV(ST(i+3))); |
| 4036 |
work[i] = *INT2PTR(i_fcolor *, tmp); |
| 4037 |
} |
| 4038 |
else { |
| 4039 |
myfree(work); |
| 4040 |
croak("i_plinf: pixels must be Imager::Color::Float objects"); |
| 4041 |
} |
| 4042 |
} |
| 4043 |
/**(char *)0 = 1;*/ |
| 4044 |
RETVAL = i_plinf(im, l, l+items-3, y, work); |
| 4045 |
myfree(work); |
| 4046 |
} |
| 4047 |
} |
| 4048 |
else { |
| 4049 |
RETVAL = 0; |
| 4050 |
} |
| 4051 |
OUTPUT: |
| 4052 |
RETVAL |
| 4053 |
|
| 4054 |
Imager::Color::Float |
| 4055 |
i_gpixf(im, x, y) |
| 4056 |
Imager::ImgRaw im |
| 4057 |
i_img_dim x |
| 4058 |
i_img_dim y; |
| 4059 |
CODE: |
| 4060 |
RETVAL = (i_fcolor *)mymalloc(sizeof(i_fcolor)); |
| 4061 |
memset(RETVAL, 0, sizeof(*RETVAL)); |
| 4062 |
if (i_gpixf(im, x, y, RETVAL) != 0) { |
| 4063 |
myfree(RETVAL); |
| 4064 |
XSRETURN_UNDEF; |
| 4065 |
} |
| 4066 |
OUTPUT: |
| 4067 |
RETVAL |
| 4068 |
|
| 4069 |
void |
| 4070 |
i_glin(im, l, r, y) |
| 4071 |
Imager::ImgRaw im |
| 4072 |
i_img_dim l |
| 4073 |
i_img_dim r |
| 4074 |
i_img_dim y |
| 4075 |
PREINIT: |
| 4076 |
i_color *vals; |
| 4077 |
i_img_dim count, i; |
| 4078 |
PPCODE: |
| 4079 |
if (l < r) { |
| 4080 |
vals = mymalloc((r-l) * sizeof(i_color)); |
| 4081 |
memset(vals, 0, (r-l) * sizeof(i_color)); |
| 4082 |
count = i_glin(im, l, r, y, vals); |
| 4083 |
if (GIMME_V == G_ARRAY) { |
| 4084 |
EXTEND(SP, count); |
| 4085 |
for (i = 0; i < count; ++i) { |
| 4086 |
SV *sv = make_i_color_sv_mortal(aTHX_ vals+i); |
| 4087 |
PUSHs(sv); |
| 4088 |
} |
| 4089 |
} |
| 4090 |
else if (count) { |
| 4091 |
EXTEND(SP, 1); |
| 4092 |
PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_color)))); |
| 4093 |
} |
| 4094 |
myfree(vals); |
| 4095 |
} |
| 4096 |
|
| 4097 |
void |
| 4098 |
i_glinf(im, l, r, y) |
| 4099 |
Imager::ImgRaw im |
| 4100 |
i_img_dim l |
| 4101 |
i_img_dim r |
| 4102 |
i_img_dim y |
| 4103 |
PREINIT: |
| 4104 |
i_fcolor *vals; |
| 4105 |
i_img_dim count, i; |
| 4106 |
i_fcolor zero; |
| 4107 |
PPCODE: |
| 4108 |
for (i = 0; i < MAXCHANNELS; ++i) |
| 4109 |
zero.channel[i] = 0; |
| 4110 |
if (l < r) { |
| 4111 |
vals = mymalloc((r-l) * sizeof(i_fcolor)); |
| 4112 |
for (i = 0; i < r-l; ++i) |
| 4113 |
vals[i] = zero; |
| 4114 |
count = i_glinf(im, l, r, y, vals); |
| 4115 |
if (GIMME_V == G_ARRAY) { |
| 4116 |
EXTEND(SP, count); |
| 4117 |
for (i = 0; i < count; ++i) { |
| 4118 |
SV *sv = make_i_fcolor_sv_mortal(aTHX_ vals+i); |
| 4119 |
PUSHs(sv); |
| 4120 |
} |
| 4121 |
} |
| 4122 |
else if (count) { |
| 4123 |
EXTEND(SP, 1); |
| 4124 |
PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_fcolor)))); |
| 4125 |
} |
| 4126 |
myfree(vals); |
| 4127 |
} |
| 4128 |
|
| 4129 |
Imager::ImgRaw |
| 4130 |
i_img_8_new(xsize, ysize, channels) |
| 4131 |
i_img_dim xsize |
| 4132 |
i_img_dim ysize |
| 4133 |
int channels |
| 4134 |
|
| 4135 |
Imager::ImgRaw |
| 4136 |
i_img_16_new(xsize, ysize, channels) |
| 4137 |
i_img_dim xsize |
| 4138 |
i_img_dim ysize |
| 4139 |
int channels |
| 4140 |
|
| 4141 |
Imager::ImgRaw |
| 4142 |
i_img_to_rgb16(im) |
| 4143 |
Imager::ImgRaw im |
| 4144 |
|
| 4145 |
Imager::ImgRaw |
| 4146 |
i_img_double_new(xsize, ysize, channels) |
| 4147 |
i_img_dim xsize |
| 4148 |
i_img_dim ysize |
| 4149 |
int channels |
| 4150 |
|
| 4151 |
Imager::ImgRaw |
| 4152 |
i_img_to_drgb(im) |
| 4153 |
Imager::ImgRaw im |
| 4154 |
|
| 4155 |
undef_int |
| 4156 |
i_tags_addn(im, name_sv, code, idata) |
| 4157 |
Imager::ImgRaw im |
| 4158 |
SV *name_sv |
| 4159 |
int code |
| 4160 |
int idata |
| 4161 |
PREINIT: |
| 4162 |
char *name; |
| 4163 |
STRLEN len; |
| 4164 |
CODE: |
| 4165 |
SvGETMAGIC(name_sv); |
| 4166 |
if (SvOK(name_sv)) |
| 4167 |
name = SvPV_nomg(name_sv, len); |
| 4168 |
else |
| 4169 |
name = NULL; |
| 4170 |
RETVAL = i_tags_addn(&im->tags, name, code, idata); |
| 4171 |
OUTPUT: |
| 4172 |
RETVAL |
| 4173 |
|
| 4174 |
undef_int |
| 4175 |
i_tags_add(im, name_sv, code, data_sv, idata) |
| 4176 |
Imager::ImgRaw im |
| 4177 |
SV *name_sv |
| 4178 |
int code |
| 4179 |
SV *data_sv |
| 4180 |
int idata |
| 4181 |
PREINIT: |
| 4182 |
char *name; |
| 4183 |
char *data; |
| 4184 |
STRLEN len; |
| 4185 |
CODE: |
| 4186 |
SvGETMAGIC(name_sv); |
| 4187 |
if (SvOK(name_sv)) |
| 4188 |
name = SvPV_nomg(name_sv, len); |
| 4189 |
else |
| 4190 |
name = NULL; |
| 4191 |
SvGETMAGIC(data_sv); |
| 4192 |
if (SvOK(data_sv)) |
| 4193 |
data = SvPV(data_sv, len); |
| 4194 |
else { |
| 4195 |
data = NULL; |
| 4196 |
len = 0; |
| 4197 |
} |
| 4198 |
RETVAL = i_tags_add(&im->tags, name, code, data, len, idata); |
| 4199 |
OUTPUT: |
| 4200 |
RETVAL |
| 4201 |
|
| 4202 |
SysRet |
| 4203 |
i_tags_find(im, name, start) |
| 4204 |
Imager::ImgRaw im |
| 4205 |
char *name |
| 4206 |
int start |
| 4207 |
PREINIT: |
| 4208 |
int entry; |
| 4209 |
CODE: |
| 4210 |
if (i_tags_find(&im->tags, name, start, &entry)) { |
| 4211 |
RETVAL = entry; |
| 4212 |
} else { |
| 4213 |
XSRETURN_UNDEF; |
| 4214 |
} |
| 4215 |
OUTPUT: |
| 4216 |
RETVAL |
| 4217 |
|
| 4218 |
SysRet |
| 4219 |
i_tags_findn(im, code, start) |
| 4220 |
Imager::ImgRaw im |
| 4221 |
int code |
| 4222 |
int start |
| 4223 |
PREINIT: |
| 4224 |
int entry; |
| 4225 |
CODE: |
| 4226 |
if (i_tags_findn(&im->tags, code, start, &entry)) { |
| 4227 |
RETVAL = entry; |
| 4228 |
} |
| 4229 |
else { |
| 4230 |
XSRETURN_UNDEF; |
| 4231 |
} |
| 4232 |
OUTPUT: |
| 4233 |
RETVAL |
| 4234 |
|
| 4235 |
int |
| 4236 |
i_tags_delete(im, entry) |
| 4237 |
Imager::ImgRaw im |
| 4238 |
int entry |
| 4239 |
CODE: |
| 4240 |
RETVAL = i_tags_delete(&im->tags, entry); |
| 4241 |
OUTPUT: |
| 4242 |
RETVAL |
| 4243 |
|
| 4244 |
int |
| 4245 |
i_tags_delbyname(im, name) |
| 4246 |
Imager::ImgRaw im |
| 4247 |
char * name |
| 4248 |
CODE: |
| 4249 |
RETVAL = i_tags_delbyname(&im->tags, name); |
| 4250 |
OUTPUT: |
| 4251 |
RETVAL |
| 4252 |
|
| 4253 |
int |
| 4254 |
i_tags_delbycode(im, code) |
| 4255 |
Imager::ImgRaw im |
| 4256 |
int code |
| 4257 |
CODE: |
| 4258 |
RETVAL = i_tags_delbycode(&im->tags, code); |
| 4259 |
OUTPUT: |
| 4260 |
RETVAL |
| 4261 |
|
| 4262 |
void |
| 4263 |
i_tags_get(im, index) |
| 4264 |
Imager::ImgRaw im |
| 4265 |
int index |
| 4266 |
PPCODE: |
| 4267 |
if (index >= 0 && index < im->tags.count) { |
| 4268 |
i_img_tag *entry = im->tags.tags + index; |
| 4269 |
EXTEND(SP, 5); |
| 4270 |
|
| 4271 |
if (entry->name) { |
| 4272 |
PUSHs(sv_2mortal(newSVpv(entry->name, 0))); |
| 4273 |
} |
| 4274 |
else { |
| 4275 |
PUSHs(sv_2mortal(newSViv(entry->code))); |
| 4276 |
} |
| 4277 |
if (entry->data) { |
| 4278 |
PUSHs(sv_2mortal(newSVpvn(entry->data, entry->size))); |
| 4279 |
} |
| 4280 |
else { |
| 4281 |
PUSHs(sv_2mortal(newSViv(entry->idata))); |
| 4282 |
} |
| 4283 |
} |
| 4284 |
|
| 4285 |
void |
| 4286 |
i_tags_get_string(im, what_sv) |
| 4287 |
Imager::ImgRaw im |
| 4288 |
SV *what_sv |
| 4289 |
PREINIT: |
| 4290 |
char const *name = NULL; |
| 4291 |
int code; |
| 4292 |
char buffer[200]; |
| 4293 |
PPCODE: |
| 4294 |
if (SvIOK(what_sv)) { |
| 4295 |
code = SvIV(what_sv); |
| 4296 |
name = NULL; |
| 4297 |
} |
| 4298 |
else { |
| 4299 |
name = SvPV_nolen(what_sv); |
| 4300 |
code = 0; |
| 4301 |
} |
| 4302 |
if (i_tags_get_string(&im->tags, name, code, buffer, sizeof(buffer))) { |
| 4303 |
EXTEND(SP, 1); |
| 4304 |
PUSHs(sv_2mortal(newSVpv(buffer, 0))); |
| 4305 |
} |
| 4306 |
|
| 4307 |
int |
| 4308 |
i_tags_count(im) |
| 4309 |
Imager::ImgRaw im |
| 4310 |
CODE: |
| 4311 |
RETVAL = im->tags.count; |
| 4312 |
OUTPUT: |
| 4313 |
RETVAL |
| 4314 |
|
| 4315 |
|
| 4316 |
|
| 4317 |
MODULE = Imager PACKAGE = Imager::FillHandle PREFIX=IFILL_ |
| 4318 |
|
| 4319 |
void |
| 4320 |
IFILL_DESTROY(fill) |
| 4321 |
Imager::FillHandle fill |
| 4322 |
|
| 4323 |
int |
| 4324 |
IFILL_CLONE_SKIP(...) |
| 4325 |
CODE: |
| 4326 |
(void)items; /* avoid unused warning for XS variable */ |
| 4327 |
RETVAL = 1; |
| 4328 |
OUTPUT: |
| 4329 |
RETVAL |
| 4330 |
|
| 4331 |
MODULE = Imager PACKAGE = Imager |
| 4332 |
|
| 4333 |
Imager::FillHandle |
| 4334 |
i_new_fill_solid(cl, combine) |
| 4335 |
Imager::Color cl |
| 4336 |
int combine |
| 4337 |
|
| 4338 |
Imager::FillHandle |
| 4339 |
i_new_fill_solidf(cl, combine) |
| 4340 |
Imager::Color::Float cl |
| 4341 |
int combine |
| 4342 |
|
| 4343 |
Imager::FillHandle |
| 4344 |
i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch_sv, dx, dy) |
| 4345 |
Imager::Color fg |
| 4346 |
Imager::Color bg |
| 4347 |
int combine |
| 4348 |
int hatch |
| 4349 |
SV *cust_hatch_sv |
| 4350 |
i_img_dim dx |
| 4351 |
i_img_dim dy |
| 4352 |
PREINIT: |
| 4353 |
unsigned char *cust_hatch; |
| 4354 |
STRLEN len; |
| 4355 |
CODE: |
| 4356 |
SvGETMAGIC(cust_hatch_sv); |
| 4357 |
if (SvOK(cust_hatch_sv)) { |
| 4358 |
cust_hatch = (unsigned char *)SvPV_nomg(cust_hatch_sv, len); |
| 4359 |
} |
| 4360 |
else |
| 4361 |
cust_hatch = NULL; |
| 4362 |
RETVAL = i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy); |
| 4363 |
OUTPUT: |
| 4364 |
RETVAL |
| 4365 |
|
| 4366 |
Imager::FillHandle |
| 4367 |
i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch_sv, dx, dy) |
| 4368 |
Imager::Color::Float fg |
| 4369 |
Imager::Color::Float bg |
| 4370 |
int combine |
| 4371 |
int hatch |
| 4372 |
SV *cust_hatch_sv |
| 4373 |
i_img_dim dx |
| 4374 |
i_img_dim dy |
| 4375 |
PREINIT: |
| 4376 |
unsigned char *cust_hatch; |
| 4377 |
STRLEN len; |
| 4378 |
CODE: |
| 4379 |
SvGETMAGIC(cust_hatch_sv); |
| 4380 |
if (SvOK(cust_hatch_sv)) { |
| 4381 |
cust_hatch = (unsigned char *)SvPV(cust_hatch_sv, len); |
| 4382 |
} |
| 4383 |
else |
| 4384 |
cust_hatch = NULL; |
| 4385 |
RETVAL = i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy); |
| 4386 |
OUTPUT: |
| 4387 |
RETVAL |
| 4388 |
|
| 4389 |
Imager::FillHandle |
| 4390 |
i_new_fill_image(src, matrix_sv, xoff, yoff, combine) |
| 4391 |
Imager::ImgRaw src |
| 4392 |
SV *matrix_sv |
| 4393 |
i_img_dim xoff |
| 4394 |
i_img_dim yoff |
| 4395 |
int combine |
| 4396 |
PREINIT: |
| 4397 |
double matrix[9]; |
| 4398 |
double *matrixp; |
| 4399 |
AV *av; |
| 4400 |
IV len; |
| 4401 |
SV *sv1; |
| 4402 |
int i; |
| 4403 |
CODE: |
| 4404 |
SvGETMAGIC(matrix_sv); |
| 4405 |
if (!SvOK(matrix_sv)) { |
| 4406 |
matrixp = NULL; |
| 4407 |
} |
| 4408 |
else { |
| 4409 |
if (!SvROK(matrix_sv) || SvTYPE(SvRV(matrix_sv)) != SVt_PVAV) |
| 4410 |
croak("i_new_fill_image: matrix parameter must be an arrayref or undef"); |
| 4411 |
av=(AV*)SvRV(matrix_sv); |
| 4412 |
len=av_len(av)+1; |
| 4413 |
if (len > 9) |
| 4414 |
len = 9; |
| 4415 |
for (i = 0; i < len; ++i) { |
| 4416 |
sv1=(*(av_fetch(av,i,0))); |
| 4417 |
matrix[i] = SvNV(sv1); |
| 4418 |
} |
| 4419 |
for (; i < 9; ++i) |
| 4420 |
matrix[i] = 0; |
| 4421 |
matrixp = matrix; |
| 4422 |
} |
| 4423 |
RETVAL = i_new_fill_image(src, matrixp, xoff, yoff, combine); |
| 4424 |
OUTPUT: |
| 4425 |
RETVAL |
| 4426 |
|
| 4427 |
MODULE = Imager PACKAGE = Imager::Internal::Hlines PREFIX=i_int_hlines_ |
| 4428 |
|
| 4429 |
# this class is only exposed for testing |
| 4430 |
|
| 4431 |
int |
| 4432 |
i_int_hlines_testing() |
| 4433 |
|
| 4434 |
#if i_int_hlines_testing() |
| 4435 |
|
| 4436 |
Imager::Internal::Hlines |
| 4437 |
i_int_hlines_new(start_y, count_y, start_x, count_x) |
| 4438 |
i_img_dim start_y |
| 4439 |
int count_y |
| 4440 |
i_img_dim start_x |
| 4441 |
int count_x |
| 4442 |
|
| 4443 |
Imager::Internal::Hlines |
| 4444 |
i_int_hlines_new_img(im) |
| 4445 |
Imager::ImgRaw im |
| 4446 |
|
| 4447 |
void |
| 4448 |
i_int_hlines_add(hlines, y, minx, width) |
| 4449 |
Imager::Internal::Hlines hlines |
| 4450 |
i_img_dim y |
| 4451 |
i_img_dim minx |
| 4452 |
i_img_dim width |
| 4453 |
|
| 4454 |
void |
| 4455 |
i_int_hlines_DESTROY(hlines) |
| 4456 |
Imager::Internal::Hlines hlines |
| 4457 |
|
| 4458 |
SV * |
| 4459 |
i_int_hlines_dump(hlines) |
| 4460 |
Imager::Internal::Hlines hlines |
| 4461 |
|
| 4462 |
int |
| 4463 |
i_int_hlines_CLONE_SKIP(cls) |
| 4464 |
|
| 4465 |
#endif |
| 4466 |
|
| 4467 |
MODULE = Imager PACKAGE = Imager::TrimColorList PREFIX=trim_color_list_ |
| 4468 |
|
| 4469 |
Imager::TrimColorList |
| 4470 |
trim_color_list__new(cls) |
| 4471 |
C_ARGS: |
| 4472 |
|
| 4473 |
int |
| 4474 |
trim_color_list_add_color(Imager::TrimColorList t, Imager::Color c1, Imager::Color c2) |
| 4475 |
|
| 4476 |
int |
| 4477 |
trim_color_list_add_fcolor(Imager::TrimColorList t, Imager::Color::Float c1, Imager::Color::Float c2) |
| 4478 |
|
| 4479 |
SV * |
| 4480 |
trim_color_list_get(Imager::TrimColorList t, IV i) |
| 4481 |
|
| 4482 |
IV |
| 4483 |
trim_color_list_count(Imager::TrimColorList t) |
| 4484 |
|
| 4485 |
MODULE = Imager PACKAGE = Imager::Context PREFIX=im_context_ |
| 4486 |
|
| 4487 |
void |
| 4488 |
im_context_DESTROY(ctx) |
| 4489 |
Imager::Context ctx |
| 4490 |
|
| 4491 |
#ifdef PERL_IMPLICIT_CONTEXT |
| 4492 |
|
| 4493 |
void |
| 4494 |
im_context_CLONE(...) |
| 4495 |
CODE: |
| 4496 |
MY_CXT_CLONE; |
| 4497 |
(void)items; |
| 4498 |
/* the following sv_setref_pv() will free this inc */ |
| 4499 |
im_context_refinc(MY_CXT.ctx, "CLONE"); |
| 4500 |
MY_CXT.ctx = im_context_clone(MY_CXT.ctx, "CLONE"); |
| 4501 |
if (MY_CXT.ctx == NULL) { |
| 4502 |
croak("Failed to clone Imager context"); |
| 4503 |
} |
| 4504 |
sv_setref_pv(get_sv("Imager::_context", GV_ADD), "Imager::Context", MY_CXT.ctx); |
| 4505 |
|
| 4506 |
#endif |
| 4507 |
|
| 4508 |
BOOT: |
| 4509 |
PERL_SET_GLOBAL_CALLBACKS; |
| 4510 |
PERL_PL_SET_GLOBAL_CALLBACKS; |
| 4511 |
#ifdef PERL_IMPLICIT_CONTEXT |
| 4512 |
{ |
| 4513 |
MY_CXT_INIT; |
| 4514 |
(void)MY_CXT; |
| 4515 |
} |
| 4516 |
#endif |
| 4517 |
start_context(aTHX); |
| 4518 |
im_get_context = perl_get_context; |
| 4519 |
#ifdef HAVE_LIBTT |
| 4520 |
i_tt_start(); |
| 4521 |
#endif |
| 4522 |
|