1 #define PERL_NO_GET_CONTEXT
8 #define NEED_newRV_noinc
9 #define NEED_sv_2pv_nolen
10 #define NEED_sv_2pvbyte
16 #define i_int_hlines_testing() 1
23 #include "imextpltypes.h"
26 #if i_int_hlines_testing()
34 Allocate memory that will be discarded when mortals are discarded.
39 malloc_temp(pTHX_ size_t size) {
40 SV *sv = sv_2mortal(newSV(size));
45 /* These functions are all shared - then comes platform dependant code */
46 static int getstr(void *hv_t,char *key,char **store) {
51 mm_log((1,"getstr(hv_t %p, key %s, store %p)\n",hv_t,key,store));
53 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
55 svpp=hv_fetch(hv, key, strlen(key), 0);
56 *store=SvPV(*svpp, PL_na );
61 static int getint(void *hv_t,char *key,int *store) {
66 mm_log((1,"getint(hv_t %p, key %s, store %p)\n",hv_t,key,store));
68 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
70 svpp=hv_fetch(hv, key, strlen(key), 0);
71 *store=(int)SvIV(*svpp);
75 static int getdouble(void *hv_t,char* key,double *store) {
80 mm_log((1,"getdouble(hv_t %p, key %s, store %p)\n",hv_t,key,store));
82 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
83 svpp=hv_fetch(hv, key, strlen(key), 0);
84 *store=(double)SvNV(*svpp);
88 static int getvoid(void *hv_t,char* key,void **store) {
93 mm_log((1,"getvoid(hv_t %p, key %s, store %p)\n",hv_t,key,store));
95 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
97 svpp=hv_fetch(hv, key, strlen(key), 0);
98 *store = INT2PTR(void*, SvIV(*svpp));
103 static int getobj(void *hv_t,char *key,char *type,void **store) {
108 mm_log((1,"getobj(hv_t %p, key %s,type %s, store %p)\n",hv_t,key,type,store));
110 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
112 svpp=hv_fetch(hv, key, strlen(key), 0);
114 if (sv_derived_from(*svpp,type)) {
115 IV tmp = SvIV((SV*)SvRV(*svpp));
116 *store = INT2PTR(void*, tmp);
118 mm_log((1,"getobj: key exists in hash but is not of correct type"));
125 UTIL_table_t i_UTIL_table={getstr,getint,getdouble,getvoid,getobj};
127 void my_SvREFCNT_dec(void *p) {
129 SvREFCNT_dec((SV*)p);
134 i_log_entry(char *string, int level) {
135 mm_log((level, "%s", string));
139 make_i_color_sv(pTHX_ const i_color *c) {
141 i_color *col = mymalloc(sizeof(i_color));
144 sv_setref_pv(sv, "Imager::Color", (void *)col);
149 #define CBDATA_BUFSIZE 8192
152 /* the SVs we use to call back to Perl */
160 call_reader(struct cbdata *cbd, void *buf, size_t size,
168 if (!SvOK(cbd->readcb))
175 PUSHs(sv_2mortal(newSViv(size)));
176 PUSHs(sv_2mortal(newSViv(maxread)));
179 count = perl_call_sv(cbd->readcb, G_SCALAR);
184 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
190 char *ptr = SvPVbyte(data, len);
192 croak("Too much data returned in reader callback (wanted %d, got %d, expected %d)",
193 (int)size, (int)len, (int)maxread);
195 memcpy(buf, ptr, len);
210 io_seeker(void *p, off_t offset, int whence) {
212 struct cbdata *cbd = p;
217 if (!SvOK(cbd->seekcb))
224 PUSHs(sv_2mortal(newSViv(offset)));
225 PUSHs(sv_2mortal(newSViv(whence)));
228 count = perl_call_sv(cbd->seekcb, G_SCALAR);
233 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
245 io_writer(void *p, void const *data, size_t size) {
247 struct cbdata *cbd = p;
253 if (!SvOK(cbd->writecb))
260 PUSHs(sv_2mortal(newSVpv((char *)data, size)));
263 count = perl_call_sv(cbd->writecb, G_SCALAR);
267 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
270 success = SvTRUE(sv);
277 return success ? size : -1;
281 io_reader(void *p, void *data, size_t size) {
282 struct cbdata *cbd = p;
284 return call_reader(cbd, data, size, size);
287 static int io_closer(void *p) {
289 struct cbdata *cbd = p;
292 if (SvOK(cbd->closecb)) {
302 count = perl_call_sv(cbd->closecb, G_SCALAR);
307 success = SvTRUE(sv);
314 return success ? 0 : -1;
317 static void io_destroyer(void *p) {
319 struct cbdata *cbd = p;
321 SvREFCNT_dec(cbd->writecb);
322 SvREFCNT_dec(cbd->readcb);
323 SvREFCNT_dec(cbd->seekcb);
324 SvREFCNT_dec(cbd->closecb);
329 do_io_new_buffer(pTHX_ SV *data_sv) {
333 data = SvPVbyte(data_sv, length);
334 SvREFCNT_inc(data_sv);
335 return io_new_buffer(data, length, my_SvREFCNT_dec, data_sv);
339 do_io_new_cb(pTHX_ SV *writecb, SV *readcb, SV *seekcb, SV *closecb) {
342 cbd = mymalloc(sizeof(struct cbdata));
343 cbd->writecb = newSVsv(writecb);
344 cbd->readcb = newSVsv(readcb);
345 cbd->seekcb = newSVsv(seekcb);
346 cbd->closecb = newSVsv(closecb);
348 return io_new_cb(cbd, io_reader, io_writer, io_seeker, io_closer,
356 static int lookup_name(struct value_name *names, int count, char *name, int def_value)
359 for (i = 0; i < count; ++i)
360 if (strEQ(names[i].name, name))
361 return names[i].value;
365 static struct value_name transp_names[] =
368 { "threshold", tr_threshold },
369 { "errdiff", tr_errdiff },
370 { "ordered", tr_ordered, },
373 static struct value_name make_color_names[] =
375 { "none", mc_none, },
376 { "webmap", mc_web_map, },
377 { "addi", mc_addi, },
378 { "mediancut", mc_median_cut, },
379 { "mono", mc_mono, },
380 { "monochrome", mc_mono, },
381 { "gray", mc_gray, },
382 { "gray4", mc_gray4, },
383 { "gray16", mc_gray16, },
386 static struct value_name translate_names[] =
388 { "giflib", pt_giflib, },
389 { "closest", pt_closest, },
390 { "perturb", pt_perturb, },
391 { "errdiff", pt_errdiff, },
394 static struct value_name errdiff_names[] =
396 { "floyd", ed_floyd, },
397 { "jarvis", ed_jarvis, },
398 { "stucki", ed_stucki, },
399 { "custom", ed_custom, },
402 static struct value_name orddith_names[] =
404 { "random", od_random, },
405 { "dot8", od_dot8, },
406 { "dot4", od_dot4, },
407 { "hline", od_hline, },
408 { "vline", od_vline, },
409 { "/line", od_slashline, },
410 { "slashline", od_slashline, },
411 { "\\line", od_backline, },
412 { "backline", od_backline, },
413 { "tiny", od_tiny, },
414 { "custom", od_custom, },
417 /* look through the hash for quantization options */
419 ip_handle_quant_opts(pTHX_ i_quantize *quant, HV *hv)
421 /*** POSSIBLY BROKEN: do I need to unref the SV from hv_fetch ***/
427 quant->mc_colors = mymalloc(quant->mc_size * sizeof(i_color));
429 sv = hv_fetch(hv, "transp", 6, 0);
430 if (sv && *sv && (str = SvPV(*sv, len))) {
432 lookup_name(transp_names, sizeof(transp_names)/sizeof(*transp_names),
434 if (quant->transp != tr_none) {
435 quant->tr_threshold = 127;
436 sv = hv_fetch(hv, "tr_threshold", 12, 0);
438 quant->tr_threshold = SvIV(*sv);
440 if (quant->transp == tr_errdiff) {
441 sv = hv_fetch(hv, "tr_errdiff", 10, 0);
442 if (sv && *sv && (str = SvPV(*sv, len)))
443 quant->tr_errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
445 if (quant->transp == tr_ordered) {
446 quant->tr_orddith = od_tiny;
447 sv = hv_fetch(hv, "tr_orddith", 10, 0);
448 if (sv && *sv && (str = SvPV(*sv, len)))
449 quant->tr_orddith = lookup_name(orddith_names, sizeof(orddith_names)/sizeof(*orddith_names), str, od_random);
451 if (quant->tr_orddith == od_custom) {
452 sv = hv_fetch(hv, "tr_map", 6, 0);
453 if (sv && *sv && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
454 AV *av = (AV*)SvRV(*sv);
455 len = av_len(av) + 1;
456 if (len > sizeof(quant->tr_custom))
457 len = sizeof(quant->tr_custom);
458 for (i = 0; i < len; ++i) {
459 SV **sv2 = av_fetch(av, i, 0);
461 quant->tr_custom[i] = SvIV(*sv2);
464 while (i < sizeof(quant->tr_custom))
465 quant->tr_custom[i++] = 0;
470 quant->make_colors = mc_median_cut;
471 sv = hv_fetch(hv, "make_colors", 11, 0);
472 if (sv && *sv && (str = SvPV(*sv, len))) {
474 lookup_name(make_color_names, sizeof(make_color_names)/sizeof(*make_color_names), str, mc_median_cut);
476 sv = hv_fetch(hv, "colors", 6, 0);
477 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
478 /* needs to be an array of Imager::Color
479 note that the caller allocates the mc_color array and sets mc_size
481 AV *av = (AV *)SvRV(*sv);
482 quant->mc_count = av_len(av)+1;
483 if (quant->mc_count > quant->mc_size)
484 quant->mc_count = quant->mc_size;
485 for (i = 0; i < quant->mc_count; ++i) {
486 SV **sv1 = av_fetch(av, i, 0);
487 if (sv1 && *sv1 && SvROK(*sv1) && sv_derived_from(*sv1, "Imager::Color")) {
488 i_color *col = INT2PTR(i_color *, SvIV((SV*)SvRV(*sv1)));
489 quant->mc_colors[i] = *col;
493 sv = hv_fetch(hv, "max_colors", 10, 0);
496 if (i <= quant->mc_size && i >= quant->mc_count)
500 quant->translate = pt_closest;
501 sv = hv_fetch(hv, "translate", 9, 0);
502 if (sv && *sv && (str = SvPV(*sv, len))) {
503 quant->translate = lookup_name(translate_names, sizeof(translate_names)/sizeof(*translate_names), str, pt_closest);
505 sv = hv_fetch(hv, "errdiff", 7, 0);
506 if (sv && *sv && (str = SvPV(*sv, len))) {
507 quant->errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
509 if (quant->translate == pt_errdiff && quant->errdiff == ed_custom) {
510 /* get the error diffusion map */
511 sv = hv_fetch(hv, "errdiff_width", 13, 0);
513 quant->ed_width = SvIV(*sv);
514 sv = hv_fetch(hv, "errdiff_height", 14, 0);
516 quant->ed_height = SvIV(*sv);
517 sv = hv_fetch(hv, "errdiff_orig", 12, 0);
519 quant->ed_orig = SvIV(*sv);
520 if (quant->ed_width > 0 && quant->ed_height > 0) {
522 quant->ed_map = mymalloc(sizeof(int)*quant->ed_width*quant->ed_height);
523 sv = hv_fetch(hv, "errdiff_map", 11, 0);
524 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
525 AV *av = (AV*)SvRV(*sv);
526 len = av_len(av) + 1;
527 if (len > quant->ed_width * quant->ed_height)
528 len = quant->ed_width * quant->ed_height;
529 for (i = 0; i < len; ++i) {
530 SV **sv2 = av_fetch(av, i, 0);
532 quant->ed_map[i] = SvIV(*sv2);
533 sum += quant->ed_map[i];
539 myfree(quant->ed_map);
541 quant->errdiff = ed_floyd;
545 sv = hv_fetch(hv, "perturb", 7, 0);
547 quant->perturb = SvIV(*sv);
551 ip_cleanup_quant_opts(pTHX_ i_quantize *quant) {
552 myfree(quant->mc_colors);
554 myfree(quant->ed_map);
557 /* copies the color map from the hv into the colors member of the HV */
559 ip_copy_colors_back(pTHX_ HV *hv, i_quantize *quant) {
565 sv = hv_fetch(hv, "colors", 6, 0);
566 if (!sv || !*sv || !SvROK(*sv) || SvTYPE(SvRV(*sv)) != SVt_PVAV) {
571 av = (AV *)SvRV(*sv);
573 av_extend(av, quant->mc_count+1);
574 for (i = 0; i < quant->mc_count; ++i) {
575 i_color *in = quant->mc_colors+i;
576 Imager__Color c = ICL_new_internal(in->rgb.r, in->rgb.g, in->rgb.b, 255);
577 work = sv_newmortal();
578 sv_setref_pv(work, "Imager::Color", (void *)c);
584 /* loads the segments of a fountain fill into an array */
585 static i_fountain_seg *
586 load_fount_segs(pTHX_ AV *asegs, int *count) {
587 /* Each element of segs must contain:
588 [ start, middle, end, c0, c1, segtype, colortrans ]
589 start, middle, end are doubles from 0 to 1
590 c0, c1 are Imager::Color::Float or Imager::Color objects
591 segtype, colortrans are ints
595 i_fountain_seg *segs;
599 *count = av_len(asegs)+1;
601 croak("i_fountain must have at least one segment");
602 segs = mymalloc(sizeof(i_fountain_seg) * *count);
603 for(i = 0; i < *count; i++) {
604 SV **sv1 = av_fetch(asegs, i, 0);
605 if (!sv1 || !*sv1 || !SvROK(*sv1)
606 || SvTYPE(SvRV(*sv1)) != SVt_PVAV) {
608 croak("i_fountain: segs must be an arrayref of arrayrefs");
610 aseg = (AV *)SvRV(*sv1);
611 if (av_len(aseg) != 7-1) {
613 croak("i_fountain: a segment must have 7 members");
615 for (j = 0; j < 3; ++j) {
616 SV **sv2 = av_fetch(aseg, j, 0);
619 croak("i_fountain: XS error");
621 work[j] = SvNV(*sv2);
623 segs[i].start = work[0];
624 segs[i].middle = work[1];
625 segs[i].end = work[2];
626 for (j = 0; j < 2; ++j) {
627 SV **sv3 = av_fetch(aseg, 3+j, 0);
628 if (!sv3 || !*sv3 || !SvROK(*sv3) ||
629 (!sv_derived_from(*sv3, "Imager::Color")
630 && !sv_derived_from(*sv3, "Imager::Color::Float"))) {
632 croak("i_fountain: segs must contain colors in elements 3 and 4");
634 if (sv_derived_from(*sv3, "Imager::Color::Float")) {
635 segs[i].c[j] = *INT2PTR(i_fcolor *, SvIV((SV *)SvRV(*sv3)));
638 i_color c = *INT2PTR(i_color *, SvIV((SV *)SvRV(*sv3)));
640 for (ch = 0; ch < MAXCHANNELS; ++ch) {
641 segs[i].c[j].channel[ch] = c.channel[ch] / 255.0;
645 for (j = 0; j < 2; ++j) {
646 SV **sv2 = av_fetch(aseg, j+5, 0);
649 croak("i_fountain: XS error");
651 worki[j] = SvIV(*sv2);
653 segs[i].type = worki[0];
654 segs[i].color = worki[1];
660 /* validates the indexes supplied to i_ppal
662 i_ppal() doesn't do that for speed, but I'm not comfortable doing that
667 validate_i_ppal(i_img *im, i_palidx const *indexes, int count) {
668 int color_count = i_colorcount(im);
671 if (color_count == -1)
672 croak("i_plin() called on direct color image");
674 for (i = 0; i < count; ++i) {
675 if (indexes[i] >= color_count) {
676 croak("i_plin() called with out of range color index %d (max %d)",
677 indexes[i], color_count-1);
683 /* I don't think ICLF_* names belong at the C interface
684 this makes the XS code think we have them, to let us avoid
685 putting function bodies in the XS code
687 #define ICLF_new_internal(r, g, b, a) i_fcolor_new((r), (g), (b), (a))
688 #define ICLF_DESTROY(cl) i_fcolor_destroy(cl)
691 #define i_log_enabled() 1
693 #define i_log_enabled() 0
696 #if i_int_hlines_testing()
698 typedef i_int_hlines *Imager__Internal__Hlines;
700 static i_int_hlines *
701 i_int_hlines_new(i_img_dim start_y, i_img_dim count_y, i_img_dim start_x, i_img_dim count_x) {
702 i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
703 i_int_init_hlines(result, start_y, count_y, start_x, count_x);
708 static i_int_hlines *
709 i_int_hlines_new_img(i_img *im) {
710 i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
711 i_int_init_hlines_img(result, im);
717 i_int_hlines_DESTROY(i_int_hlines *hlines) {
718 i_int_hlines_destroy(hlines);
722 #define i_int_hlines_CLONE_SKIP(cls) 1
724 static int seg_compare(const void *vleft, const void *vright) {
725 const i_int_hline_seg *left = vleft;
726 const i_int_hline_seg *right = vright;
728 return left->minx - right->minx;
732 i_int_hlines_dump(i_int_hlines *hlines) {
734 SV *dump = newSVpvf("start_y: %" i_DF " limit_y: %" i_DF " start_x: %" i_DF " limit_x: %" i_DF"\n",
735 i_DFc(hlines->start_y), i_DFc(hlines->limit_y), i_DFc(hlines->start_x), i_DFc(hlines->limit_x));
738 for (y = hlines->start_y; y < hlines->limit_y; ++y) {
739 i_int_hline_entry *entry = hlines->entries[y-hlines->start_y];
742 /* sort the segments, if any */
744 qsort(entry->segs, entry->count, sizeof(i_int_hline_seg), seg_compare);
746 sv_catpvf(dump, " %" i_DF " (%" i_DF "):", i_DFc(y), i_DFc(entry->count));
747 for (i = 0; i < entry->count; ++i) {
748 sv_catpvf(dump, " [%" i_DF ", %" i_DF ")", i_DFc(entry->segs[i].minx),
749 i_DFc(entry->segs[i].x_limit));
751 sv_catpv(dump, "\n");
761 i_sv_off_t(pTHX_ SV *sv) {
762 #if LSEEKSIZE > IVSIZE
763 return (off_t)SvNV(sv);
765 return (off_t)SvIV(sv);
770 i_new_sv_off_t(pTHX_ off_t off) {
771 #if LSEEKSIZE > IVSIZE
778 static im_pl_ext_funcs im_perl_funcs =
780 IMAGER_PL_API_VERSION,
782 ip_handle_quant_opts,
783 ip_cleanup_quant_opts,
787 #define PERL_PL_SET_GLOBAL_CALLBACKS \
788 sv_setiv(get_sv(PERL_PL_FUNCTION_TABLE_NAME, 1), PTR2IV(&im_perl_funcs));
791 #define i_exif_enabled() 1
793 #define i_exif_enabled() 0
796 /* trying to use more C style names, map them here */
797 #define i_io_DESTROY(ig) io_glue_destroy(ig)
799 #define i_img_get_width(im) ((im)->xsize)
800 #define i_img_get_height(im) ((im)->ysize)
802 #define i_img_epsilonf() (DBL_EPSILON * 4)
804 /* avoid some xsubpp strangeness */
807 MODULE = Imager PACKAGE = Imager::Color PREFIX = ICL_
810 ICL_new_internal(r,g,b,a)
822 ICL_set_internal(cl,r,g,b,a)
829 ICL_set_internal(cl, r, g, b, a);
843 PUSHs(sv_2mortal(newSVnv(cl->rgba.r)));
844 PUSHs(sv_2mortal(newSVnv(cl->rgba.g)));
845 PUSHs(sv_2mortal(newSVnv(cl->rgba.b)));
846 PUSHs(sv_2mortal(newSVnv(cl->rgba.a)));
852 RETVAL = mymalloc(sizeof(i_color));
854 i_hsv_to_rgb(RETVAL);
862 RETVAL = mymalloc(sizeof(i_color));
864 i_rgb_to_hsv(RETVAL);
870 MODULE = Imager PACKAGE = Imager::Color::Float PREFIX=ICLF_
873 ICLF_new_internal(r, g, b, a)
881 Imager::Color::Float cl
885 Imager::Color::Float cl
889 EXTEND(SP, MAXCHANNELS);
890 for (ch = 0; ch < MAXCHANNELS; ++ch) {
891 /* printf("%d: %g\n", ch, cl->channel[ch]); */
892 PUSHs(sv_2mortal(newSVnv(cl->channel[ch])));
896 ICLF_set_internal(cl,r,g,b,a)
897 Imager::Color::Float cl
912 Imager::Color::Float c
914 RETVAL = mymalloc(sizeof(i_fcolor));
916 i_hsv_to_rgbf(RETVAL);
922 Imager::Color::Float c
924 RETVAL = mymalloc(sizeof(i_fcolor));
926 i_rgb_to_hsvf(RETVAL);
930 MODULE = Imager PACKAGE = Imager::ImgRaw PREFIX = IIM_
944 MODULE = Imager PACKAGE = Imager
958 io_new_buffer(data_sv)
961 RETVAL = do_io_new_buffer(aTHX_ data_sv);
966 io_new_cb(writecb, readcb, seekcb, closecb, maxwrite = CBDATA_BUFSIZE)
973 RETVAL = do_io_new_cb(aTHX_ writecb, readcb, seekcb, closecb);
985 tlength = io_slurp(ig, &data);
986 RETVAL = newSVpv((char *)data,tlength);
993 i_set_image_file_limits(width, height, bytes)
999 i_get_image_file_limits()
1001 i_img_dim width, height;
1004 if (i_get_image_file_limits(&width, &height, &bytes)) {
1006 PUSHs(sv_2mortal(newSViv(width)));
1007 PUSHs(sv_2mortal(newSViv(height)));
1008 PUSHs(sv_2mortal(newSVuv(bytes)));
1011 MODULE = Imager PACKAGE = Imager::IO PREFIX = io_
1014 io_new_fd(class, fd)
1017 RETVAL = io_new_fd(fd);
1022 io_new_buffer(class, data_sv)
1025 RETVAL = do_io_new_buffer(aTHX_ data_sv);
1030 io_new_cb(class, writecb, readcb, seekcb, closecb)
1036 RETVAL = do_io_new_cb(aTHX_ writecb, readcb, seekcb, closecb);
1041 io_new_bufchain(class)
1043 RETVAL = io_new_bufchain();
1051 unsigned char* data;
1055 tlength = io_slurp(ig, &data);
1056 RETVAL = newSVpv((char *)data,tlength);
1061 MODULE = Imager PACKAGE = Imager::IO PREFIX = i_io_
1064 i_io_raw_write(ig, data_sv)
1072 if (SvUTF8(data_sv)) {
1073 data_sv = sv_2mortal(newSVsv(data_sv));
1074 /* yes, we want this to croak() if the SV can't be downgraded */
1075 sv_utf8_downgrade(data_sv, FALSE);
1078 data = SvPV(data_sv, size);
1079 RETVAL = i_io_raw_write(ig, data, size);
1084 i_io_raw_read(ig, buffer_sv, size)
1093 croak("size negative in call to i_io_raw_read()");
1094 /* prevent an undefined value warning if they supplied an
1096 Orginally conditional on !SvOK(), but this will prevent the
1097 downgrade from croaking */
1098 sv_setpvn(buffer_sv, "", 0);
1100 if (SvUTF8(buffer_sv))
1101 sv_utf8_downgrade(buffer_sv, FALSE);
1103 buffer = SvGROW(buffer_sv, size+1);
1104 result = i_io_raw_read(ig, buffer, size);
1106 SvCUR_set(buffer_sv, result);
1107 *SvEND(buffer_sv) = '\0';
1108 SvPOK_only(buffer_sv);
1110 PUSHs(sv_2mortal(newSViv(result)));
1116 i_io_raw_read2(ig, size)
1125 croak("size negative in call to i_io_read2()");
1126 buffer_sv = newSV(size);
1127 buffer = SvGROW(buffer_sv, size+1);
1128 result = i_io_raw_read(ig, buffer, size);
1130 SvCUR_set(buffer_sv, result);
1131 *SvEND(buffer_sv) = '\0';
1132 SvPOK_only(buffer_sv);
1134 PUSHs(sv_2mortal(buffer_sv));
1138 SvREFCNT_dec(buffer_sv);
1142 i_io_raw_seek(ig, position, whence)
1156 i_io_CLONE_SKIP(...)
1158 (void)items; /* avoid unused warning for XS variable */
1185 i_io_seek(ig, off, whence)
1191 i_io_peekn(ig, size)
1199 buffer_sv = newSV(size+1);
1200 buffer = SvGROW(buffer_sv, size+1);
1201 result = i_io_peekn(ig, buffer, size);
1203 SvCUR_set(buffer_sv, result);
1204 *SvEND(buffer_sv) = '\0';
1205 SvPOK_only(buffer_sv);
1207 PUSHs(sv_2mortal(buffer_sv));
1211 SvREFCNT_dec(buffer_sv);
1215 i_io_read(ig, buffer_sv, size)
1224 croak("size negative in call to i_io_read()");
1225 /* prevent an undefined value warning if they supplied an
1227 Orginally conditional on !SvOK(), but this will prevent the
1228 downgrade from croaking */
1229 sv_setpvn(buffer_sv, "", 0);
1231 if (SvUTF8(buffer_sv))
1232 sv_utf8_downgrade(buffer_sv, FALSE);
1234 buffer = SvGROW(buffer_sv, size+1);
1235 result = i_io_read(ig, buffer, size);
1237 SvCUR_set(buffer_sv, result);
1238 *SvEND(buffer_sv) = '\0';
1239 SvPOK_only(buffer_sv);
1241 PUSHs(sv_2mortal(newSViv(result)));
1247 i_io_read2(ig, size)
1256 croak("size zero in call to read2()");
1257 buffer_sv = newSV(size);
1258 buffer = SvGROW(buffer_sv, size+1);
1259 result = i_io_read(ig, buffer, size);
1261 SvCUR_set(buffer_sv, result);
1262 *SvEND(buffer_sv) = '\0';
1263 SvPOK_only(buffer_sv);
1265 PUSHs(sv_2mortal(buffer_sv));
1269 SvREFCNT_dec(buffer_sv);
1273 i_io_gets(ig, size = 8192, eol = NEWLINE)
1283 croak("size too small in call to gets()");
1284 buffer_sv = sv_2mortal(newSV(size+1));
1285 buffer = SvPVX(buffer_sv);
1286 result = i_io_gets(ig, buffer, size+1, eol);
1288 SvCUR_set(buffer_sv, result);
1289 *SvEND(buffer_sv) = '\0';
1290 SvPOK_only(buffer_sv);
1296 i_io_write(ig, data_sv)
1304 if (SvUTF8(data_sv)) {
1305 data_sv = sv_2mortal(newSVsv(data_sv));
1306 /* yes, we want this to croak() if the SV can't be downgraded */
1307 sv_utf8_downgrade(data_sv, FALSE);
1310 data = SvPV(data_sv, size);
1311 RETVAL = i_io_write(ig, data, size);
1316 i_io_dump(ig, flags = I_IO_DUMP_DEFAULT)
1321 i_io_set_buffered(ig, flag = 1)
1326 i_io_is_buffered(ig)
1337 MODULE = Imager PACKAGE = Imager
1348 while( (item=i_format_list[i++]) != NULL ) {
1350 PUSHs(sv_2mortal(newSVpv(item,0)));
1363 i_img_empty_ch(im,x,y,ch)
1370 i_sametype(im, x, y)
1376 i_sametype_chans(im, x, y, channels)
1383 i_init_log(name_sv,level)
1387 const char *name = SvOK(name_sv) ? SvPV_nolen(name_sv) : NULL;
1389 RETVAL = i_init_log(name, level);
1394 i_log_entry(string,level)
1415 i_img_info(im,info);
1417 PUSHs(sv_2mortal(newSViv(info[0])));
1418 PUSHs(sv_2mortal(newSViv(info[1])));
1419 PUSHs(sv_2mortal(newSViv(info[2])));
1420 PUSHs(sv_2mortal(newSViv(info[3])));
1426 i_img_setmask(im,ch_mask)
1435 i_img_getchannels(im)
1444 sv_2mortal(newSVpv((char *)im->idata, im->bytes))
1452 i_img_get_height(im)
1457 i_img_is_monochrome(im)
1463 result = i_img_is_monochrome(im, &zero_is_white);
1465 if (GIMME_V == G_ARRAY) {
1468 PUSHs(sv_2mortal(newSViv(zero_is_white)));
1477 i_line(im,x1,y1,x2,y2,val,endp)
1487 i_line_aa(im,x1,y1,x2,y2,val,endp)
1497 i_box(im,x1,y1,x2,y2,val)
1506 i_box_filled(im,x1,y1,x2,y2,val)
1515 i_box_filledf(im,x1,y1,x2,y2,val)
1521 Imager::Color::Float val
1524 i_box_cfill(im,x1,y1,x2,y2,fill)
1530 Imager::FillHandle fill
1533 i_arc(im,x,y,rad,d1,d2,val)
1543 i_arc_aa(im,x,y,rad,d1,d2,val)
1553 i_arc_cfill(im,x,y,rad,d1,d2,fill)
1560 Imager::FillHandle fill
1563 i_arc_aa_cfill(im,x,y,rad,d1,d2,fill)
1570 Imager::FillHandle fill
1574 i_circle_aa(im,x,y,rad,val)
1582 i_circle_out(im,x,y,rad,val)
1590 i_circle_out_aa(im,x,y,rad,val)
1598 i_arc_out(im,x,y,rad,d1,d2,val)
1608 i_arc_out_aa(im,x,y,rad,d1,d2,val)
1619 i_bezier_multi(im,xc,yc,val)
1632 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_bezier_multi must be a reference to an array\n");
1633 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_bezier_multi must be a reference to an array\n");
1634 if (!SvROK(ST(2))) croak("Imager: Parameter 2 to i_bezier_multi must be a reference to an array\n");
1635 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 to i_bezier_multi must be a reference to an array\n");
1636 av1=(AV*)SvRV(ST(1));
1637 av2=(AV*)SvRV(ST(2));
1638 if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_bezier_multi must be equal length\n");
1640 x=mymalloc( len*sizeof(double) );
1641 y=mymalloc( len*sizeof(double) );
1642 for(i=0;i<len;i++) {
1643 sv1=(*(av_fetch(av1,i,0)));
1644 sv2=(*(av_fetch(av2,i,0)));
1645 x[i]=(double)SvNV(sv1);
1646 y[i]=(double)SvNV(sv2);
1648 i_bezier_multi(im,len,x,y,val);
1654 i_poly_aa(im,xc,yc,val)
1667 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1668 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1669 if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1670 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1671 av1=(AV*)SvRV(ST(1));
1672 av2=(AV*)SvRV(ST(2));
1673 if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_poly_aa must be equal length\n");
1675 x=mymalloc( len*sizeof(double) );
1676 y=mymalloc( len*sizeof(double) );
1677 for(i=0;i<len;i++) {
1678 sv1=(*(av_fetch(av1,i,0)));
1679 sv2=(*(av_fetch(av2,i,0)));
1680 x[i]=(double)SvNV(sv1);
1681 y[i]=(double)SvNV(sv2);
1683 RETVAL = i_poly_aa(im,len,x,y,val);
1690 i_poly_aa_cfill(im,xc,yc,fill)
1692 Imager::FillHandle fill
1702 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1703 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1704 if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1705 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1706 av1=(AV*)SvRV(ST(1));
1707 av2=(AV*)SvRV(ST(2));
1708 if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_poly_aa_cfill must be equal length\n");
1710 x=mymalloc( len*sizeof(double) );
1711 y=mymalloc( len*sizeof(double) );
1712 for(i=0;i<len;i++) {
1713 sv1=(*(av_fetch(av1,i,0)));
1714 sv2=(*(av_fetch(av2,i,0)));
1715 x[i]=(double)SvNV(sv1);
1716 y[i]=(double)SvNV(sv2);
1718 RETVAL = i_poly_aa_cfill(im,len,x,y,fill);
1727 i_flood_fill(im,seedx,seedy,dcol)
1734 i_flood_cfill(im,seedx,seedy,fill)
1738 Imager::FillHandle fill
1741 i_flood_fill_border(im,seedx,seedy,dcol, border)
1746 Imager::Color border
1749 i_flood_cfill_border(im,seedx,seedy,fill, border)
1753 Imager::FillHandle fill
1754 Imager::Color border
1758 i_copyto(im,src,x1,y1,x2,y2,tx,ty)
1770 i_copyto_trans(im,src,x1,y1,x2,y2,tx,ty,trans)
1787 i_rubthru(im,src,tx,ty,src_minx,src_miny,src_maxx,src_maxy)
1798 i_compose(out, src, out_left, out_top, src_left, src_top, width, height, combine = ic_normal, opacity = 0.0)
1811 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)
1827 i_combine(src_av, channels_av = NULL)
1831 i_img **imgs = NULL;
1833 int *channels = NULL;
1838 in_count = av_len(src_av) + 1;
1840 imgs = mymalloc(sizeof(i_img*) * in_count);
1841 channels = mymalloc(sizeof(int) * in_count);
1842 for (i = 0; i < in_count; ++i) {
1843 psv = av_fetch(src_av, i, 0);
1844 if (!psv || !*psv || !sv_derived_from(*psv, "Imager::ImgRaw")) {
1847 croak("imgs must contain only images");
1849 tmp = SvIV((SV*)SvRV(*psv));
1850 imgs[i] = INT2PTR(i_img*, tmp);
1852 (psv = av_fetch(channels_av, i, 0)) != NULL &&
1854 channels[i] = SvIV(*psv);
1861 RETVAL = i_combine(imgs, channels, in_count);
1868 i_flipxy(im, direction)
1873 i_rotate90(im, degrees)
1878 i_rotate_exact(im, amount, ...)
1882 i_color *backp = NULL;
1883 i_fcolor *fbackp = NULL;
1887 /* extract the bg colors if any */
1888 /* yes, this is kind of strange */
1889 for (i = 2; i < items; ++i) {
1891 if (sv_derived_from(sv1, "Imager::Color")) {
1892 IV tmp = SvIV((SV*)SvRV(sv1));
1893 backp = INT2PTR(i_color *, tmp);
1895 else if (sv_derived_from(sv1, "Imager::Color::Float")) {
1896 IV tmp = SvIV((SV*)SvRV(sv1));
1897 fbackp = INT2PTR(i_fcolor *, tmp);
1900 RETVAL = i_rotate_exact_bg(im, amount, backp, fbackp);
1905 i_matrix_transform(im, xsize, ysize, matrix, ...)
1915 i_color *backp = NULL;
1916 i_fcolor *fbackp = NULL;
1918 if (!SvROK(ST(3)) || SvTYPE(SvRV(ST(3))) != SVt_PVAV)
1919 croak("i_matrix_transform: parameter 4 must be an array ref\n");
1920 av=(AV*)SvRV(ST(3));
1924 for (i = 0; i < len; ++i) {
1925 sv1=(*(av_fetch(av,i,0)));
1926 matrix[i] = SvNV(sv1);
1930 /* extract the bg colors if any */
1931 /* yes, this is kind of strange */
1932 for (i = 4; i < items; ++i) {
1934 if (sv_derived_from(sv1, "Imager::Color")) {
1935 IV tmp = SvIV((SV*)SvRV(sv1));
1936 backp = INT2PTR(i_color *, tmp);
1938 else if (sv_derived_from(sv1, "Imager::Color::Float")) {
1939 IV tmp = SvIV((SV*)SvRV(sv1));
1940 fbackp = INT2PTR(i_fcolor *, tmp);
1943 RETVAL = i_matrix_transform_bg(im, xsize, ysize, matrix, backp, fbackp);
1948 i_gaussian(im,stdev)
1953 i_unsharp_mask(im,stdev,scale)
1968 len = av_len(coef) + 1;
1969 c_coef=mymalloc( len * sizeof(double) );
1970 for(i = 0; i < len; i++) {
1971 sv1 = (*(av_fetch(coef, i, 0)));
1972 c_coef[i] = (double)SvNV(sv1);
1974 RETVAL = i_conv(im, c_coef, len);
1980 i_convert(src, avmain)
1992 outchan = av_len(avmain)+1;
1993 /* find the biggest */
1995 for (j=0; j < outchan; ++j) {
1996 temp = av_fetch(avmain, j, 0);
1997 if (temp && SvROK(*temp) && SvTYPE(SvRV(*temp)) == SVt_PVAV) {
1998 avsub = (AV*)SvRV(*temp);
1999 len = av_len(avsub)+1;
2004 coeff = mymalloc(sizeof(double) * outchan * inchan);
2005 for (j = 0; j < outchan; ++j) {
2006 avsub = (AV*)SvRV(*av_fetch(avmain, j, 0));
2007 len = av_len(avsub)+1;
2008 for (i = 0; i < len; ++i) {
2009 temp = av_fetch(avsub, i, 0);
2011 coeff[i+j*inchan] = SvNV(*temp);
2013 coeff[i+j*inchan] = 0;
2016 coeff[i++ + j*inchan] = 0;
2018 RETVAL = i_convert(src, coeff, outchan, inchan);
2028 unsigned int mask = 0;
2034 unsigned char (*maps)[256];
2036 if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
2037 croak("i_map: parameter 2 must be an arrayref\n");
2038 avmain = (AV*)SvRV(ST(1));
2039 len = av_len(avmain)+1;
2040 if (im->channels < len) len = im->channels;
2042 maps = mymalloc( len * sizeof(unsigned char [256]) );
2044 for (j=0; j<len ; j++) {
2045 temp = av_fetch(avmain, j, 0);
2046 if (temp && SvROK(*temp) && (SvTYPE(SvRV(*temp)) == SVt_PVAV) ) {
2047 avsub = (AV*)SvRV(*temp);
2048 if(av_len(avsub) != 255) continue;
2050 for (i=0; i<256 ; i++) {
2052 temp = av_fetch(avsub, i, 0);
2053 val = temp ? SvIV(*temp) : 0;
2055 if (val>255) val = 255;
2060 i_map(im, maps, mask);
2071 i_img_diffd(im1,im2)
2076 i_img_samef(im1, im2, epsilon = i_img_epsilonf(), what=NULL)
2086 _is_color_object(sv)
2090 RETVAL = SvOK(sv) && SvROK(sv) &&
2091 (sv_derived_from(sv, "Imager::Color")
2092 || sv_derived_from(sv, "Imager::Color::Float"));
2104 MODULE = Imager PACKAGE = Imager::Font::TT PREFIX=TT_
2106 #define TT_DESTROY(handle) i_tt_destroy(handle)
2110 Imager::Font::TT handle
2115 (void)items; /* avoid unused warning */
2121 MODULE = Imager PACKAGE = Imager
2125 i_tt_text(handle,im,xb,yb,cl,points,str_sv,len_ignored,smooth,utf8,align=1)
2126 Imager::Font::TT handle
2144 str = SvPV(str_sv, len);
2145 RETVAL = i_tt_text(handle, im, xb, yb, cl, points, str,
2146 len, smooth, utf8, align);
2152 i_tt_cp(handle,im,xb,yb,channel,points,str_sv,len_ignored,smooth,utf8,align=1)
2153 Imager::Font::TT handle
2171 str = SvPV(str_sv, len);
2172 RETVAL = i_tt_cp(handle, im, xb, yb, channel, points, str, len,
2173 smooth, utf8, align);
2179 i_tt_bbox(handle,point,str_sv,len_ignored, utf8)
2180 Imager::Font::TT handle
2185 i_img_dim cords[BOUNDING_BOX_COUNT];
2195 str = SvPV(str_sv, len);
2196 if ((rc=i_tt_bbox(handle,point,str,len,cords, utf8))) {
2198 for (i = 0; i < rc; ++i) {
2199 PUSHs(sv_2mortal(newSViv(cords[i])));
2204 i_tt_has_chars(handle, text_sv, utf8)
2205 Imager::Font::TT handle
2216 if (SvUTF8(text_sv))
2219 text = SvPV(text_sv, len);
2220 work = mymalloc(len);
2221 count = i_tt_has_chars(handle, text, len, utf8, work);
2222 if (GIMME_V == G_ARRAY) {
2224 for (i = 0; i < count; ++i) {
2225 PUSHs(boolSV(work[i]));
2230 PUSHs(sv_2mortal(newSVpv(work, count)));
2235 i_tt_dump_names(handle)
2236 Imager::Font::TT handle
2239 i_tt_face_name(handle)
2240 Imager::Font::TT handle
2245 len = i_tt_face_name(handle, name, sizeof(name));
2248 PUSHs(sv_2mortal(newSVpv(name, len-1)));
2252 i_tt_glyph_name(handle, text_sv, utf8 = 0)
2253 Imager::Font::TT handle
2264 if (SvUTF8(text_sv))
2267 text = SvPV(text_sv, work_len);
2272 ch = i_utf8_advance(&text, &len);
2274 i_push_error(0, "invalid UTF8 character");
2283 if ((outsize = i_tt_glyph_name(handle, ch, name, sizeof(name))) != 0) {
2284 PUSHs(sv_2mortal(newSVpv(name, 0)));
2287 PUSHs(&PL_sv_undef);
2294 i_test_format_probe(ig, length)
2299 i_readpnm_wiol(ig, allow_incomplete)
2301 int allow_incomplete
2305 i_readpnm_multi_wiol(ig, allow_incomplete)
2307 int allow_incomplete
2313 imgs = i_readpnm_multi_wiol(ig, &count, allow_incomplete);
2316 for (i = 0; i < count; ++i) {
2317 SV *sv = sv_newmortal();
2318 sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
2325 i_writeppm_wiol(im, ig)
2334 i_readraw_wiol(ig,x,y,datachannels,storechannels,intrl)
2343 i_writeraw_wiol(im,ig)
2348 i_writebmp_wiol(im,ig)
2353 i_readbmp_wiol(ig, allow_incomplete=0)
2355 int allow_incomplete
2359 i_writetga_wiol(im,ig, wierdpack, compress, idstring)
2368 idlen = SvCUR(ST(4));
2369 RETVAL = i_writetga_wiol(im, ig, wierdpack, compress, idstring, idlen);
2375 i_readtga_wiol(ig, length)
2383 i_scaleaxis(im,Value,Axis)
2389 i_scale_nn(im,scx,scy)
2395 i_scale_mixing(im, width, height)
2405 i_count_colors(im,maxc)
2410 i_get_anonymous_color_histo(im, maxc = 0x40000000)
2415 unsigned int * col_usage = NULL;
2418 col_cnt = i_get_anonymous_color_histo(im, &col_usage, maxc);
2419 EXTEND(SP, col_cnt);
2420 for (i = 0; i < col_cnt; i++) {
2421 PUSHs(sv_2mortal(newSViv( col_usage[i])));
2428 i_transform(im,opx,opy,parm)
2442 if (!SvROK(ST(1))) croak("Imager: Parameter 1 must be a reference to an array\n");
2443 if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to an array\n");
2444 if (!SvROK(ST(3))) croak("Imager: Parameter 3 must be a reference to an array\n");
2445 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 must be a reference to an array\n");
2446 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 must be a reference to an array\n");
2447 if (SvTYPE(SvRV(ST(3))) != SVt_PVAV) croak("Imager: Parameter 3 must be a reference to an array\n");
2448 av=(AV*)SvRV(ST(1));
2450 opx=mymalloc( opxl*sizeof(int) );
2451 for(i=0;i<opxl;i++) {
2452 sv1=(*(av_fetch(av,i,0)));
2453 opx[i]=(int)SvIV(sv1);
2455 av=(AV*)SvRV(ST(2));
2457 opy=mymalloc( opyl*sizeof(int) );
2458 for(i=0;i<opyl;i++) {
2459 sv1=(*(av_fetch(av,i,0)));
2460 opy[i]=(int)SvIV(sv1);
2462 av=(AV*)SvRV(ST(3));
2463 parmlen=av_len(av)+1;
2464 parm=mymalloc( parmlen*sizeof(double) );
2465 for(i=0;i<parmlen;i++) { /* FIXME: Bug? */
2466 sv1=(*(av_fetch(av,i,0)));
2467 parm[i]=(double)SvNV(sv1);
2469 result=i_transform(im,opx,opxl,opy,opyl,parm,parmlen);
2474 SV *result_sv = sv_newmortal();
2476 sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result);
2481 i_transform2(sv_width,sv_height,channels,sv_ops,av_n_regs,av_c_regs,av_in_imgs)
2507 in_imgs_count = av_len(av_in_imgs)+1;
2508 for (i = 0; i < in_imgs_count; ++i) {
2509 sv1 = *av_fetch(av_in_imgs, i, 0);
2510 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2511 croak("sv_in_img must contain only images");
2514 if (in_imgs_count > 0) {
2515 in_imgs = mymalloc(in_imgs_count*sizeof(i_img*));
2516 for (i = 0; i < in_imgs_count; ++i) {
2517 sv1 = *av_fetch(av_in_imgs,i,0);
2518 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2519 croak("Parameter 5 must contain only images");
2521 tmp = SvIV((SV*)SvRV(sv1));
2522 in_imgs[i] = INT2PTR(i_img*, tmp);
2526 /* no input images */
2529 /* default the output size from the first input if possible */
2531 width = SvIV(sv_width);
2532 else if (in_imgs_count)
2533 width = in_imgs[0]->xsize;
2535 croak("No output image width supplied");
2537 if (SvOK(sv_height))
2538 height = SvIV(sv_height);
2539 else if (in_imgs_count)
2540 height = in_imgs[0]->ysize;
2542 croak("No output image height supplied");
2544 ops = (struct rm_op *)SvPV(sv_ops, ops_len);
2545 if (ops_len % sizeof(struct rm_op))
2546 croak("Imager: Parameter 3 must be a bitmap of regops\n");
2547 ops_count = ops_len / sizeof(struct rm_op);
2549 n_regs_count = av_len(av_n_regs)+1;
2550 n_regs = mymalloc(n_regs_count * sizeof(double));
2551 for (i = 0; i < n_regs_count; ++i) {
2552 sv1 = *av_fetch(av_n_regs,i,0);
2554 n_regs[i] = SvNV(sv1);
2556 c_regs_count = av_len(av_c_regs)+1;
2557 c_regs = mymalloc(c_regs_count * sizeof(i_color));
2558 /* I don't bother initializing the colou?r registers */
2560 result=i_transform2(width, height, channels, ops, ops_count,
2561 n_regs, n_regs_count,
2562 c_regs, c_regs_count, in_imgs, in_imgs_count);
2568 SV *result_sv = sv_newmortal();
2570 sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result);
2576 i_contrast(im,intensity)
2589 i_noise(im,amount,type)
2595 i_bumpmap(im,bump,channel,light_x,light_y,strength)
2605 i_bumpmap_complex(im,bump,channel,tx,ty,Lx,Ly,Lz,cd,cs,n,Ia,Il,Is)
2624 i_postlevels(im,levels)
2634 i_watermark(im,wmark,tx,ty,pixdiff)
2636 Imager::ImgRaw wmark
2643 i_autolevels(im,lsat,usat,skew)
2650 i_radnoise(im,xo,yo,rscale,ascale)
2658 i_turbnoise(im, xo, yo, scale)
2681 croak("Usage: i_gradgen(im, xo, yo, ival, dmeasure)");
2682 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2683 croak("i_gradgen: Second argument must be an array ref");
2684 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
2685 croak("i_gradgen: Third argument must be an array ref");
2686 if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
2687 croak("i_gradgen: Fourth argument must be an array ref");
2688 axx = (AV *)SvRV(ST(1));
2689 ayy = (AV *)SvRV(ST(2));
2690 ac = (AV *)SvRV(ST(3));
2691 dmeasure = (int)SvIV(ST(4));
2693 num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
2694 num = num <= av_len(ac) ? num : av_len(ac);
2696 if (num < 2) croak("Usage: i_gradgen array refs must have more than 1 entry each");
2697 xo = mymalloc( sizeof(i_img_dim) * num );
2698 yo = mymalloc( sizeof(i_img_dim) * num );
2699 ival = mymalloc( sizeof(i_color) * num );
2700 for(i = 0; i<num; i++) {
2701 xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0));
2702 yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0));
2703 sv = *av_fetch(ac, i, 0);
2704 if ( !sv_derived_from(sv, "Imager::Color") ) {
2705 free(axx); free(ayy); free(ac);
2706 croak("i_gradgen: Element of fourth argument is not derived from Imager::Color");
2708 ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
2710 i_gradgen(im, num, xo, yo, ival, dmeasure);
2716 i_diff_image(im, im2, mindist=0)
2722 i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2732 double ssample_param
2736 i_fountain_seg *segs;
2738 if (!SvROK(ST(10)) || ! SvTYPE(SvRV(ST(10))))
2739 croak("i_fountain: argument 11 must be an array ref");
2741 asegs = (AV *)SvRV(ST(10));
2742 segs = load_fount_segs(aTHX_ asegs, &count);
2743 RETVAL = i_fountain(im, xa, ya, xb, yb, type, repeat, combine,
2744 super_sample, ssample_param, count, segs);
2750 i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2759 double ssample_param
2763 i_fountain_seg *segs;
2765 if (!SvROK(ST(9)) || ! SvTYPE(SvRV(ST(9))))
2766 croak("i_fountain: argument 11 must be an array ref");
2768 asegs = (AV *)SvRV(ST(9));
2769 segs = load_fount_segs(aTHX_ asegs, &count);
2770 RETVAL = i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine,
2771 super_sample, ssample_param, count, segs);
2777 i_new_fill_opacity(other_fill, alpha_mult)
2778 Imager::FillHandle other_fill
2789 errors = i_errors();
2791 while (errors[i].msg) {
2793 sv = newSVpv(errors[i].msg, strlen(errors[i].msg));
2794 if (!av_store(av, 0, sv)) {
2797 sv = newSViv(errors[i].code);
2798 if (!av_store(av, 1, sv)) {
2801 PUSHs(sv_2mortal(newRV_noinc((SV*)av)));
2809 i_push_error(code, msg)
2814 i_nearest_color(im, ...)
2829 croak("Usage: i_nearest_color(im, xo, yo, ival, dmeasure)");
2830 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2831 croak("i_nearest_color: Second argument must be an array ref");
2832 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
2833 croak("i_nearest_color: Third argument must be an array ref");
2834 if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
2835 croak("i_nearest_color: Fourth argument must be an array ref");
2836 axx = (AV *)SvRV(ST(1));
2837 ayy = (AV *)SvRV(ST(2));
2838 ac = (AV *)SvRV(ST(3));
2839 dmeasure = (int)SvIV(ST(4));
2841 num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
2842 num = num <= av_len(ac) ? num : av_len(ac);
2844 if (num < 2) croak("Usage: i_nearest_color array refs must have more than 1 entry each");
2845 xo = mymalloc( sizeof(i_img_dim) * num );
2846 yo = mymalloc( sizeof(i_img_dim) * num );
2847 ival = mymalloc( sizeof(i_color) * num );
2848 for(i = 0; i<num; i++) {
2849 xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0));
2850 yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0));
2851 sv = *av_fetch(ac, i, 0);
2852 if ( !sv_derived_from(sv, "Imager::Color") ) {
2853 free(axx); free(ayy); free(ac);
2854 croak("i_nearest_color: Element of fourth argument is not derived from Imager::Color");
2856 ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
2858 RETVAL = i_nearest_color(im, num, xo, yo, ival, dmeasure);
2872 rc=DSO_open(filename,&evstr);
2876 PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
2877 PUSHs(sv_2mortal(newSVpvn(evstr, strlen(evstr))));
2880 PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
2886 DSO_close(dso_handle)
2890 DSO_funclist(dso_handle_v)
2894 DSO_handle *dso_handle;
2895 func_ptr *functions;
2897 dso_handle=(DSO_handle*)dso_handle_v;
2898 functions = DSO_funclist(dso_handle);
2900 while( functions[i].name != NULL) {
2902 PUSHs(sv_2mortal(newSVpv(functions[i].name,0)));
2904 PUSHs(sv_2mortal(newSVpv(functions[i++].pcode,0)));
2908 DSO_call(handle,func_index,hv)
2914 if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to a hash\n");
2915 hv=(HV*)SvRV(ST(2));
2916 if (SvTYPE(hv)!=SVt_PVHV) croak("Imager: Parameter 2 must be a reference to a hash\n");
2917 DSO_call( (DSO_handle *)handle,func_index,hv);
2920 i_get_pixel(im, x, y)
2927 color = (i_color *)mymalloc(sizeof(i_color));
2928 if (i_gpix(im, x, y, color) == 0) {
2929 RETVAL = NEWSV(0, 0);
2930 sv_setref_pv(RETVAL, "Imager::Color", (void *)color);
2934 RETVAL = &PL_sv_undef;
2941 i_ppix(im, x, y, cl)
2948 i_img_pal_new(x, y, channels, maxpal)
2955 i_img_to_pal(src, quant)
2961 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2962 croak("i_img_to_pal: second argument must be a hash ref");
2963 hv = (HV *)SvRV(ST(1));
2964 memset(&quant, 0, sizeof(quant));
2966 quant.mc_size = 256;
2967 ip_handle_quant_opts(aTHX_ &quant, hv);
2968 RETVAL = i_img_to_pal(src, &quant);
2970 ip_copy_colors_back(aTHX_ hv, &quant);
2972 ip_cleanup_quant_opts(aTHX_ &quant);
2981 i_img_make_palette(HV *quant_hv, ...)
2983 size_t count = items - 1;
2985 i_img **imgs = NULL;
2989 croak("Please supply at least one image (%d)", (int)count);
2990 imgs = mymalloc(sizeof(i_img *) * count);
2991 for (i = 0; i < count; ++i) {
2992 SV *img_sv = ST(i + 1);
2993 if (SvROK(img_sv) && sv_derived_from(img_sv, "Imager::ImgRaw")) {
2994 imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(img_sv)));
2998 croak("Image %d is not an image object", i+1);
3001 memset(&quant, 0, sizeof(quant));
3003 quant.mc_size = 256;
3004 ip_handle_quant_opts(aTHX_ &quant, quant_hv);
3005 i_quant_makemap(&quant, imgs, count);
3006 EXTEND(SP, quant.mc_count);
3007 for (i = 0; i < quant.mc_count; ++i) {
3008 SV *sv_c = make_i_color_sv(aTHX_ quant.mc_colors + i);
3011 ip_cleanup_quant_opts(aTHX_ &quant);
3025 work = mymalloc((r-l) * sizeof(i_palidx));
3026 count = i_gpal(im, l, r, y, work);
3027 if (GIMME_V == G_ARRAY) {
3029 for (i = 0; i < count; ++i) {
3030 PUSHs(sv_2mortal(newSViv(work[i])));
3035 PUSHs(sv_2mortal(newSVpv((char *)work, count * sizeof(i_palidx))));
3040 if (GIMME_V != G_ARRAY) {
3042 PUSHs(&PL_sv_undef);
3047 i_ppal(im, l, y, ...)
3056 work = malloc_temp(aTHX_ sizeof(i_palidx) * (items-3));
3057 for (i=0; i < items-3; ++i) {
3058 work[i] = SvIV(ST(i+3));
3060 validate_i_ppal(im, work, items - 3);
3061 RETVAL = i_ppal(im, l, l+items-3, y, work);
3070 i_ppal_p(im, l, y, data)
3076 i_palidx const *work;
3079 work = (i_palidx const *)SvPV(data, len);
3080 len /= sizeof(i_palidx);
3082 validate_i_ppal(im, work, len);
3083 RETVAL = i_ppal(im, l, l+len, y, work);
3092 i_addcolors(im, ...)
3100 croak("i_addcolors: no colors to add");
3101 colors = mymalloc((items-1) * sizeof(i_color));
3102 for (i=0; i < items-1; ++i) {
3103 if (sv_isobject(ST(i+1))
3104 && sv_derived_from(ST(i+1), "Imager::Color")) {
3105 IV tmp = SvIV((SV *)SvRV(ST(i+1)));
3106 colors[i] = *INT2PTR(i_color *, tmp);
3110 croak("i_addcolor: pixels must be Imager::Color objects");
3113 index = i_addcolors(im, colors, items-1);
3116 RETVAL = newSVpv("0 but true", 0);
3118 else if (index == -1) {
3119 RETVAL = &PL_sv_undef;
3122 RETVAL = newSViv(index);
3128 i_setcolors(im, index, ...)
3136 croak("i_setcolors: no colors to add");
3137 colors = mymalloc((items-2) * sizeof(i_color));
3138 for (i=0; i < items-2; ++i) {
3139 if (sv_isobject(ST(i+2))
3140 && sv_derived_from(ST(i+2), "Imager::Color")) {
3141 IV tmp = SvIV((SV *)SvRV(ST(i+2)));
3142 colors[i] = *INT2PTR(i_color *, tmp);
3146 croak("i_setcolors: pixels must be Imager::Color objects");
3149 RETVAL = i_setcolors(im, index, colors, items-2);
3155 i_getcolors(im, index, ...)
3164 croak("i_getcolors: too many arguments");
3166 count = SvIV(ST(2));
3168 croak("i_getcolors: count must be positive");
3169 colors = mymalloc(sizeof(i_color) * count);
3170 if (i_getcolors(im, index, colors, count)) {
3171 for (i = 0; i < count; ++i) {
3172 SV *sv = make_i_color_sv(aTHX_ colors+i);
3188 i_findcolor(im, color)
3194 if (i_findcolor(im, color, &index)) {
3195 RETVAL = newSViv(index);
3198 RETVAL = &PL_sv_undef;
3216 i_gsamp(im, l, r, y, ...)
3228 croak("No channel numbers supplied to g_samp()");
3230 chan_count = items - 4;
3231 chans = mymalloc(sizeof(int) * chan_count);
3232 for (i = 0; i < chan_count; ++i)
3233 chans[i] = SvIV(ST(i+4));
3234 data = mymalloc(sizeof(i_sample_t) * (r-l) * chan_count); /* XXX: memleak? */
3235 count = i_gsamp(im, l, r, y, data, chans, chan_count);
3237 if (GIMME_V == G_ARRAY) {
3239 for (i = 0; i < count; ++i)
3240 PUSHs(sv_2mortal(newSViv(data[i])));
3244 PUSHs(sv_2mortal(newSVpv((char *)data, count * sizeof(i_sample_t))));
3249 if (GIMME_V != G_ARRAY) {
3251 PUSHs(&PL_sv_undef);
3256 i_gsamp_bits(im, l, r, y, bits, target, offset, ...)
3272 croak("No channel numbers supplied to g_samp()");
3274 chan_count = items - 7;
3275 chans = mymalloc(sizeof(int) * chan_count);
3276 for (i = 0; i < chan_count; ++i)
3277 chans[i] = SvIV(ST(i+7));
3278 data = mymalloc(sizeof(unsigned) * (r-l) * chan_count);
3279 count = i_gsamp_bits(im, l, r, y, data, chans, chan_count, bits);
3281 for (i = 0; i < count; ++i) {
3282 av_store(target, i+offset, newSVuv(data[i]));
3294 i_psamp_bits(im, l, y, bits, channels_sv, data_av, data_offset = 0, pixel_count = -1)
3312 if (SvOK(channels_sv)) {
3314 if (!SvROK(channels_sv) || SvTYPE(SvRV(channels_sv)) != SVt_PVAV) {
3315 croak("channels is not an array ref");
3317 channels_av = (AV *)SvRV(channels_sv);
3318 chan_count = av_len(channels_av) + 1;
3319 if (chan_count < 1) {
3320 croak("i_psamp_bits: no channels provided");
3322 channels = mymalloc(sizeof(int) * chan_count);
3323 for (i = 0; i < chan_count; ++i)
3324 channels[i] = SvIV(*av_fetch(channels_av, i, 0));
3327 chan_count = im->channels;
3331 data_count = av_len(data_av) + 1;
3332 if (data_offset < 0) {
3333 croak("data_offset must by non-negative");
3335 if (data_offset > data_count) {
3336 croak("data_offset greater than number of samples supplied");
3338 if (pixel_count == -1 ||
3339 data_offset + pixel_count * chan_count > data_count) {
3340 pixel_count = (data_count - data_offset) / chan_count;
3343 data_used = pixel_count * chan_count;
3344 data = mymalloc(sizeof(unsigned) * data_count);
3345 for (i = 0; i < data_used; ++i)
3346 data[i] = SvUV(*av_fetch(data_av, data_offset + i, 0));
3348 RETVAL = i_psamp_bits(im, l, l + pixel_count, y, data, channels,
3359 i_img_masked_new(targ, mask, x, y, w, h)
3369 if (!sv_isobject(ST(1))
3370 || !sv_derived_from(ST(1), "Imager::ImgRaw")) {
3371 croak("i_img_masked_new: parameter 2 must undef or an image");
3373 mask = INT2PTR(i_img *, SvIV((SV *)SvRV(ST(1))));
3377 RETVAL = i_img_masked_new(targ, mask, x, y, w, h);
3382 i_plin(im, l, y, ...)
3393 if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
3394 /* supplied as a byte string */
3395 work = (i_color *)SvPV(ST(3), len);
3396 count = len / sizeof(i_color);
3397 if (count * sizeof(i_color) != len) {
3398 croak("i_plin: length of scalar argument must be multiple of sizeof i_color");
3400 RETVAL = i_plin(im, l, l+count, y, work);
3403 work = mymalloc(sizeof(i_color) * (items-3));
3404 for (i=0; i < items-3; ++i) {
3405 if (sv_isobject(ST(i+3))
3406 && sv_derived_from(ST(i+3), "Imager::Color")) {
3407 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3408 work[i] = *INT2PTR(i_color *, tmp);
3412 croak("i_plin: pixels must be Imager::Color objects");
3415 RETVAL = i_plin(im, l, l+items-3, y, work);
3426 i_ppixf(im, x, y, cl)
3430 Imager::Color::Float cl
3433 i_gsampf(im, l, r, y, ...)
3445 croak("No channel numbers supplied to g_sampf()");
3447 chan_count = items - 4;
3448 chans = mymalloc(sizeof(int) * chan_count);
3449 for (i = 0; i < chan_count; ++i)
3450 chans[i] = SvIV(ST(i+4));
3451 data = mymalloc(sizeof(i_fsample_t) * (r-l) * chan_count);
3452 count = i_gsampf(im, l, r, y, data, chans, chan_count);
3454 if (GIMME_V == G_ARRAY) {
3456 for (i = 0; i < count; ++i)
3457 PUSHs(sv_2mortal(newSVnv(data[i])));
3461 PUSHs(sv_2mortal(newSVpv((void *)data, count * sizeof(i_fsample_t))));
3466 if (GIMME_V != G_ARRAY) {
3468 PUSHs(&PL_sv_undef);
3473 i_plinf(im, l, y, ...)
3484 if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
3485 /* supplied as a byte string */
3486 work = (i_fcolor *)SvPV(ST(3), len);
3487 count = len / sizeof(i_fcolor);
3488 if (count * sizeof(i_fcolor) != len) {
3489 croak("i_plin: length of scalar argument must be multiple of sizeof i_fcolor");
3491 RETVAL = i_plinf(im, l, l+count, y, work);
3494 work = mymalloc(sizeof(i_fcolor) * (items-3));
3495 for (i=0; i < items-3; ++i) {
3496 if (sv_isobject(ST(i+3))
3497 && sv_derived_from(ST(i+3), "Imager::Color::Float")) {
3498 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3499 work[i] = *INT2PTR(i_fcolor *, tmp);
3503 croak("i_plinf: pixels must be Imager::Color::Float objects");
3507 RETVAL = i_plinf(im, l, l+items-3, y, work);
3525 color = (i_fcolor *)mymalloc(sizeof(i_fcolor));
3526 if (i_gpixf(im, x, y, color) == 0) {
3527 RETVAL = NEWSV(0,0);
3528 sv_setref_pv(RETVAL, "Imager::Color::Float", (void *)color);
3532 RETVAL = &PL_sv_undef;
3548 vals = mymalloc((r-l) * sizeof(i_color));
3549 memset(vals, 0, (r-l) * sizeof(i_color));
3550 count = i_glin(im, l, r, y, vals);
3551 if (GIMME_V == G_ARRAY) {
3553 for (i = 0; i < count; ++i) {
3554 SV *sv = make_i_color_sv(aTHX_ vals+i);
3560 PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_color))));
3566 i_glinf(im, l, r, y)
3576 for (i = 0; i < MAXCHANNELS; ++i)
3577 zero.channel[i] = 0;
3579 vals = mymalloc((r-l) * sizeof(i_fcolor));
3580 for (i = 0; i < r-l; ++i)
3582 count = i_glinf(im, l, r, y, vals);
3583 if (GIMME_V == G_ARRAY) {
3585 for (i = 0; i < count; ++i) {
3587 i_fcolor *col = mymalloc(sizeof(i_fcolor));
3589 sv = sv_newmortal();
3590 sv_setref_pv(sv, "Imager::Color::Float", (void *)col);
3596 PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_fcolor))));
3602 i_img_16_new(x, y, ch)
3612 i_img_double_new(x, y, ch)
3622 i_tags_addn(im, name, code, idata)
3631 name = SvPV(ST(1), len);
3634 RETVAL = i_tags_addn(&im->tags, name, code, idata);
3639 i_tags_add(im, name, code, data, idata)
3649 name = SvPV(ST(1), len);
3653 data = SvPV(ST(3), len);
3658 RETVAL = i_tags_add(&im->tags, name, code, data, len, idata);
3663 i_tags_find(im, name, start)
3670 if (i_tags_find(&im->tags, name, start, &entry)) {
3672 RETVAL = newSVpv("0 but true", 0);
3674 RETVAL = newSViv(entry);
3676 RETVAL = &PL_sv_undef;
3682 i_tags_findn(im, code, start)
3689 if (i_tags_findn(&im->tags, code, start, &entry)) {
3691 RETVAL = newSVpv("0 but true", 0);
3693 RETVAL = newSViv(entry);
3696 RETVAL = &PL_sv_undef;
3702 i_tags_delete(im, entry)
3706 RETVAL = i_tags_delete(&im->tags, entry);
3711 i_tags_delbyname(im, name)
3715 RETVAL = i_tags_delbyname(&im->tags, name);
3720 i_tags_delbycode(im, code)
3724 RETVAL = i_tags_delbycode(&im->tags, code);
3729 i_tags_get(im, index)
3733 if (index >= 0 && index < im->tags.count) {
3734 i_img_tag *entry = im->tags.tags + index;
3738 PUSHs(sv_2mortal(newSVpv(entry->name, 0)));
3741 PUSHs(sv_2mortal(newSViv(entry->code)));
3744 PUSHs(sv_2mortal(newSVpvn(entry->data, entry->size)));
3747 PUSHs(sv_2mortal(newSViv(entry->idata)));
3752 i_tags_get_string(im, what_sv)
3756 char const *name = NULL;
3760 if (SvIOK(what_sv)) {
3761 code = SvIV(what_sv);
3765 name = SvPV_nolen(what_sv);
3768 if (i_tags_get_string(&im->tags, name, code, buffer, sizeof(buffer))) {
3770 PUSHs(sv_2mortal(newSVpv(buffer, 0)));
3777 RETVAL = im->tags.count;
3783 MODULE = Imager PACKAGE = Imager::FillHandle PREFIX=IFILL_
3787 Imager::FillHandle fill
3790 IFILL_CLONE_SKIP(...)
3792 (void)items; /* avoid unused warning for XS variable */
3797 MODULE = Imager PACKAGE = Imager
3800 i_new_fill_solid(cl, combine)
3805 i_new_fill_solidf(cl, combine)
3806 Imager::Color::Float cl
3810 i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy)
3818 unsigned char *cust_hatch;
3822 cust_hatch = (unsigned char *)SvPV(ST(4), len);
3826 RETVAL = i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy);
3831 i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy)
3832 Imager::Color::Float fg
3833 Imager::Color::Float bg
3839 unsigned char *cust_hatch;
3843 cust_hatch = (unsigned char *)SvPV(ST(4), len);
3847 RETVAL = i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy);
3852 i_new_fill_image(src, matrix, xoff, yoff, combine)
3869 if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
3870 croak("i_new_fill_image: parameter must be an arrayref");
3871 av=(AV*)SvRV(ST(1));
3875 for (i = 0; i < len; ++i) {
3876 sv1=(*(av_fetch(av,i,0)));
3877 matrix[i] = SvNV(sv1);
3883 RETVAL = i_new_fill_image(src, matrixp, xoff, yoff, combine);
3887 MODULE = Imager PACKAGE = Imager::Internal::Hlines PREFIX=i_int_hlines_
3889 # this class is only exposed for testing
3892 i_int_hlines_testing()
3894 #if i_int_hlines_testing()
3896 Imager::Internal::Hlines
3897 i_int_hlines_new(start_y, count_y, start_x, count_x)
3903 Imager::Internal::Hlines
3904 i_int_hlines_new_img(im)
3908 i_int_hlines_add(hlines, y, minx, width)
3909 Imager::Internal::Hlines hlines
3915 i_int_hlines_DESTROY(hlines)
3916 Imager::Internal::Hlines hlines
3919 i_int_hlines_dump(hlines)
3920 Imager::Internal::Hlines hlines
3923 i_int_hlines_CLONE_SKIP(cls)
3928 PERL_SET_GLOBAL_CALLBACKS;
3929 PERL_PL_SET_GLOBAL_CALLBACKS;