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()
32 static im_context_t work_context;
35 perl_get_context(void) {
39 /* used to represent channel lists parameters */
40 typedef struct i_channel_list_tag {
47 const i_sample_t *samples;
52 const i_fsample_t *samples;
57 Allocate memory that will be discarded when mortals are discarded.
62 malloc_temp(pTHX_ size_t size) {
63 SV *sv = sv_2mortal(newSV(size));
68 /* These functions are all shared - then comes platform dependant code */
69 static int getstr(void *hv_t,char *key,char **store) {
74 mm_log((1,"getstr(hv_t %p, key %s, store %p)\n",hv_t,key,store));
76 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
78 svpp=hv_fetch(hv, key, strlen(key), 0);
79 *store=SvPV(*svpp, PL_na );
84 static int getint(void *hv_t,char *key,int *store) {
89 mm_log((1,"getint(hv_t %p, key %s, store %p)\n",hv_t,key,store));
91 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
93 svpp=hv_fetch(hv, key, strlen(key), 0);
94 *store=(int)SvIV(*svpp);
98 static int getdouble(void *hv_t,char* key,double *store) {
103 mm_log((1,"getdouble(hv_t %p, key %s, store %p)\n",hv_t,key,store));
105 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
106 svpp=hv_fetch(hv, key, strlen(key), 0);
107 *store=(double)SvNV(*svpp);
111 static int getvoid(void *hv_t,char* key,void **store) {
116 mm_log((1,"getvoid(hv_t %p, key %s, store %p)\n",hv_t,key,store));
118 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
120 svpp=hv_fetch(hv, key, strlen(key), 0);
121 *store = INT2PTR(void*, SvIV(*svpp));
126 static int getobj(void *hv_t,char *key,char *type,void **store) {
131 mm_log((1,"getobj(hv_t %p, key %s,type %s, store %p)\n",hv_t,key,type,store));
133 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
135 svpp=hv_fetch(hv, key, strlen(key), 0);
137 if (sv_derived_from(*svpp,type)) {
138 IV tmp = SvIV((SV*)SvRV(*svpp));
139 *store = INT2PTR(void*, tmp);
141 mm_log((1,"getobj: key exists in hash but is not of correct type"));
148 UTIL_table_t i_UTIL_table={getstr,getint,getdouble,getvoid,getobj};
150 void my_SvREFCNT_dec(void *p) {
152 SvREFCNT_dec((SV*)p);
157 i_log_entry(char *string, int level) {
158 mm_log((level, "%s", string));
162 make_i_color_sv(pTHX_ const i_color *c) {
164 i_color *col = mymalloc(sizeof(i_color));
167 sv_setref_pv(sv, "Imager::Color", (void *)col);
172 #define CBDATA_BUFSIZE 8192
175 /* the SVs we use to call back to Perl */
183 call_reader(struct cbdata *cbd, void *buf, size_t size,
191 if (!SvOK(cbd->readcb)) {
192 mm_log((1, "read callback called but no readcb supplied\n"));
193 i_push_error(0, "read callback called but no readcb supplied");
201 PUSHs(sv_2mortal(newSViv(size)));
202 PUSHs(sv_2mortal(newSViv(maxread)));
205 count = perl_call_sv(cbd->readcb, G_SCALAR);
210 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
216 char *ptr = SvPVbyte(data, len);
218 croak("Too much data returned in reader callback (wanted %d, got %d, expected %d)",
219 (int)size, (int)len, (int)maxread);
221 memcpy(buf, ptr, len);
236 io_seeker(void *p, off_t offset, int whence) {
238 struct cbdata *cbd = p;
243 if (!SvOK(cbd->seekcb)) {
244 mm_log((1, "seek callback called but no seekcb supplied\n"));
245 i_push_error(0, "seek callback called but no seekcb supplied");
253 PUSHs(sv_2mortal(newSViv(offset)));
254 PUSHs(sv_2mortal(newSViv(whence)));
257 count = perl_call_sv(cbd->seekcb, G_SCALAR);
262 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
274 io_writer(void *p, void const *data, size_t size) {
276 struct cbdata *cbd = p;
282 if (!SvOK(cbd->writecb)) {
283 mm_log((1, "write callback called but no writecb supplied\n"));
284 i_push_error(0, "write callback called but no writecb supplied");
292 PUSHs(sv_2mortal(newSVpv((char *)data, size)));
295 count = perl_call_sv(cbd->writecb, G_SCALAR);
299 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
302 success = SvTRUE(sv);
309 return success ? size : -1;
313 io_reader(void *p, void *data, size_t size) {
314 struct cbdata *cbd = p;
316 return call_reader(cbd, data, size, size);
319 static int io_closer(void *p) {
321 struct cbdata *cbd = p;
324 if (SvOK(cbd->closecb)) {
334 count = perl_call_sv(cbd->closecb, G_SCALAR);
339 success = SvTRUE(sv);
346 return success ? 0 : -1;
349 static void io_destroyer(void *p) {
351 struct cbdata *cbd = p;
353 SvREFCNT_dec(cbd->writecb);
354 SvREFCNT_dec(cbd->readcb);
355 SvREFCNT_dec(cbd->seekcb);
356 SvREFCNT_dec(cbd->closecb);
361 do_io_new_buffer(pTHX_ SV *data_sv) {
365 data = SvPVbyte(data_sv, length);
366 SvREFCNT_inc(data_sv);
367 return io_new_buffer(data, length, my_SvREFCNT_dec, data_sv);
371 describe_sv(SV *sv) {
374 svtype type = SvTYPE(SvRV(sv));
376 case SVt_PVCV: return "CV";
377 case SVt_PVGV: return "GV";
378 case SVt_PVLV: return "LV";
379 default: return "some reference";
383 return "non-reference scalar";
392 do_io_new_cb(pTHX_ SV *writecb, SV *readcb, SV *seekcb, SV *closecb) {
395 cbd = mymalloc(sizeof(struct cbdata));
396 cbd->writecb = newSVsv(writecb);
397 cbd->readcb = newSVsv(readcb);
398 cbd->seekcb = newSVsv(seekcb);
399 cbd->closecb = newSVsv(closecb);
401 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)));
403 return io_new_cb(cbd, io_reader, io_writer, io_seeker, io_closer,
411 static int lookup_name(struct value_name *names, int count, char *name, int def_value)
414 for (i = 0; i < count; ++i)
415 if (strEQ(names[i].name, name))
416 return names[i].value;
420 static struct value_name transp_names[] =
423 { "threshold", tr_threshold },
424 { "errdiff", tr_errdiff },
425 { "ordered", tr_ordered, },
428 static struct value_name make_color_names[] =
430 { "none", mc_none, },
431 { "webmap", mc_web_map, },
432 { "addi", mc_addi, },
433 { "mediancut", mc_median_cut, },
434 { "mono", mc_mono, },
435 { "monochrome", mc_mono, },
436 { "gray", mc_gray, },
437 { "gray4", mc_gray4, },
438 { "gray16", mc_gray16, },
441 static struct value_name translate_names[] =
443 { "giflib", pt_giflib, },
444 { "closest", pt_closest, },
445 { "perturb", pt_perturb, },
446 { "errdiff", pt_errdiff, },
449 static struct value_name errdiff_names[] =
451 { "floyd", ed_floyd, },
452 { "jarvis", ed_jarvis, },
453 { "stucki", ed_stucki, },
454 { "custom", ed_custom, },
457 static struct value_name orddith_names[] =
459 { "random", od_random, },
460 { "dot8", od_dot8, },
461 { "dot4", od_dot4, },
462 { "hline", od_hline, },
463 { "vline", od_vline, },
464 { "/line", od_slashline, },
465 { "slashline", od_slashline, },
466 { "\\line", od_backline, },
467 { "backline", od_backline, },
468 { "tiny", od_tiny, },
469 { "custom", od_custom, },
472 /* look through the hash for quantization options */
474 ip_handle_quant_opts(pTHX_ i_quantize *quant, HV *hv)
476 /*** POSSIBLY BROKEN: do I need to unref the SV from hv_fetch ***/
482 quant->mc_colors = mymalloc(quant->mc_size * sizeof(i_color));
484 sv = hv_fetch(hv, "transp", 6, 0);
485 if (sv && *sv && (str = SvPV(*sv, len))) {
487 lookup_name(transp_names, sizeof(transp_names)/sizeof(*transp_names),
489 if (quant->transp != tr_none) {
490 quant->tr_threshold = 127;
491 sv = hv_fetch(hv, "tr_threshold", 12, 0);
493 quant->tr_threshold = SvIV(*sv);
495 if (quant->transp == tr_errdiff) {
496 sv = hv_fetch(hv, "tr_errdiff", 10, 0);
497 if (sv && *sv && (str = SvPV(*sv, len)))
498 quant->tr_errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
500 if (quant->transp == tr_ordered) {
501 quant->tr_orddith = od_tiny;
502 sv = hv_fetch(hv, "tr_orddith", 10, 0);
503 if (sv && *sv && (str = SvPV(*sv, len)))
504 quant->tr_orddith = lookup_name(orddith_names, sizeof(orddith_names)/sizeof(*orddith_names), str, od_random);
506 if (quant->tr_orddith == od_custom) {
507 sv = hv_fetch(hv, "tr_map", 6, 0);
508 if (sv && *sv && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
509 AV *av = (AV*)SvRV(*sv);
510 len = av_len(av) + 1;
511 if (len > sizeof(quant->tr_custom))
512 len = sizeof(quant->tr_custom);
513 for (i = 0; i < len; ++i) {
514 SV **sv2 = av_fetch(av, i, 0);
516 quant->tr_custom[i] = SvIV(*sv2);
519 while (i < sizeof(quant->tr_custom))
520 quant->tr_custom[i++] = 0;
525 quant->make_colors = mc_median_cut;
526 sv = hv_fetch(hv, "make_colors", 11, 0);
527 if (sv && *sv && (str = SvPV(*sv, len))) {
529 lookup_name(make_color_names, sizeof(make_color_names)/sizeof(*make_color_names), str, mc_median_cut);
531 sv = hv_fetch(hv, "colors", 6, 0);
532 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
533 /* needs to be an array of Imager::Color
534 note that the caller allocates the mc_color array and sets mc_size
536 AV *av = (AV *)SvRV(*sv);
537 quant->mc_count = av_len(av)+1;
538 if (quant->mc_count > quant->mc_size)
539 quant->mc_count = quant->mc_size;
540 for (i = 0; i < quant->mc_count; ++i) {
541 SV **sv1 = av_fetch(av, i, 0);
542 if (sv1 && *sv1 && SvROK(*sv1) && sv_derived_from(*sv1, "Imager::Color")) {
543 i_color *col = INT2PTR(i_color *, SvIV((SV*)SvRV(*sv1)));
544 quant->mc_colors[i] = *col;
548 sv = hv_fetch(hv, "max_colors", 10, 0);
551 if (i <= quant->mc_size && i >= quant->mc_count)
555 quant->translate = pt_closest;
556 sv = hv_fetch(hv, "translate", 9, 0);
557 if (sv && *sv && (str = SvPV(*sv, len))) {
558 quant->translate = lookup_name(translate_names, sizeof(translate_names)/sizeof(*translate_names), str, pt_closest);
560 sv = hv_fetch(hv, "errdiff", 7, 0);
561 if (sv && *sv && (str = SvPV(*sv, len))) {
562 quant->errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
564 if (quant->translate == pt_errdiff && quant->errdiff == ed_custom) {
565 /* get the error diffusion map */
566 sv = hv_fetch(hv, "errdiff_width", 13, 0);
568 quant->ed_width = SvIV(*sv);
569 sv = hv_fetch(hv, "errdiff_height", 14, 0);
571 quant->ed_height = SvIV(*sv);
572 sv = hv_fetch(hv, "errdiff_orig", 12, 0);
574 quant->ed_orig = SvIV(*sv);
575 if (quant->ed_width > 0 && quant->ed_height > 0) {
577 quant->ed_map = mymalloc(sizeof(int)*quant->ed_width*quant->ed_height);
578 sv = hv_fetch(hv, "errdiff_map", 11, 0);
579 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
580 AV *av = (AV*)SvRV(*sv);
581 len = av_len(av) + 1;
582 if (len > quant->ed_width * quant->ed_height)
583 len = quant->ed_width * quant->ed_height;
584 for (i = 0; i < len; ++i) {
585 SV **sv2 = av_fetch(av, i, 0);
587 quant->ed_map[i] = SvIV(*sv2);
588 sum += quant->ed_map[i];
594 myfree(quant->ed_map);
596 quant->errdiff = ed_floyd;
600 sv = hv_fetch(hv, "perturb", 7, 0);
602 quant->perturb = SvIV(*sv);
606 ip_cleanup_quant_opts(pTHX_ i_quantize *quant) {
607 myfree(quant->mc_colors);
609 myfree(quant->ed_map);
612 /* copies the color map from the hv into the colors member of the HV */
614 ip_copy_colors_back(pTHX_ HV *hv, i_quantize *quant) {
620 sv = hv_fetch(hv, "colors", 6, 0);
621 if (!sv || !*sv || !SvROK(*sv) || SvTYPE(SvRV(*sv)) != SVt_PVAV) {
626 av = (AV *)SvRV(*sv);
628 av_extend(av, quant->mc_count+1);
629 for (i = 0; i < quant->mc_count; ++i) {
630 i_color *in = quant->mc_colors+i;
631 Imager__Color c = ICL_new_internal(in->rgb.r, in->rgb.g, in->rgb.b, 255);
632 work = sv_newmortal();
633 sv_setref_pv(work, "Imager::Color", (void *)c);
639 /* loads the segments of a fountain fill into an array */
640 static i_fountain_seg *
641 load_fount_segs(pTHX_ AV *asegs, int *count) {
642 /* Each element of segs must contain:
643 [ start, middle, end, c0, c1, segtype, colortrans ]
644 start, middle, end are doubles from 0 to 1
645 c0, c1 are Imager::Color::Float or Imager::Color objects
646 segtype, colortrans are ints
650 i_fountain_seg *segs;
654 *count = av_len(asegs)+1;
656 croak("i_fountain must have at least one segment");
657 segs = mymalloc(sizeof(i_fountain_seg) * *count);
658 for(i = 0; i < *count; i++) {
659 SV **sv1 = av_fetch(asegs, i, 0);
660 if (!sv1 || !*sv1 || !SvROK(*sv1)
661 || SvTYPE(SvRV(*sv1)) != SVt_PVAV) {
663 croak("i_fountain: segs must be an arrayref of arrayrefs");
665 aseg = (AV *)SvRV(*sv1);
666 if (av_len(aseg) != 7-1) {
668 croak("i_fountain: a segment must have 7 members");
670 for (j = 0; j < 3; ++j) {
671 SV **sv2 = av_fetch(aseg, j, 0);
674 croak("i_fountain: XS error");
676 work[j] = SvNV(*sv2);
678 segs[i].start = work[0];
679 segs[i].middle = work[1];
680 segs[i].end = work[2];
681 for (j = 0; j < 2; ++j) {
682 SV **sv3 = av_fetch(aseg, 3+j, 0);
683 if (!sv3 || !*sv3 || !SvROK(*sv3) ||
684 (!sv_derived_from(*sv3, "Imager::Color")
685 && !sv_derived_from(*sv3, "Imager::Color::Float"))) {
687 croak("i_fountain: segs must contain colors in elements 3 and 4");
689 if (sv_derived_from(*sv3, "Imager::Color::Float")) {
690 segs[i].c[j] = *INT2PTR(i_fcolor *, SvIV((SV *)SvRV(*sv3)));
693 i_color c = *INT2PTR(i_color *, SvIV((SV *)SvRV(*sv3)));
695 for (ch = 0; ch < MAXCHANNELS; ++ch) {
696 segs[i].c[j].channel[ch] = c.channel[ch] / 255.0;
700 for (j = 0; j < 2; ++j) {
701 SV **sv2 = av_fetch(aseg, j+5, 0);
704 croak("i_fountain: XS error");
706 worki[j] = SvIV(*sv2);
708 segs[i].type = worki[0];
709 segs[i].color = worki[1];
715 /* validates the indexes supplied to i_ppal
717 i_ppal() doesn't do that for speed, but I'm not comfortable doing that
722 validate_i_ppal(i_img *im, i_palidx const *indexes, int count) {
723 int color_count = i_colorcount(im);
726 if (color_count == -1)
727 croak("i_plin() called on direct color image");
729 for (i = 0; i < count; ++i) {
730 if (indexes[i] >= color_count) {
731 croak("i_plin() called with out of range color index %d (max %d)",
732 indexes[i], color_count-1);
738 /* I don't think ICLF_* names belong at the C interface
739 this makes the XS code think we have them, to let us avoid
740 putting function bodies in the XS code
742 #define ICLF_new_internal(r, g, b, a) i_fcolor_new((r), (g), (b), (a))
743 #define ICLF_DESTROY(cl) i_fcolor_destroy(cl)
746 #define i_log_enabled() 1
748 #define i_log_enabled() 0
751 #if i_int_hlines_testing()
753 typedef i_int_hlines *Imager__Internal__Hlines;
755 static i_int_hlines *
756 i_int_hlines_new(i_img_dim start_y, i_img_dim count_y, i_img_dim start_x, i_img_dim count_x) {
757 i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
758 i_int_init_hlines(result, start_y, count_y, start_x, count_x);
763 static i_int_hlines *
764 i_int_hlines_new_img(i_img *im) {
765 i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
766 i_int_init_hlines_img(result, im);
772 i_int_hlines_DESTROY(i_int_hlines *hlines) {
773 i_int_hlines_destroy(hlines);
777 #define i_int_hlines_CLONE_SKIP(cls) 1
779 static int seg_compare(const void *vleft, const void *vright) {
780 const i_int_hline_seg *left = vleft;
781 const i_int_hline_seg *right = vright;
783 return left->minx - right->minx;
787 i_int_hlines_dump(i_int_hlines *hlines) {
789 SV *dump = newSVpvf("start_y: %" i_DF " limit_y: %" i_DF " start_x: %" i_DF " limit_x: %" i_DF"\n",
790 i_DFc(hlines->start_y), i_DFc(hlines->limit_y), i_DFc(hlines->start_x), i_DFc(hlines->limit_x));
793 for (y = hlines->start_y; y < hlines->limit_y; ++y) {
794 i_int_hline_entry *entry = hlines->entries[y-hlines->start_y];
797 /* sort the segments, if any */
799 qsort(entry->segs, entry->count, sizeof(i_int_hline_seg), seg_compare);
801 sv_catpvf(dump, " %" i_DF " (%" i_DF "):", i_DFc(y), i_DFc(entry->count));
802 for (i = 0; i < entry->count; ++i) {
803 sv_catpvf(dump, " [%" i_DF ", %" i_DF ")", i_DFc(entry->segs[i].minx),
804 i_DFc(entry->segs[i].x_limit));
806 sv_catpv(dump, "\n");
816 i_sv_off_t(pTHX_ SV *sv) {
817 #if LSEEKSIZE > IVSIZE
818 return (off_t)SvNV(sv);
820 return (off_t)SvIV(sv);
825 i_new_sv_off_t(pTHX_ off_t off) {
826 #if LSEEKSIZE > IVSIZE
833 static im_pl_ext_funcs im_perl_funcs =
835 IMAGER_PL_API_VERSION,
837 ip_handle_quant_opts,
838 ip_cleanup_quant_opts,
842 #define PERL_PL_SET_GLOBAL_CALLBACKS \
843 sv_setiv(get_sv(PERL_PL_FUNCTION_TABLE_NAME, 1), PTR2IV(&im_perl_funcs));
845 #define IIM_new i_img_8_new
846 #define IIM_DESTROY i_img_destroy
849 #define i_exif_enabled() 1
851 #define i_exif_enabled() 0
854 /* trying to use more C style names, map them here */
855 #define i_io_DESTROY(ig) io_glue_destroy(ig)
857 #define i_img_get_width(im) ((im)->xsize)
858 #define i_img_get_height(im) ((im)->ysize)
860 #define i_img_epsilonf() (DBL_EPSILON * 4)
862 /* avoid some xsubpp strangeness */
865 MODULE = Imager PACKAGE = Imager::Color PREFIX = ICL_
868 ICL_new_internal(r,g,b,a)
880 ICL_set_internal(cl,r,g,b,a)
887 ICL_set_internal(cl, r, g, b, a);
901 PUSHs(sv_2mortal(newSVnv(cl->rgba.r)));
902 PUSHs(sv_2mortal(newSVnv(cl->rgba.g)));
903 PUSHs(sv_2mortal(newSVnv(cl->rgba.b)));
904 PUSHs(sv_2mortal(newSVnv(cl->rgba.a)));
910 RETVAL = mymalloc(sizeof(i_color));
912 i_hsv_to_rgb(RETVAL);
920 RETVAL = mymalloc(sizeof(i_color));
922 i_rgb_to_hsv(RETVAL);
928 MODULE = Imager PACKAGE = Imager::Color::Float PREFIX=ICLF_
931 ICLF_new_internal(r, g, b, a)
939 Imager::Color::Float cl
943 Imager::Color::Float cl
947 EXTEND(SP, MAXCHANNELS);
948 for (ch = 0; ch < MAXCHANNELS; ++ch) {
949 /* printf("%d: %g\n", ch, cl->channel[ch]); */
950 PUSHs(sv_2mortal(newSVnv(cl->channel[ch])));
954 ICLF_set_internal(cl,r,g,b,a)
955 Imager::Color::Float cl
970 Imager::Color::Float c
972 RETVAL = mymalloc(sizeof(i_fcolor));
974 i_hsv_to_rgbf(RETVAL);
980 Imager::Color::Float c
982 RETVAL = mymalloc(sizeof(i_fcolor));
984 i_rgb_to_hsvf(RETVAL);
988 MODULE = Imager PACKAGE = Imager::ImgRaw PREFIX = IIM_
1002 MODULE = Imager PACKAGE = Imager
1016 io_new_buffer(data_sv)
1019 RETVAL = do_io_new_buffer(aTHX_ data_sv);
1024 io_new_cb(writecb, readcb, seekcb, closecb, maxwrite = CBDATA_BUFSIZE)
1031 RETVAL = do_io_new_cb(aTHX_ writecb, readcb, seekcb, closecb);
1039 unsigned char* data;
1043 tlength = io_slurp(ig, &data);
1044 RETVAL = newSVpv((char *)data,tlength);
1051 i_set_image_file_limits(width, height, bytes)
1057 i_get_image_file_limits()
1059 i_img_dim width, height;
1062 if (i_get_image_file_limits(&width, &height, &bytes)) {
1064 PUSHs(sv_2mortal(newSViv(width)));
1065 PUSHs(sv_2mortal(newSViv(height)));
1066 PUSHs(sv_2mortal(newSVuv(bytes)));
1070 i_int_check_image_file_limits(width, height, channels, sample_size)
1077 MODULE = Imager PACKAGE = Imager::IO PREFIX = io_
1080 io_new_fd(class, fd)
1083 RETVAL = io_new_fd(fd);
1088 io_new_buffer(class, data_sv)
1091 RETVAL = do_io_new_buffer(aTHX_ data_sv);
1096 io_new_cb(class, writecb, readcb, seekcb, closecb)
1102 RETVAL = do_io_new_cb(aTHX_ writecb, readcb, seekcb, closecb);
1107 io_new_bufchain(class)
1109 RETVAL = io_new_bufchain();
1117 unsigned char* data;
1121 tlength = io_slurp(ig, &data);
1122 RETVAL = newSVpv((char *)data,tlength);
1127 MODULE = Imager PACKAGE = Imager::IO PREFIX = i_io_
1130 i_io_raw_write(ig, data_sv)
1138 if (SvUTF8(data_sv)) {
1139 data_sv = sv_2mortal(newSVsv(data_sv));
1140 /* yes, we want this to croak() if the SV can't be downgraded */
1141 sv_utf8_downgrade(data_sv, FALSE);
1144 data = SvPV(data_sv, size);
1145 RETVAL = i_io_raw_write(ig, data, size);
1150 i_io_raw_read(ig, buffer_sv, size)
1159 croak("size negative in call to i_io_raw_read()");
1160 /* prevent an undefined value warning if they supplied an
1162 Orginally conditional on !SvOK(), but this will prevent the
1163 downgrade from croaking */
1164 sv_setpvn(buffer_sv, "", 0);
1166 if (SvUTF8(buffer_sv))
1167 sv_utf8_downgrade(buffer_sv, FALSE);
1169 buffer = SvGROW(buffer_sv, size+1);
1170 result = i_io_raw_read(ig, buffer, size);
1172 SvCUR_set(buffer_sv, result);
1173 *SvEND(buffer_sv) = '\0';
1174 SvPOK_only(buffer_sv);
1176 PUSHs(sv_2mortal(newSViv(result)));
1182 i_io_raw_read2(ig, size)
1191 croak("size negative in call to i_io_read2()");
1192 buffer_sv = newSV(size);
1193 buffer = SvGROW(buffer_sv, size+1);
1194 result = i_io_raw_read(ig, buffer, size);
1196 SvCUR_set(buffer_sv, result);
1197 *SvEND(buffer_sv) = '\0';
1198 SvPOK_only(buffer_sv);
1200 PUSHs(sv_2mortal(buffer_sv));
1204 SvREFCNT_dec(buffer_sv);
1208 i_io_raw_seek(ig, position, whence)
1222 i_io_CLONE_SKIP(...)
1224 (void)items; /* avoid unused warning for XS variable */
1251 i_io_seek(ig, off, whence)
1257 i_io_peekn(ig, size)
1265 buffer_sv = newSV(size+1);
1266 buffer = SvGROW(buffer_sv, size+1);
1267 result = i_io_peekn(ig, buffer, size);
1269 SvCUR_set(buffer_sv, result);
1270 *SvEND(buffer_sv) = '\0';
1271 SvPOK_only(buffer_sv);
1273 PUSHs(sv_2mortal(buffer_sv));
1277 SvREFCNT_dec(buffer_sv);
1281 i_io_read(ig, buffer_sv, size)
1290 croak("size negative in call to i_io_read()");
1291 /* prevent an undefined value warning if they supplied an
1293 Orginally conditional on !SvOK(), but this will prevent the
1294 downgrade from croaking */
1295 sv_setpvn(buffer_sv, "", 0);
1297 if (SvUTF8(buffer_sv))
1298 sv_utf8_downgrade(buffer_sv, FALSE);
1300 buffer = SvGROW(buffer_sv, size+1);
1301 result = i_io_read(ig, buffer, size);
1303 SvCUR_set(buffer_sv, result);
1304 *SvEND(buffer_sv) = '\0';
1305 SvPOK_only(buffer_sv);
1307 PUSHs(sv_2mortal(newSViv(result)));
1313 i_io_read2(ig, size)
1322 croak("size zero in call to read2()");
1323 buffer_sv = newSV(size);
1324 buffer = SvGROW(buffer_sv, size+1);
1325 result = i_io_read(ig, buffer, size);
1327 SvCUR_set(buffer_sv, result);
1328 *SvEND(buffer_sv) = '\0';
1329 SvPOK_only(buffer_sv);
1331 PUSHs(sv_2mortal(buffer_sv));
1335 SvREFCNT_dec(buffer_sv);
1339 i_io_gets(ig, size = 8192, eol = NEWLINE)
1349 croak("size too small in call to gets()");
1350 buffer_sv = sv_2mortal(newSV(size+1));
1351 buffer = SvPVX(buffer_sv);
1352 result = i_io_gets(ig, buffer, size+1, eol);
1354 SvCUR_set(buffer_sv, result);
1355 *SvEND(buffer_sv) = '\0';
1356 SvPOK_only(buffer_sv);
1362 i_io_write(ig, data_sv)
1370 if (SvUTF8(data_sv)) {
1371 data_sv = sv_2mortal(newSVsv(data_sv));
1372 /* yes, we want this to croak() if the SV can't be downgraded */
1373 sv_utf8_downgrade(data_sv, FALSE);
1376 data = SvPV(data_sv, size);
1377 RETVAL = i_io_write(ig, data, size);
1382 i_io_dump(ig, flags = I_IO_DUMP_DEFAULT)
1387 i_io_set_buffered(ig, flag = 1)
1392 i_io_is_buffered(ig)
1403 MODULE = Imager PACKAGE = Imager
1414 while( (item=i_format_list[i++]) != NULL ) {
1416 PUSHs(sv_2mortal(newSVpv(item,0)));
1420 i_sametype(im, x, y)
1426 i_sametype_chans(im, x, y, channels)
1433 i_init_log(name_sv,level)
1437 const char *name = SvOK(name_sv) ? SvPV_nolen(name_sv) : NULL;
1439 RETVAL = i_init_log(name, level);
1444 i_log_entry(string,level)
1457 i_img_info(im,info);
1459 PUSHs(sv_2mortal(newSViv(info[0])));
1460 PUSHs(sv_2mortal(newSViv(info[1])));
1461 PUSHs(sv_2mortal(newSViv(info[2])));
1462 PUSHs(sv_2mortal(newSViv(info[3])));
1468 i_img_setmask(im,ch_mask)
1477 i_img_getchannels(im)
1486 sv_2mortal(newSVpv((char *)im->idata, im->bytes))
1494 i_img_get_height(im)
1499 i_img_is_monochrome(im)
1505 result = i_img_is_monochrome(im, &zero_is_white);
1507 if (GIMME_V == G_ARRAY) {
1510 PUSHs(sv_2mortal(newSViv(zero_is_white)));
1519 i_line(im,x1,y1,x2,y2,val,endp)
1529 i_line_aa(im,x1,y1,x2,y2,val,endp)
1539 i_box(im,x1,y1,x2,y2,val)
1548 i_box_filled(im,x1,y1,x2,y2,val)
1557 i_box_filledf(im,x1,y1,x2,y2,val)
1563 Imager::Color::Float val
1566 i_box_cfill(im,x1,y1,x2,y2,fill)
1572 Imager::FillHandle fill
1575 i_arc(im,x,y,rad,d1,d2,val)
1585 i_arc_aa(im,x,y,rad,d1,d2,val)
1595 i_arc_cfill(im,x,y,rad,d1,d2,fill)
1602 Imager::FillHandle fill
1605 i_arc_aa_cfill(im,x,y,rad,d1,d2,fill)
1612 Imager::FillHandle fill
1616 i_circle_aa(im,x,y,rad,val)
1624 i_circle_out(im,x,y,rad,val)
1632 i_circle_out_aa(im,x,y,rad,val)
1640 i_arc_out(im,x,y,rad,d1,d2,val)
1650 i_arc_out_aa(im,x,y,rad,d1,d2,val)
1661 i_bezier_multi(im,xc,yc,val)
1674 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_bezier_multi must be a reference to an array\n");
1675 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_bezier_multi must be a reference to an array\n");
1676 if (!SvROK(ST(2))) croak("Imager: Parameter 2 to i_bezier_multi must be a reference to an array\n");
1677 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 to i_bezier_multi must be a reference to an array\n");
1678 av1=(AV*)SvRV(ST(1));
1679 av2=(AV*)SvRV(ST(2));
1680 if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_bezier_multi must be equal length\n");
1682 x=mymalloc( len*sizeof(double) );
1683 y=mymalloc( len*sizeof(double) );
1684 for(i=0;i<len;i++) {
1685 sv1=(*(av_fetch(av1,i,0)));
1686 sv2=(*(av_fetch(av2,i,0)));
1687 x[i]=(double)SvNV(sv1);
1688 y[i]=(double)SvNV(sv2);
1690 i_bezier_multi(im,len,x,y,val);
1696 i_poly_aa(im,xc,yc,val)
1709 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1710 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1711 if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1712 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1713 av1=(AV*)SvRV(ST(1));
1714 av2=(AV*)SvRV(ST(2));
1715 if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_poly_aa must be equal length\n");
1717 x=mymalloc( len*sizeof(double) );
1718 y=mymalloc( len*sizeof(double) );
1719 for(i=0;i<len;i++) {
1720 sv1=(*(av_fetch(av1,i,0)));
1721 sv2=(*(av_fetch(av2,i,0)));
1722 x[i]=(double)SvNV(sv1);
1723 y[i]=(double)SvNV(sv2);
1725 RETVAL = i_poly_aa(im,len,x,y,val);
1732 i_poly_aa_cfill(im,xc,yc,fill)
1734 Imager::FillHandle fill
1744 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1745 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1746 if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1747 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1748 av1=(AV*)SvRV(ST(1));
1749 av2=(AV*)SvRV(ST(2));
1750 if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_poly_aa_cfill must be equal length\n");
1752 x=mymalloc( len*sizeof(double) );
1753 y=mymalloc( len*sizeof(double) );
1754 for(i=0;i<len;i++) {
1755 sv1=(*(av_fetch(av1,i,0)));
1756 sv2=(*(av_fetch(av2,i,0)));
1757 x[i]=(double)SvNV(sv1);
1758 y[i]=(double)SvNV(sv2);
1760 RETVAL = i_poly_aa_cfill(im,len,x,y,fill);
1769 i_flood_fill(im,seedx,seedy,dcol)
1776 i_flood_cfill(im,seedx,seedy,fill)
1780 Imager::FillHandle fill
1783 i_flood_fill_border(im,seedx,seedy,dcol, border)
1788 Imager::Color border
1791 i_flood_cfill_border(im,seedx,seedy,fill, border)
1795 Imager::FillHandle fill
1796 Imager::Color border
1800 i_copyto(im,src,x1,y1,x2,y2,tx,ty)
1812 i_copyto_trans(im,src,x1,y1,x2,y2,tx,ty,trans)
1829 i_rubthru(im,src,tx,ty,src_minx,src_miny,src_maxx,src_maxy)
1840 i_compose(out, src, out_left, out_top, src_left, src_top, width, height, combine = ic_normal, opacity = 0.0)
1853 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)
1869 i_combine(src_av, channels_av = NULL)
1873 i_img **imgs = NULL;
1875 int *channels = NULL;
1880 in_count = av_len(src_av) + 1;
1882 imgs = mymalloc(sizeof(i_img*) * in_count);
1883 channels = mymalloc(sizeof(int) * in_count);
1884 for (i = 0; i < in_count; ++i) {
1885 psv = av_fetch(src_av, i, 0);
1886 if (!psv || !*psv || !sv_derived_from(*psv, "Imager::ImgRaw")) {
1889 croak("imgs must contain only images");
1891 tmp = SvIV((SV*)SvRV(*psv));
1892 imgs[i] = INT2PTR(i_img*, tmp);
1894 (psv = av_fetch(channels_av, i, 0)) != NULL &&
1896 channels[i] = SvIV(*psv);
1903 RETVAL = i_combine(imgs, channels, in_count);
1910 i_flipxy(im, direction)
1915 i_rotate90(im, degrees)
1920 i_rotate_exact(im, amount, ...)
1924 i_color *backp = NULL;
1925 i_fcolor *fbackp = NULL;
1929 /* extract the bg colors if any */
1930 /* yes, this is kind of strange */
1931 for (i = 2; i < items; ++i) {
1933 if (sv_derived_from(sv1, "Imager::Color")) {
1934 IV tmp = SvIV((SV*)SvRV(sv1));
1935 backp = INT2PTR(i_color *, tmp);
1937 else if (sv_derived_from(sv1, "Imager::Color::Float")) {
1938 IV tmp = SvIV((SV*)SvRV(sv1));
1939 fbackp = INT2PTR(i_fcolor *, tmp);
1942 RETVAL = i_rotate_exact_bg(im, amount, backp, fbackp);
1947 i_matrix_transform(im, xsize, ysize, matrix, ...)
1957 i_color *backp = NULL;
1958 i_fcolor *fbackp = NULL;
1960 if (!SvROK(ST(3)) || SvTYPE(SvRV(ST(3))) != SVt_PVAV)
1961 croak("i_matrix_transform: parameter 4 must be an array ref\n");
1962 av=(AV*)SvRV(ST(3));
1966 for (i = 0; i < len; ++i) {
1967 sv1=(*(av_fetch(av,i,0)));
1968 matrix[i] = SvNV(sv1);
1972 /* extract the bg colors if any */
1973 /* yes, this is kind of strange */
1974 for (i = 4; i < items; ++i) {
1976 if (sv_derived_from(sv1, "Imager::Color")) {
1977 IV tmp = SvIV((SV*)SvRV(sv1));
1978 backp = INT2PTR(i_color *, tmp);
1980 else if (sv_derived_from(sv1, "Imager::Color::Float")) {
1981 IV tmp = SvIV((SV*)SvRV(sv1));
1982 fbackp = INT2PTR(i_fcolor *, tmp);
1985 RETVAL = i_matrix_transform_bg(im, xsize, ysize, matrix, backp, fbackp);
1990 i_gaussian(im,stdev)
1995 i_unsharp_mask(im,stdev,scale)
2010 len = av_len(coef) + 1;
2011 c_coef=mymalloc( len * sizeof(double) );
2012 for(i = 0; i < len; i++) {
2013 sv1 = (*(av_fetch(coef, i, 0)));
2014 c_coef[i] = (double)SvNV(sv1);
2016 RETVAL = i_conv(im, c_coef, len);
2022 i_convert(src, avmain)
2034 outchan = av_len(avmain)+1;
2035 /* find the biggest */
2037 for (j=0; j < outchan; ++j) {
2038 temp = av_fetch(avmain, j, 0);
2039 if (temp && SvROK(*temp) && SvTYPE(SvRV(*temp)) == SVt_PVAV) {
2040 avsub = (AV*)SvRV(*temp);
2041 len = av_len(avsub)+1;
2046 i_push_errorf(0, "invalid matrix: element %d is not an array ref", j);
2050 coeff = mymalloc(sizeof(double) * outchan * inchan);
2051 for (j = 0; j < outchan; ++j) {
2052 avsub = (AV*)SvRV(*av_fetch(avmain, j, 0));
2053 len = av_len(avsub)+1;
2054 for (i = 0; i < len; ++i) {
2055 temp = av_fetch(avsub, i, 0);
2057 coeff[i+j*inchan] = SvNV(*temp);
2059 coeff[i+j*inchan] = 0;
2062 coeff[i++ + j*inchan] = 0;
2064 RETVAL = i_convert(src, coeff, outchan, inchan);
2074 unsigned int mask = 0;
2080 unsigned char (*maps)[256];
2082 if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
2083 croak("i_map: parameter 2 must be an arrayref\n");
2084 avmain = (AV*)SvRV(ST(1));
2085 len = av_len(avmain)+1;
2086 if (im->channels < len) len = im->channels;
2088 maps = mymalloc( len * sizeof(unsigned char [256]) );
2090 for (j=0; j<len ; j++) {
2091 temp = av_fetch(avmain, j, 0);
2092 if (temp && SvROK(*temp) && (SvTYPE(SvRV(*temp)) == SVt_PVAV) ) {
2093 avsub = (AV*)SvRV(*temp);
2094 if(av_len(avsub) != 255) continue;
2096 for (i=0; i<256 ; i++) {
2098 temp = av_fetch(avsub, i, 0);
2099 val = temp ? SvIV(*temp) : 0;
2101 if (val>255) val = 255;
2106 i_map(im, maps, mask);
2117 i_img_diffd(im1,im2)
2122 i_img_samef(im1, im2, epsilon = i_img_epsilonf(), what=NULL)
2132 _is_color_object(sv)
2136 RETVAL = SvOK(sv) && SvROK(sv) &&
2137 (sv_derived_from(sv, "Imager::Color")
2138 || sv_derived_from(sv, "Imager::Color::Float"));
2150 MODULE = Imager PACKAGE = Imager::Font::TT PREFIX=TT_
2152 #define TT_DESTROY(handle) i_tt_destroy(handle)
2156 Imager::Font::TT handle
2161 (void)items; /* avoid unused warning */
2167 MODULE = Imager PACKAGE = Imager
2171 i_tt_text(handle,im,xb,yb,cl,points,str_sv,len_ignored,smooth,utf8,align=1)
2172 Imager::Font::TT handle
2190 str = SvPV(str_sv, len);
2191 RETVAL = i_tt_text(handle, im, xb, yb, cl, points, str,
2192 len, smooth, utf8, align);
2198 i_tt_cp(handle,im,xb,yb,channel,points,str_sv,len_ignored,smooth,utf8,align=1)
2199 Imager::Font::TT handle
2217 str = SvPV(str_sv, len);
2218 RETVAL = i_tt_cp(handle, im, xb, yb, channel, points, str, len,
2219 smooth, utf8, align);
2225 i_tt_bbox(handle,point,str_sv,len_ignored, utf8)
2226 Imager::Font::TT handle
2231 i_img_dim cords[BOUNDING_BOX_COUNT];
2241 str = SvPV(str_sv, len);
2242 if ((rc=i_tt_bbox(handle,point,str,len,cords, utf8))) {
2244 for (i = 0; i < rc; ++i) {
2245 PUSHs(sv_2mortal(newSViv(cords[i])));
2250 i_tt_has_chars(handle, text_sv, utf8)
2251 Imager::Font::TT handle
2262 if (SvUTF8(text_sv))
2265 text = SvPV(text_sv, len);
2266 work = mymalloc(len);
2267 count = i_tt_has_chars(handle, text, len, utf8, work);
2268 if (GIMME_V == G_ARRAY) {
2270 for (i = 0; i < count; ++i) {
2271 PUSHs(boolSV(work[i]));
2276 PUSHs(sv_2mortal(newSVpv(work, count)));
2281 i_tt_dump_names(handle)
2282 Imager::Font::TT handle
2285 i_tt_face_name(handle)
2286 Imager::Font::TT handle
2291 len = i_tt_face_name(handle, name, sizeof(name));
2294 PUSHs(sv_2mortal(newSVpv(name, len-1)));
2298 i_tt_glyph_name(handle, text_sv, utf8 = 0)
2299 Imager::Font::TT handle
2310 if (SvUTF8(text_sv))
2313 text = SvPV(text_sv, work_len);
2318 ch = i_utf8_advance(&text, &len);
2320 i_push_error(0, "invalid UTF8 character");
2329 if ((outsize = i_tt_glyph_name(handle, ch, name, sizeof(name))) != 0) {
2330 PUSHs(sv_2mortal(newSVpv(name, 0)));
2333 PUSHs(&PL_sv_undef);
2340 i_test_format_probe(ig, length)
2345 i_readpnm_wiol(ig, allow_incomplete)
2347 int allow_incomplete
2351 i_readpnm_multi_wiol(ig, allow_incomplete)
2353 int allow_incomplete
2359 imgs = i_readpnm_multi_wiol(ig, &count, allow_incomplete);
2362 for (i = 0; i < count; ++i) {
2363 SV *sv = sv_newmortal();
2364 sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
2371 i_writeppm_wiol(im, ig)
2380 i_readraw_wiol(ig,x,y,datachannels,storechannels,intrl)
2389 i_writeraw_wiol(im,ig)
2394 i_writebmp_wiol(im,ig)
2399 i_readbmp_wiol(ig, allow_incomplete=0)
2401 int allow_incomplete
2405 i_writetga_wiol(im,ig, wierdpack, compress, idstring)
2414 idlen = SvCUR(ST(4));
2415 RETVAL = i_writetga_wiol(im, ig, wierdpack, compress, idstring, idlen);
2421 i_readtga_wiol(ig, length)
2429 i_scaleaxis(im,Value,Axis)
2435 i_scale_nn(im,scx,scy)
2441 i_scale_mixing(im, width, height)
2451 i_count_colors(im,maxc)
2456 i_get_anonymous_color_histo(im, maxc = 0x40000000)
2461 unsigned int * col_usage = NULL;
2464 col_cnt = i_get_anonymous_color_histo(im, &col_usage, maxc);
2465 EXTEND(SP, col_cnt);
2466 for (i = 0; i < col_cnt; i++) {
2467 PUSHs(sv_2mortal(newSViv( col_usage[i])));
2474 i_transform(im,opx,opy,parm)
2488 if (!SvROK(ST(1))) croak("Imager: Parameter 1 must be a reference to an array\n");
2489 if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to an array\n");
2490 if (!SvROK(ST(3))) croak("Imager: Parameter 3 must be a reference to an array\n");
2491 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 must be a reference to an array\n");
2492 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 must be a reference to an array\n");
2493 if (SvTYPE(SvRV(ST(3))) != SVt_PVAV) croak("Imager: Parameter 3 must be a reference to an array\n");
2494 av=(AV*)SvRV(ST(1));
2496 opx=mymalloc( opxl*sizeof(int) );
2497 for(i=0;i<opxl;i++) {
2498 sv1=(*(av_fetch(av,i,0)));
2499 opx[i]=(int)SvIV(sv1);
2501 av=(AV*)SvRV(ST(2));
2503 opy=mymalloc( opyl*sizeof(int) );
2504 for(i=0;i<opyl;i++) {
2505 sv1=(*(av_fetch(av,i,0)));
2506 opy[i]=(int)SvIV(sv1);
2508 av=(AV*)SvRV(ST(3));
2509 parmlen=av_len(av)+1;
2510 parm=mymalloc( parmlen*sizeof(double) );
2511 for(i=0;i<parmlen;i++) { /* FIXME: Bug? */
2512 sv1=(*(av_fetch(av,i,0)));
2513 parm[i]=(double)SvNV(sv1);
2515 result=i_transform(im,opx,opxl,opy,opyl,parm,parmlen);
2520 SV *result_sv = sv_newmortal();
2522 sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result);
2527 i_transform2(sv_width,sv_height,channels,sv_ops,av_n_regs,av_c_regs,av_in_imgs)
2553 in_imgs_count = av_len(av_in_imgs)+1;
2554 for (i = 0; i < in_imgs_count; ++i) {
2555 sv1 = *av_fetch(av_in_imgs, i, 0);
2556 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2557 croak("sv_in_img must contain only images");
2560 if (in_imgs_count > 0) {
2561 in_imgs = mymalloc(in_imgs_count*sizeof(i_img*));
2562 for (i = 0; i < in_imgs_count; ++i) {
2563 sv1 = *av_fetch(av_in_imgs,i,0);
2564 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2565 croak("Parameter 5 must contain only images");
2567 tmp = SvIV((SV*)SvRV(sv1));
2568 in_imgs[i] = INT2PTR(i_img*, tmp);
2572 /* no input images */
2575 /* default the output size from the first input if possible */
2577 width = SvIV(sv_width);
2578 else if (in_imgs_count)
2579 width = in_imgs[0]->xsize;
2581 croak("No output image width supplied");
2583 if (SvOK(sv_height))
2584 height = SvIV(sv_height);
2585 else if (in_imgs_count)
2586 height = in_imgs[0]->ysize;
2588 croak("No output image height supplied");
2590 ops = (struct rm_op *)SvPV(sv_ops, ops_len);
2591 if (ops_len % sizeof(struct rm_op))
2592 croak("Imager: Parameter 3 must be a bitmap of regops\n");
2593 ops_count = ops_len / sizeof(struct rm_op);
2595 n_regs_count = av_len(av_n_regs)+1;
2596 n_regs = mymalloc(n_regs_count * sizeof(double));
2597 for (i = 0; i < n_regs_count; ++i) {
2598 sv1 = *av_fetch(av_n_regs,i,0);
2600 n_regs[i] = SvNV(sv1);
2602 c_regs_count = av_len(av_c_regs)+1;
2603 c_regs = mymalloc(c_regs_count * sizeof(i_color));
2604 /* I don't bother initializing the colou?r registers */
2606 result=i_transform2(width, height, channels, ops, ops_count,
2607 n_regs, n_regs_count,
2608 c_regs, c_regs_count, in_imgs, in_imgs_count);
2614 SV *result_sv = sv_newmortal();
2616 sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result);
2622 i_contrast(im,intensity)
2635 i_noise(im,amount,type)
2641 i_bumpmap(im,bump,channel,light_x,light_y,strength)
2651 i_bumpmap_complex(im,bump,channel,tx,ty,Lx,Ly,Lz,cd,cs,n,Ia,Il,Is)
2670 i_postlevels(im,levels)
2680 i_watermark(im,wmark,tx,ty,pixdiff)
2682 Imager::ImgRaw wmark
2689 i_autolevels(im,lsat,usat,skew)
2696 i_radnoise(im,xo,yo,rscale,ascale)
2704 i_turbnoise(im, xo, yo, scale)
2727 croak("Usage: i_gradgen(im, xo, yo, ival, dmeasure)");
2728 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2729 croak("i_gradgen: Second argument must be an array ref");
2730 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
2731 croak("i_gradgen: Third argument must be an array ref");
2732 if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
2733 croak("i_gradgen: Fourth argument must be an array ref");
2734 axx = (AV *)SvRV(ST(1));
2735 ayy = (AV *)SvRV(ST(2));
2736 ac = (AV *)SvRV(ST(3));
2737 dmeasure = (int)SvIV(ST(4));
2739 num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
2740 num = num <= av_len(ac) ? num : av_len(ac);
2742 if (num < 2) croak("Usage: i_gradgen array refs must have more than 1 entry each");
2743 xo = mymalloc( sizeof(i_img_dim) * num );
2744 yo = mymalloc( sizeof(i_img_dim) * num );
2745 ival = mymalloc( sizeof(i_color) * num );
2746 for(i = 0; i<num; i++) {
2747 xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0));
2748 yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0));
2749 sv = *av_fetch(ac, i, 0);
2750 if ( !sv_derived_from(sv, "Imager::Color") ) {
2751 free(axx); free(ayy); free(ac);
2752 croak("i_gradgen: Element of fourth argument is not derived from Imager::Color");
2754 ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
2756 i_gradgen(im, num, xo, yo, ival, dmeasure);
2762 i_diff_image(im, im2, mindist=0)
2768 i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2778 double ssample_param
2782 i_fountain_seg *segs;
2784 if (!SvROK(ST(10)) || ! SvTYPE(SvRV(ST(10))))
2785 croak("i_fountain: argument 11 must be an array ref");
2787 asegs = (AV *)SvRV(ST(10));
2788 segs = load_fount_segs(aTHX_ asegs, &count);
2789 RETVAL = i_fountain(im, xa, ya, xb, yb, type, repeat, combine,
2790 super_sample, ssample_param, count, segs);
2796 i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2805 double ssample_param
2809 i_fountain_seg *segs;
2811 if (!SvROK(ST(9)) || ! SvTYPE(SvRV(ST(9))))
2812 croak("i_fountain: argument 11 must be an array ref");
2814 asegs = (AV *)SvRV(ST(9));
2815 segs = load_fount_segs(aTHX_ asegs, &count);
2816 RETVAL = i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine,
2817 super_sample, ssample_param, count, segs);
2823 i_new_fill_opacity(other_fill, alpha_mult)
2824 Imager::FillHandle other_fill
2835 errors = i_errors();
2837 while (errors[i].msg) {
2839 sv = newSVpv(errors[i].msg, strlen(errors[i].msg));
2840 if (!av_store(av, 0, sv)) {
2843 sv = newSViv(errors[i].code);
2844 if (!av_store(av, 1, sv)) {
2847 PUSHs(sv_2mortal(newRV_noinc((SV*)av)));
2855 i_push_error(code, msg)
2860 i_nearest_color(im, ...)
2875 croak("Usage: i_nearest_color(im, xo, yo, ival, dmeasure)");
2876 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2877 croak("i_nearest_color: Second argument must be an array ref");
2878 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
2879 croak("i_nearest_color: Third argument must be an array ref");
2880 if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
2881 croak("i_nearest_color: Fourth argument must be an array ref");
2882 axx = (AV *)SvRV(ST(1));
2883 ayy = (AV *)SvRV(ST(2));
2884 ac = (AV *)SvRV(ST(3));
2885 dmeasure = (int)SvIV(ST(4));
2887 num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
2888 num = num <= av_len(ac) ? num : av_len(ac);
2890 if (num < 2) croak("Usage: i_nearest_color array refs must have more than 1 entry each");
2891 xo = mymalloc( sizeof(i_img_dim) * num );
2892 yo = mymalloc( sizeof(i_img_dim) * num );
2893 ival = mymalloc( sizeof(i_color) * num );
2894 for(i = 0; i<num; i++) {
2895 xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0));
2896 yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0));
2897 sv = *av_fetch(ac, i, 0);
2898 if ( !sv_derived_from(sv, "Imager::Color") ) {
2899 free(axx); free(ayy); free(ac);
2900 croak("i_nearest_color: Element of fourth argument is not derived from Imager::Color");
2902 ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
2904 RETVAL = i_nearest_color(im, num, xo, yo, ival, dmeasure);
2918 rc=DSO_open(filename,&evstr);
2922 PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
2923 PUSHs(sv_2mortal(newSVpvn(evstr, strlen(evstr))));
2926 PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
2932 DSO_close(dso_handle)
2936 DSO_funclist(dso_handle_v)
2940 DSO_handle *dso_handle;
2941 func_ptr *functions;
2943 dso_handle=(DSO_handle*)dso_handle_v;
2944 functions = DSO_funclist(dso_handle);
2946 while( functions[i].name != NULL) {
2948 PUSHs(sv_2mortal(newSVpv(functions[i].name,0)));
2950 PUSHs(sv_2mortal(newSVpv(functions[i++].pcode,0)));
2954 DSO_call(handle,func_index,hv)
2960 if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to a hash\n");
2961 hv=(HV*)SvRV(ST(2));
2962 if (SvTYPE(hv)!=SVt_PVHV) croak("Imager: Parameter 2 must be a reference to a hash\n");
2963 DSO_call( (DSO_handle *)handle,func_index,hv);
2966 i_get_pixel(im, x, y)
2973 color = (i_color *)mymalloc(sizeof(i_color));
2974 if (i_gpix(im, x, y, color) == 0) {
2975 RETVAL = NEWSV(0, 0);
2976 sv_setref_pv(RETVAL, "Imager::Color", (void *)color);
2980 RETVAL = &PL_sv_undef;
2987 i_ppix(im, x, y, cl)
2994 i_img_pal_new(x, y, channels, maxpal)
3001 i_img_to_pal(src, quant)
3007 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
3008 croak("i_img_to_pal: second argument must be a hash ref");
3009 hv = (HV *)SvRV(ST(1));
3010 memset(&quant, 0, sizeof(quant));
3012 quant.mc_size = 256;
3013 ip_handle_quant_opts(aTHX_ &quant, hv);
3014 RETVAL = i_img_to_pal(src, &quant);
3016 ip_copy_colors_back(aTHX_ hv, &quant);
3018 ip_cleanup_quant_opts(aTHX_ &quant);
3027 i_img_make_palette(HV *quant_hv, ...)
3029 size_t count = items - 1;
3031 i_img **imgs = NULL;
3035 croak("Please supply at least one image (%d)", (int)count);
3036 imgs = mymalloc(sizeof(i_img *) * count);
3037 for (i = 0; i < count; ++i) {
3038 SV *img_sv = ST(i + 1);
3039 if (SvROK(img_sv) && sv_derived_from(img_sv, "Imager::ImgRaw")) {
3040 imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(img_sv)));
3044 croak("Image %d is not an image object", (int)i+1);
3047 memset(&quant, 0, sizeof(quant));
3049 quant.mc_size = 256;
3050 ip_handle_quant_opts(aTHX_ &quant, quant_hv);
3051 i_quant_makemap(&quant, imgs, count);
3052 EXTEND(SP, quant.mc_count);
3053 for (i = 0; i < quant.mc_count; ++i) {
3054 SV *sv_c = make_i_color_sv(aTHX_ quant.mc_colors + i);
3057 ip_cleanup_quant_opts(aTHX_ &quant);
3071 work = mymalloc((r-l) * sizeof(i_palidx));
3072 count = i_gpal(im, l, r, y, work);
3073 if (GIMME_V == G_ARRAY) {
3075 for (i = 0; i < count; ++i) {
3076 PUSHs(sv_2mortal(newSViv(work[i])));
3081 PUSHs(sv_2mortal(newSVpv((char *)work, count * sizeof(i_palidx))));
3086 if (GIMME_V != G_ARRAY) {
3088 PUSHs(&PL_sv_undef);
3093 i_ppal(im, l, y, ...)
3102 work = malloc_temp(aTHX_ sizeof(i_palidx) * (items-3));
3103 for (i=0; i < items-3; ++i) {
3104 work[i] = SvIV(ST(i+3));
3106 validate_i_ppal(im, work, items - 3);
3107 RETVAL = i_ppal(im, l, l+items-3, y, work);
3116 i_ppal_p(im, l, y, data)
3122 i_palidx const *work;
3125 work = (i_palidx const *)SvPV(data, len);
3126 len /= sizeof(i_palidx);
3128 validate_i_ppal(im, work, len);
3129 RETVAL = i_ppal(im, l, l+len, y, work);
3138 i_addcolors(im, ...)
3146 croak("i_addcolors: no colors to add");
3147 colors = mymalloc((items-1) * sizeof(i_color));
3148 for (i=0; i < items-1; ++i) {
3149 if (sv_isobject(ST(i+1))
3150 && sv_derived_from(ST(i+1), "Imager::Color")) {
3151 IV tmp = SvIV((SV *)SvRV(ST(i+1)));
3152 colors[i] = *INT2PTR(i_color *, tmp);
3156 croak("i_addcolor: pixels must be Imager::Color objects");
3159 index = i_addcolors(im, colors, items-1);
3162 RETVAL = newSVpv("0 but true", 0);
3164 else if (index == -1) {
3165 RETVAL = &PL_sv_undef;
3168 RETVAL = newSViv(index);
3174 i_setcolors(im, index, ...)
3182 croak("i_setcolors: no colors to add");
3183 colors = mymalloc((items-2) * sizeof(i_color));
3184 for (i=0; i < items-2; ++i) {
3185 if (sv_isobject(ST(i+2))
3186 && sv_derived_from(ST(i+2), "Imager::Color")) {
3187 IV tmp = SvIV((SV *)SvRV(ST(i+2)));
3188 colors[i] = *INT2PTR(i_color *, tmp);
3192 croak("i_setcolors: pixels must be Imager::Color objects");
3195 RETVAL = i_setcolors(im, index, colors, items-2);
3201 i_getcolors(im, index, ...)
3210 croak("i_getcolors: too many arguments");
3212 count = SvIV(ST(2));
3214 croak("i_getcolors: count must be positive");
3215 colors = mymalloc(sizeof(i_color) * count);
3216 if (i_getcolors(im, index, colors, count)) {
3217 for (i = 0; i < count; ++i) {
3218 SV *sv = make_i_color_sv(aTHX_ colors+i);
3234 i_findcolor(im, color)
3240 if (i_findcolor(im, color, &index)) {
3241 RETVAL = newSViv(index);
3244 RETVAL = &PL_sv_undef;
3262 i_gsamp(im, l, r, y, channels)
3267 i_channel_list channels
3273 data = mymalloc(sizeof(i_sample_t) * (r-l) * channels.count); /* XXX: memleak? */
3274 count = i_gsamp(im, l, r, y, data, channels.channels, channels.count);
3275 if (GIMME_V == G_ARRAY) {
3277 for (i = 0; i < count; ++i)
3278 PUSHs(sv_2mortal(newSViv(data[i])));
3282 PUSHs(sv_2mortal(newSVpv((char *)data, count * sizeof(i_sample_t))));
3287 if (GIMME_V != G_ARRAY) {
3289 PUSHs(&PL_sv_undef);
3294 i_gsamp_bits(im, l, r, y, bits, target, offset, channels)
3302 i_channel_list channels
3309 croak("No channel numbers supplied to g_samp()");
3311 data = mymalloc(sizeof(unsigned) * (r-l) * channels.count);
3312 count = i_gsamp_bits(im, l, r, y, data, channels.channels, channels.count, bits);
3313 for (i = 0; i < count; ++i) {
3314 av_store(target, i+offset, newSVuv(data[i]));
3326 i_psamp_bits(im, l, y, bits, channels, data_av, data_offset = 0, pixel_count = -1)
3331 i_channel_list channels
3333 i_img_dim data_offset
3334 i_img_dim pixel_count
3343 data_count = av_len(data_av) + 1;
3344 if (data_offset < 0) {
3345 croak("data_offset must be non-negative");
3347 if (data_offset > data_count) {
3348 croak("data_offset greater than number of samples supplied");
3350 if (pixel_count == -1 ||
3351 data_offset + pixel_count * channels.count > data_count) {
3352 pixel_count = (data_count - data_offset) / channels.count;
3355 data_used = pixel_count * channels.count;
3356 data = mymalloc(sizeof(unsigned) * data_count);
3357 for (i = 0; i < data_used; ++i)
3358 data[i] = SvUV(*av_fetch(data_av, data_offset + i, 0));
3360 RETVAL = i_psamp_bits(im, l, l + pixel_count, y, data, channels.channels,
3361 channels.count, bits);
3369 i_psamp(im, x, y, channels, data, offset = 0, width = -1)
3373 i_channel_list channels
3382 i_push_error(0, "offset must be non-negative");
3386 if (offset > data.count) {
3387 i_push_error(0, "offset greater than number of samples supplied");
3390 data.samples += offset;
3391 data.count -= offset;
3394 width * channels.count > data.count) {
3395 width = data.count / channels.count;
3398 RETVAL = i_psamp(im, x, r, y, data.samples, channels.channels, channels.count);
3403 i_psampf(im, x, y, channels, data, offset = 0, width = -1)
3407 i_channel_list channels
3416 i_push_error(0, "offset must be non-negative");
3420 if (offset > data.count) {
3421 i_push_error(0, "offset greater than number of samples supplied");
3424 data.samples += offset;
3425 data.count -= offset;
3428 width * channels.count > data.count) {
3429 width = data.count / channels.count;
3432 RETVAL = i_psampf(im, x, r, y, data.samples, channels.channels, channels.count);
3437 i_img_masked_new(targ, mask, x, y, w, h)
3447 if (!sv_isobject(ST(1))
3448 || !sv_derived_from(ST(1), "Imager::ImgRaw")) {
3449 croak("i_img_masked_new: parameter 2 must undef or an image");
3451 mask = INT2PTR(i_img *, SvIV((SV *)SvRV(ST(1))));
3455 RETVAL = i_img_masked_new(targ, mask, x, y, w, h);
3460 i_plin(im, l, y, ...)
3471 if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
3472 /* supplied as a byte string */
3473 work = (i_color *)SvPV(ST(3), len);
3474 count = len / sizeof(i_color);
3475 if (count * sizeof(i_color) != len) {
3476 croak("i_plin: length of scalar argument must be multiple of sizeof i_color");
3478 RETVAL = i_plin(im, l, l+count, y, work);
3481 work = mymalloc(sizeof(i_color) * (items-3));
3482 for (i=0; i < items-3; ++i) {
3483 if (sv_isobject(ST(i+3))
3484 && sv_derived_from(ST(i+3), "Imager::Color")) {
3485 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3486 work[i] = *INT2PTR(i_color *, tmp);
3490 croak("i_plin: pixels must be Imager::Color objects");
3493 RETVAL = i_plin(im, l, l+items-3, y, work);
3504 i_ppixf(im, x, y, cl)
3508 Imager::Color::Float cl
3511 i_gsampf(im, l, r, y, channels)
3516 i_channel_list channels
3522 data = mymalloc(sizeof(i_fsample_t) * (r-l) * channels.count);
3523 count = i_gsampf(im, l, r, y, data, channels.channels, channels.count);
3524 if (GIMME_V == G_ARRAY) {
3526 for (i = 0; i < count; ++i)
3527 PUSHs(sv_2mortal(newSVnv(data[i])));
3531 PUSHs(sv_2mortal(newSVpv((void *)data, count * sizeof(i_fsample_t))));
3536 if (GIMME_V != G_ARRAY) {
3538 PUSHs(&PL_sv_undef);
3543 i_plinf(im, l, y, ...)
3554 if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
3555 /* supplied as a byte string */
3556 work = (i_fcolor *)SvPV(ST(3), len);
3557 count = len / sizeof(i_fcolor);
3558 if (count * sizeof(i_fcolor) != len) {
3559 croak("i_plin: length of scalar argument must be multiple of sizeof i_fcolor");
3561 RETVAL = i_plinf(im, l, l+count, y, work);
3564 work = mymalloc(sizeof(i_fcolor) * (items-3));
3565 for (i=0; i < items-3; ++i) {
3566 if (sv_isobject(ST(i+3))
3567 && sv_derived_from(ST(i+3), "Imager::Color::Float")) {
3568 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3569 work[i] = *INT2PTR(i_fcolor *, tmp);
3573 croak("i_plinf: pixels must be Imager::Color::Float objects");
3577 RETVAL = i_plinf(im, l, l+items-3, y, work);
3595 color = (i_fcolor *)mymalloc(sizeof(i_fcolor));
3596 if (i_gpixf(im, x, y, color) == 0) {
3597 RETVAL = NEWSV(0,0);
3598 sv_setref_pv(RETVAL, "Imager::Color::Float", (void *)color);
3602 RETVAL = &PL_sv_undef;
3618 vals = mymalloc((r-l) * sizeof(i_color));
3619 memset(vals, 0, (r-l) * sizeof(i_color));
3620 count = i_glin(im, l, r, y, vals);
3621 if (GIMME_V == G_ARRAY) {
3623 for (i = 0; i < count; ++i) {
3624 SV *sv = make_i_color_sv(aTHX_ vals+i);
3630 PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_color))));
3636 i_glinf(im, l, r, y)
3646 for (i = 0; i < MAXCHANNELS; ++i)
3647 zero.channel[i] = 0;
3649 vals = mymalloc((r-l) * sizeof(i_fcolor));
3650 for (i = 0; i < r-l; ++i)
3652 count = i_glinf(im, l, r, y, vals);
3653 if (GIMME_V == G_ARRAY) {
3655 for (i = 0; i < count; ++i) {
3657 i_fcolor *col = mymalloc(sizeof(i_fcolor));
3659 sv = sv_newmortal();
3660 sv_setref_pv(sv, "Imager::Color::Float", (void *)col);
3666 PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_fcolor))));
3672 i_img_8_new(x, y, ch)
3678 i_img_16_new(x, y, ch)
3688 i_img_double_new(x, y, ch)
3698 i_tags_addn(im, name, code, idata)
3707 name = SvPV(ST(1), len);
3710 RETVAL = i_tags_addn(&im->tags, name, code, idata);
3715 i_tags_add(im, name, code, data, idata)
3725 name = SvPV(ST(1), len);
3729 data = SvPV(ST(3), len);
3734 RETVAL = i_tags_add(&im->tags, name, code, data, len, idata);
3739 i_tags_find(im, name, start)
3746 if (i_tags_find(&im->tags, name, start, &entry)) {
3748 RETVAL = newSVpv("0 but true", 0);
3750 RETVAL = newSViv(entry);
3752 RETVAL = &PL_sv_undef;
3758 i_tags_findn(im, code, start)
3765 if (i_tags_findn(&im->tags, code, start, &entry)) {
3767 RETVAL = newSVpv("0 but true", 0);
3769 RETVAL = newSViv(entry);
3772 RETVAL = &PL_sv_undef;
3778 i_tags_delete(im, entry)
3782 RETVAL = i_tags_delete(&im->tags, entry);
3787 i_tags_delbyname(im, name)
3791 RETVAL = i_tags_delbyname(&im->tags, name);
3796 i_tags_delbycode(im, code)
3800 RETVAL = i_tags_delbycode(&im->tags, code);
3805 i_tags_get(im, index)
3809 if (index >= 0 && index < im->tags.count) {
3810 i_img_tag *entry = im->tags.tags + index;
3814 PUSHs(sv_2mortal(newSVpv(entry->name, 0)));
3817 PUSHs(sv_2mortal(newSViv(entry->code)));
3820 PUSHs(sv_2mortal(newSVpvn(entry->data, entry->size)));
3823 PUSHs(sv_2mortal(newSViv(entry->idata)));
3828 i_tags_get_string(im, what_sv)
3832 char const *name = NULL;
3836 if (SvIOK(what_sv)) {
3837 code = SvIV(what_sv);
3841 name = SvPV_nolen(what_sv);
3844 if (i_tags_get_string(&im->tags, name, code, buffer, sizeof(buffer))) {
3846 PUSHs(sv_2mortal(newSVpv(buffer, 0)));
3853 RETVAL = im->tags.count;
3859 MODULE = Imager PACKAGE = Imager::FillHandle PREFIX=IFILL_
3863 Imager::FillHandle fill
3866 IFILL_CLONE_SKIP(...)
3868 (void)items; /* avoid unused warning for XS variable */
3873 MODULE = Imager PACKAGE = Imager
3876 i_new_fill_solid(cl, combine)
3881 i_new_fill_solidf(cl, combine)
3882 Imager::Color::Float cl
3886 i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy)
3894 unsigned char *cust_hatch;
3898 cust_hatch = (unsigned char *)SvPV(ST(4), len);
3902 RETVAL = i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy);
3907 i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy)
3908 Imager::Color::Float fg
3909 Imager::Color::Float bg
3915 unsigned char *cust_hatch;
3919 cust_hatch = (unsigned char *)SvPV(ST(4), len);
3923 RETVAL = i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy);
3928 i_new_fill_image(src, matrix, xoff, yoff, combine)
3945 if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
3946 croak("i_new_fill_image: parameter must be an arrayref");
3947 av=(AV*)SvRV(ST(1));
3951 for (i = 0; i < len; ++i) {
3952 sv1=(*(av_fetch(av,i,0)));
3953 matrix[i] = SvNV(sv1);
3959 RETVAL = i_new_fill_image(src, matrixp, xoff, yoff, combine);
3963 MODULE = Imager PACKAGE = Imager::Internal::Hlines PREFIX=i_int_hlines_
3965 # this class is only exposed for testing
3968 i_int_hlines_testing()
3970 #if i_int_hlines_testing()
3972 Imager::Internal::Hlines
3973 i_int_hlines_new(start_y, count_y, start_x, count_x)
3979 Imager::Internal::Hlines
3980 i_int_hlines_new_img(im)
3984 i_int_hlines_add(hlines, y, minx, width)
3985 Imager::Internal::Hlines hlines
3991 i_int_hlines_DESTROY(hlines)
3992 Imager::Internal::Hlines hlines
3995 i_int_hlines_dump(hlines)
3996 Imager::Internal::Hlines hlines
3999 i_int_hlines_CLONE_SKIP(cls)
4004 PERL_SET_GLOBAL_CALLBACKS;
4005 PERL_PL_SET_GLOBAL_CALLBACKS;
4006 work_context = im_context_new();
4007 im_get_context = perl_get_context;