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 /* used to represent channel lists parameters */
33 typedef struct i_channel_list_tag {
40 const i_sample_t *samples;
45 const i_fsample_t *samples;
50 Allocate memory that will be discarded when mortals are discarded.
55 malloc_temp(pTHX_ size_t size) {
56 SV *sv = sv_2mortal(newSV(size));
61 /* These functions are all shared - then comes platform dependant code */
62 static int getstr(void *hv_t,char *key,char **store) {
67 mm_log((1,"getstr(hv_t %p, key %s, store %p)\n",hv_t,key,store));
69 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
71 svpp=hv_fetch(hv, key, strlen(key), 0);
72 *store=SvPV(*svpp, PL_na );
77 static int getint(void *hv_t,char *key,int *store) {
82 mm_log((1,"getint(hv_t %p, key %s, store %p)\n",hv_t,key,store));
84 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
86 svpp=hv_fetch(hv, key, strlen(key), 0);
87 *store=(int)SvIV(*svpp);
91 static int getdouble(void *hv_t,char* key,double *store) {
96 mm_log((1,"getdouble(hv_t %p, key %s, store %p)\n",hv_t,key,store));
98 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
99 svpp=hv_fetch(hv, key, strlen(key), 0);
100 *store=(double)SvNV(*svpp);
104 static int getvoid(void *hv_t,char* key,void **store) {
109 mm_log((1,"getvoid(hv_t %p, key %s, store %p)\n",hv_t,key,store));
111 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
113 svpp=hv_fetch(hv, key, strlen(key), 0);
114 *store = INT2PTR(void*, SvIV(*svpp));
119 static int getobj(void *hv_t,char *key,char *type,void **store) {
124 mm_log((1,"getobj(hv_t %p, key %s,type %s, store %p)\n",hv_t,key,type,store));
126 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
128 svpp=hv_fetch(hv, key, strlen(key), 0);
130 if (sv_derived_from(*svpp,type)) {
131 IV tmp = SvIV((SV*)SvRV(*svpp));
132 *store = INT2PTR(void*, tmp);
134 mm_log((1,"getobj: key exists in hash but is not of correct type"));
141 UTIL_table_t i_UTIL_table={getstr,getint,getdouble,getvoid,getobj};
143 void my_SvREFCNT_dec(void *p) {
145 SvREFCNT_dec((SV*)p);
150 i_log_entry(char *string, int level) {
151 mm_log((level, "%s", string));
155 make_i_color_sv(pTHX_ const i_color *c) {
157 i_color *col = mymalloc(sizeof(i_color));
160 sv_setref_pv(sv, "Imager::Color", (void *)col);
165 #define CBDATA_BUFSIZE 8192
168 /* the SVs we use to call back to Perl */
176 call_reader(struct cbdata *cbd, void *buf, size_t size,
184 if (!SvOK(cbd->readcb)) {
185 mm_log((1, "read callback called but no readcb supplied\n"));
186 i_push_error(0, "read callback called but no readcb supplied");
194 PUSHs(sv_2mortal(newSViv(size)));
195 PUSHs(sv_2mortal(newSViv(maxread)));
198 count = perl_call_sv(cbd->readcb, G_SCALAR);
203 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
209 char *ptr = SvPVbyte(data, len);
211 croak("Too much data returned in reader callback (wanted %d, got %d, expected %d)",
212 (int)size, (int)len, (int)maxread);
214 memcpy(buf, ptr, len);
229 io_seeker(void *p, off_t offset, int whence) {
231 struct cbdata *cbd = p;
236 if (!SvOK(cbd->seekcb)) {
237 mm_log((1, "seek callback called but no seekcb supplied\n"));
238 i_push_error(0, "seek callback called but no seekcb supplied");
246 PUSHs(sv_2mortal(newSViv(offset)));
247 PUSHs(sv_2mortal(newSViv(whence)));
250 count = perl_call_sv(cbd->seekcb, G_SCALAR);
255 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
267 io_writer(void *p, void const *data, size_t size) {
269 struct cbdata *cbd = p;
275 if (!SvOK(cbd->writecb)) {
276 mm_log((1, "write callback called but no writecb supplied\n"));
277 i_push_error(0, "write callback called but no writecb supplied");
285 PUSHs(sv_2mortal(newSVpv((char *)data, size)));
288 count = perl_call_sv(cbd->writecb, G_SCALAR);
292 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
295 success = SvTRUE(sv);
302 return success ? size : -1;
306 io_reader(void *p, void *data, size_t size) {
307 struct cbdata *cbd = p;
309 return call_reader(cbd, data, size, size);
312 static int io_closer(void *p) {
314 struct cbdata *cbd = p;
317 if (SvOK(cbd->closecb)) {
327 count = perl_call_sv(cbd->closecb, G_SCALAR);
332 success = SvTRUE(sv);
339 return success ? 0 : -1;
342 static void io_destroyer(void *p) {
344 struct cbdata *cbd = p;
346 SvREFCNT_dec(cbd->writecb);
347 SvREFCNT_dec(cbd->readcb);
348 SvREFCNT_dec(cbd->seekcb);
349 SvREFCNT_dec(cbd->closecb);
354 do_io_new_buffer(pTHX_ SV *data_sv) {
358 data = SvPVbyte(data_sv, length);
359 SvREFCNT_inc(data_sv);
360 return io_new_buffer(data, length, my_SvREFCNT_dec, data_sv);
364 describe_sv(SV *sv) {
367 svtype type = SvTYPE(SvRV(sv));
369 case SVt_PVCV: return "CV";
370 case SVt_PVGV: return "GV";
371 case SVt_PVLV: return "LV";
372 default: return "some reference";
376 return "non-reference scalar";
385 do_io_new_cb(pTHX_ SV *writecb, SV *readcb, SV *seekcb, SV *closecb) {
388 cbd = mymalloc(sizeof(struct cbdata));
389 cbd->writecb = newSVsv(writecb);
390 cbd->readcb = newSVsv(readcb);
391 cbd->seekcb = newSVsv(seekcb);
392 cbd->closecb = newSVsv(closecb);
394 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)));
396 return io_new_cb(cbd, io_reader, io_writer, io_seeker, io_closer,
404 static int lookup_name(struct value_name *names, int count, char *name, int def_value)
407 for (i = 0; i < count; ++i)
408 if (strEQ(names[i].name, name))
409 return names[i].value;
413 static struct value_name transp_names[] =
416 { "threshold", tr_threshold },
417 { "errdiff", tr_errdiff },
418 { "ordered", tr_ordered, },
421 static struct value_name make_color_names[] =
423 { "none", mc_none, },
424 { "webmap", mc_web_map, },
425 { "addi", mc_addi, },
426 { "mediancut", mc_median_cut, },
427 { "mono", mc_mono, },
428 { "monochrome", mc_mono, },
429 { "gray", mc_gray, },
430 { "gray4", mc_gray4, },
431 { "gray16", mc_gray16, },
434 static struct value_name translate_names[] =
436 { "giflib", pt_giflib, },
437 { "closest", pt_closest, },
438 { "perturb", pt_perturb, },
439 { "errdiff", pt_errdiff, },
442 static struct value_name errdiff_names[] =
444 { "floyd", ed_floyd, },
445 { "jarvis", ed_jarvis, },
446 { "stucki", ed_stucki, },
447 { "custom", ed_custom, },
450 static struct value_name orddith_names[] =
452 { "random", od_random, },
453 { "dot8", od_dot8, },
454 { "dot4", od_dot4, },
455 { "hline", od_hline, },
456 { "vline", od_vline, },
457 { "/line", od_slashline, },
458 { "slashline", od_slashline, },
459 { "\\line", od_backline, },
460 { "backline", od_backline, },
461 { "tiny", od_tiny, },
462 { "custom", od_custom, },
465 /* look through the hash for quantization options */
467 ip_handle_quant_opts(pTHX_ i_quantize *quant, HV *hv)
469 /*** POSSIBLY BROKEN: do I need to unref the SV from hv_fetch ***/
475 quant->mc_colors = mymalloc(quant->mc_size * sizeof(i_color));
477 sv = hv_fetch(hv, "transp", 6, 0);
478 if (sv && *sv && (str = SvPV(*sv, len))) {
480 lookup_name(transp_names, sizeof(transp_names)/sizeof(*transp_names),
482 if (quant->transp != tr_none) {
483 quant->tr_threshold = 127;
484 sv = hv_fetch(hv, "tr_threshold", 12, 0);
486 quant->tr_threshold = SvIV(*sv);
488 if (quant->transp == tr_errdiff) {
489 sv = hv_fetch(hv, "tr_errdiff", 10, 0);
490 if (sv && *sv && (str = SvPV(*sv, len)))
491 quant->tr_errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
493 if (quant->transp == tr_ordered) {
494 quant->tr_orddith = od_tiny;
495 sv = hv_fetch(hv, "tr_orddith", 10, 0);
496 if (sv && *sv && (str = SvPV(*sv, len)))
497 quant->tr_orddith = lookup_name(orddith_names, sizeof(orddith_names)/sizeof(*orddith_names), str, od_random);
499 if (quant->tr_orddith == od_custom) {
500 sv = hv_fetch(hv, "tr_map", 6, 0);
501 if (sv && *sv && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
502 AV *av = (AV*)SvRV(*sv);
503 len = av_len(av) + 1;
504 if (len > sizeof(quant->tr_custom))
505 len = sizeof(quant->tr_custom);
506 for (i = 0; i < len; ++i) {
507 SV **sv2 = av_fetch(av, i, 0);
509 quant->tr_custom[i] = SvIV(*sv2);
512 while (i < sizeof(quant->tr_custom))
513 quant->tr_custom[i++] = 0;
518 quant->make_colors = mc_median_cut;
519 sv = hv_fetch(hv, "make_colors", 11, 0);
520 if (sv && *sv && (str = SvPV(*sv, len))) {
522 lookup_name(make_color_names, sizeof(make_color_names)/sizeof(*make_color_names), str, mc_median_cut);
524 sv = hv_fetch(hv, "colors", 6, 0);
525 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
526 /* needs to be an array of Imager::Color
527 note that the caller allocates the mc_color array and sets mc_size
529 AV *av = (AV *)SvRV(*sv);
530 quant->mc_count = av_len(av)+1;
531 if (quant->mc_count > quant->mc_size)
532 quant->mc_count = quant->mc_size;
533 for (i = 0; i < quant->mc_count; ++i) {
534 SV **sv1 = av_fetch(av, i, 0);
535 if (sv1 && *sv1 && SvROK(*sv1) && sv_derived_from(*sv1, "Imager::Color")) {
536 i_color *col = INT2PTR(i_color *, SvIV((SV*)SvRV(*sv1)));
537 quant->mc_colors[i] = *col;
541 sv = hv_fetch(hv, "max_colors", 10, 0);
544 if (i <= quant->mc_size && i >= quant->mc_count)
548 quant->translate = pt_closest;
549 sv = hv_fetch(hv, "translate", 9, 0);
550 if (sv && *sv && (str = SvPV(*sv, len))) {
551 quant->translate = lookup_name(translate_names, sizeof(translate_names)/sizeof(*translate_names), str, pt_closest);
553 sv = hv_fetch(hv, "errdiff", 7, 0);
554 if (sv && *sv && (str = SvPV(*sv, len))) {
555 quant->errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
557 if (quant->translate == pt_errdiff && quant->errdiff == ed_custom) {
558 /* get the error diffusion map */
559 sv = hv_fetch(hv, "errdiff_width", 13, 0);
561 quant->ed_width = SvIV(*sv);
562 sv = hv_fetch(hv, "errdiff_height", 14, 0);
564 quant->ed_height = SvIV(*sv);
565 sv = hv_fetch(hv, "errdiff_orig", 12, 0);
567 quant->ed_orig = SvIV(*sv);
568 if (quant->ed_width > 0 && quant->ed_height > 0) {
570 quant->ed_map = mymalloc(sizeof(int)*quant->ed_width*quant->ed_height);
571 sv = hv_fetch(hv, "errdiff_map", 11, 0);
572 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
573 AV *av = (AV*)SvRV(*sv);
574 len = av_len(av) + 1;
575 if (len > quant->ed_width * quant->ed_height)
576 len = quant->ed_width * quant->ed_height;
577 for (i = 0; i < len; ++i) {
578 SV **sv2 = av_fetch(av, i, 0);
580 quant->ed_map[i] = SvIV(*sv2);
581 sum += quant->ed_map[i];
587 myfree(quant->ed_map);
589 quant->errdiff = ed_floyd;
593 sv = hv_fetch(hv, "perturb", 7, 0);
595 quant->perturb = SvIV(*sv);
599 ip_cleanup_quant_opts(pTHX_ i_quantize *quant) {
600 myfree(quant->mc_colors);
602 myfree(quant->ed_map);
605 /* copies the color map from the hv into the colors member of the HV */
607 ip_copy_colors_back(pTHX_ HV *hv, i_quantize *quant) {
613 sv = hv_fetch(hv, "colors", 6, 0);
614 if (!sv || !*sv || !SvROK(*sv) || SvTYPE(SvRV(*sv)) != SVt_PVAV) {
619 av = (AV *)SvRV(*sv);
621 av_extend(av, quant->mc_count+1);
622 for (i = 0; i < quant->mc_count; ++i) {
623 i_color *in = quant->mc_colors+i;
624 Imager__Color c = ICL_new_internal(in->rgb.r, in->rgb.g, in->rgb.b, 255);
625 work = sv_newmortal();
626 sv_setref_pv(work, "Imager::Color", (void *)c);
632 /* loads the segments of a fountain fill into an array */
633 static i_fountain_seg *
634 load_fount_segs(pTHX_ AV *asegs, int *count) {
635 /* Each element of segs must contain:
636 [ start, middle, end, c0, c1, segtype, colortrans ]
637 start, middle, end are doubles from 0 to 1
638 c0, c1 are Imager::Color::Float or Imager::Color objects
639 segtype, colortrans are ints
643 i_fountain_seg *segs;
647 *count = av_len(asegs)+1;
649 croak("i_fountain must have at least one segment");
650 segs = mymalloc(sizeof(i_fountain_seg) * *count);
651 for(i = 0; i < *count; i++) {
652 SV **sv1 = av_fetch(asegs, i, 0);
653 if (!sv1 || !*sv1 || !SvROK(*sv1)
654 || SvTYPE(SvRV(*sv1)) != SVt_PVAV) {
656 croak("i_fountain: segs must be an arrayref of arrayrefs");
658 aseg = (AV *)SvRV(*sv1);
659 if (av_len(aseg) != 7-1) {
661 croak("i_fountain: a segment must have 7 members");
663 for (j = 0; j < 3; ++j) {
664 SV **sv2 = av_fetch(aseg, j, 0);
667 croak("i_fountain: XS error");
669 work[j] = SvNV(*sv2);
671 segs[i].start = work[0];
672 segs[i].middle = work[1];
673 segs[i].end = work[2];
674 for (j = 0; j < 2; ++j) {
675 SV **sv3 = av_fetch(aseg, 3+j, 0);
676 if (!sv3 || !*sv3 || !SvROK(*sv3) ||
677 (!sv_derived_from(*sv3, "Imager::Color")
678 && !sv_derived_from(*sv3, "Imager::Color::Float"))) {
680 croak("i_fountain: segs must contain colors in elements 3 and 4");
682 if (sv_derived_from(*sv3, "Imager::Color::Float")) {
683 segs[i].c[j] = *INT2PTR(i_fcolor *, SvIV((SV *)SvRV(*sv3)));
686 i_color c = *INT2PTR(i_color *, SvIV((SV *)SvRV(*sv3)));
688 for (ch = 0; ch < MAXCHANNELS; ++ch) {
689 segs[i].c[j].channel[ch] = c.channel[ch] / 255.0;
693 for (j = 0; j < 2; ++j) {
694 SV **sv2 = av_fetch(aseg, j+5, 0);
697 croak("i_fountain: XS error");
699 worki[j] = SvIV(*sv2);
701 segs[i].type = worki[0];
702 segs[i].color = worki[1];
708 /* validates the indexes supplied to i_ppal
710 i_ppal() doesn't do that for speed, but I'm not comfortable doing that
715 validate_i_ppal(i_img *im, i_palidx const *indexes, int count) {
716 int color_count = i_colorcount(im);
719 if (color_count == -1)
720 croak("i_plin() called on direct color image");
722 for (i = 0; i < count; ++i) {
723 if (indexes[i] >= color_count) {
724 croak("i_plin() called with out of range color index %d (max %d)",
725 indexes[i], color_count-1);
731 /* I don't think ICLF_* names belong at the C interface
732 this makes the XS code think we have them, to let us avoid
733 putting function bodies in the XS code
735 #define ICLF_new_internal(r, g, b, a) i_fcolor_new((r), (g), (b), (a))
736 #define ICLF_DESTROY(cl) i_fcolor_destroy(cl)
739 #define i_log_enabled() 1
741 #define i_log_enabled() 0
744 #if i_int_hlines_testing()
746 typedef i_int_hlines *Imager__Internal__Hlines;
748 static i_int_hlines *
749 i_int_hlines_new(i_img_dim start_y, i_img_dim count_y, i_img_dim start_x, i_img_dim count_x) {
750 i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
751 i_int_init_hlines(result, start_y, count_y, start_x, count_x);
756 static i_int_hlines *
757 i_int_hlines_new_img(i_img *im) {
758 i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
759 i_int_init_hlines_img(result, im);
765 i_int_hlines_DESTROY(i_int_hlines *hlines) {
766 i_int_hlines_destroy(hlines);
770 #define i_int_hlines_CLONE_SKIP(cls) 1
772 static int seg_compare(const void *vleft, const void *vright) {
773 const i_int_hline_seg *left = vleft;
774 const i_int_hline_seg *right = vright;
776 return left->minx - right->minx;
780 i_int_hlines_dump(i_int_hlines *hlines) {
782 SV *dump = newSVpvf("start_y: %" i_DF " limit_y: %" i_DF " start_x: %" i_DF " limit_x: %" i_DF"\n",
783 i_DFc(hlines->start_y), i_DFc(hlines->limit_y), i_DFc(hlines->start_x), i_DFc(hlines->limit_x));
786 for (y = hlines->start_y; y < hlines->limit_y; ++y) {
787 i_int_hline_entry *entry = hlines->entries[y-hlines->start_y];
790 /* sort the segments, if any */
792 qsort(entry->segs, entry->count, sizeof(i_int_hline_seg), seg_compare);
794 sv_catpvf(dump, " %" i_DF " (%" i_DF "):", i_DFc(y), i_DFc(entry->count));
795 for (i = 0; i < entry->count; ++i) {
796 sv_catpvf(dump, " [%" i_DF ", %" i_DF ")", i_DFc(entry->segs[i].minx),
797 i_DFc(entry->segs[i].x_limit));
799 sv_catpv(dump, "\n");
809 i_sv_off_t(pTHX_ SV *sv) {
810 #if LSEEKSIZE > IVSIZE
811 return (off_t)SvNV(sv);
813 return (off_t)SvIV(sv);
818 i_new_sv_off_t(pTHX_ off_t off) {
819 #if LSEEKSIZE > IVSIZE
826 static im_pl_ext_funcs im_perl_funcs =
828 IMAGER_PL_API_VERSION,
830 ip_handle_quant_opts,
831 ip_cleanup_quant_opts,
835 #define PERL_PL_SET_GLOBAL_CALLBACKS \
836 sv_setiv(get_sv(PERL_PL_FUNCTION_TABLE_NAME, 1), PTR2IV(&im_perl_funcs));
838 #define IIM_new i_img_8_new
839 #define IIM_DESTROY i_img_destroy
842 #define i_exif_enabled() 1
844 #define i_exif_enabled() 0
847 /* trying to use more C style names, map them here */
848 #define i_io_DESTROY(ig) io_glue_destroy(ig)
850 #define i_img_get_width(im) ((im)->xsize)
851 #define i_img_get_height(im) ((im)->ysize)
853 #define i_img_epsilonf() (DBL_EPSILON * 4)
855 /* avoid some xsubpp strangeness */
858 MODULE = Imager PACKAGE = Imager::Color PREFIX = ICL_
861 ICL_new_internal(r,g,b,a)
873 ICL_set_internal(cl,r,g,b,a)
880 ICL_set_internal(cl, r, g, b, a);
894 PUSHs(sv_2mortal(newSVnv(cl->rgba.r)));
895 PUSHs(sv_2mortal(newSVnv(cl->rgba.g)));
896 PUSHs(sv_2mortal(newSVnv(cl->rgba.b)));
897 PUSHs(sv_2mortal(newSVnv(cl->rgba.a)));
903 RETVAL = mymalloc(sizeof(i_color));
905 i_hsv_to_rgb(RETVAL);
913 RETVAL = mymalloc(sizeof(i_color));
915 i_rgb_to_hsv(RETVAL);
921 MODULE = Imager PACKAGE = Imager::Color::Float PREFIX=ICLF_
924 ICLF_new_internal(r, g, b, a)
932 Imager::Color::Float cl
936 Imager::Color::Float cl
940 EXTEND(SP, MAXCHANNELS);
941 for (ch = 0; ch < MAXCHANNELS; ++ch) {
942 /* printf("%d: %g\n", ch, cl->channel[ch]); */
943 PUSHs(sv_2mortal(newSVnv(cl->channel[ch])));
947 ICLF_set_internal(cl,r,g,b,a)
948 Imager::Color::Float cl
963 Imager::Color::Float c
965 RETVAL = mymalloc(sizeof(i_fcolor));
967 i_hsv_to_rgbf(RETVAL);
973 Imager::Color::Float c
975 RETVAL = mymalloc(sizeof(i_fcolor));
977 i_rgb_to_hsvf(RETVAL);
981 MODULE = Imager PACKAGE = Imager::ImgRaw PREFIX = IIM_
995 MODULE = Imager PACKAGE = Imager
1009 io_new_buffer(data_sv)
1012 RETVAL = do_io_new_buffer(aTHX_ data_sv);
1017 io_new_cb(writecb, readcb, seekcb, closecb, maxwrite = CBDATA_BUFSIZE)
1024 RETVAL = do_io_new_cb(aTHX_ writecb, readcb, seekcb, closecb);
1032 unsigned char* data;
1036 tlength = io_slurp(ig, &data);
1037 RETVAL = newSVpv((char *)data,tlength);
1044 i_set_image_file_limits(width, height, bytes)
1050 i_get_image_file_limits()
1052 i_img_dim width, height;
1055 if (i_get_image_file_limits(&width, &height, &bytes)) {
1057 PUSHs(sv_2mortal(newSViv(width)));
1058 PUSHs(sv_2mortal(newSViv(height)));
1059 PUSHs(sv_2mortal(newSVuv(bytes)));
1063 i_int_check_image_file_limits(width, height, channels, sample_size)
1070 MODULE = Imager PACKAGE = Imager::IO PREFIX = io_
1073 io_new_fd(class, fd)
1076 RETVAL = io_new_fd(fd);
1081 io_new_buffer(class, data_sv)
1084 RETVAL = do_io_new_buffer(aTHX_ data_sv);
1089 io_new_cb(class, writecb, readcb, seekcb, closecb)
1095 RETVAL = do_io_new_cb(aTHX_ writecb, readcb, seekcb, closecb);
1100 io_new_bufchain(class)
1102 RETVAL = io_new_bufchain();
1110 unsigned char* data;
1114 tlength = io_slurp(ig, &data);
1115 RETVAL = newSVpv((char *)data,tlength);
1120 MODULE = Imager PACKAGE = Imager::IO PREFIX = i_io_
1123 i_io_raw_write(ig, data_sv)
1131 if (SvUTF8(data_sv)) {
1132 data_sv = sv_2mortal(newSVsv(data_sv));
1133 /* yes, we want this to croak() if the SV can't be downgraded */
1134 sv_utf8_downgrade(data_sv, FALSE);
1137 data = SvPV(data_sv, size);
1138 RETVAL = i_io_raw_write(ig, data, size);
1143 i_io_raw_read(ig, buffer_sv, size)
1152 croak("size negative in call to i_io_raw_read()");
1153 /* prevent an undefined value warning if they supplied an
1155 Orginally conditional on !SvOK(), but this will prevent the
1156 downgrade from croaking */
1157 sv_setpvn(buffer_sv, "", 0);
1159 if (SvUTF8(buffer_sv))
1160 sv_utf8_downgrade(buffer_sv, FALSE);
1162 buffer = SvGROW(buffer_sv, size+1);
1163 result = i_io_raw_read(ig, buffer, size);
1165 SvCUR_set(buffer_sv, result);
1166 *SvEND(buffer_sv) = '\0';
1167 SvPOK_only(buffer_sv);
1169 PUSHs(sv_2mortal(newSViv(result)));
1175 i_io_raw_read2(ig, size)
1184 croak("size negative in call to i_io_read2()");
1185 buffer_sv = newSV(size);
1186 buffer = SvGROW(buffer_sv, size+1);
1187 result = i_io_raw_read(ig, buffer, size);
1189 SvCUR_set(buffer_sv, result);
1190 *SvEND(buffer_sv) = '\0';
1191 SvPOK_only(buffer_sv);
1193 PUSHs(sv_2mortal(buffer_sv));
1197 SvREFCNT_dec(buffer_sv);
1201 i_io_raw_seek(ig, position, whence)
1215 i_io_CLONE_SKIP(...)
1217 (void)items; /* avoid unused warning for XS variable */
1244 i_io_seek(ig, off, whence)
1250 i_io_peekn(ig, size)
1258 buffer_sv = newSV(size+1);
1259 buffer = SvGROW(buffer_sv, size+1);
1260 result = i_io_peekn(ig, buffer, size);
1262 SvCUR_set(buffer_sv, result);
1263 *SvEND(buffer_sv) = '\0';
1264 SvPOK_only(buffer_sv);
1266 PUSHs(sv_2mortal(buffer_sv));
1270 SvREFCNT_dec(buffer_sv);
1274 i_io_read(ig, buffer_sv, size)
1283 croak("size negative in call to i_io_read()");
1284 /* prevent an undefined value warning if they supplied an
1286 Orginally conditional on !SvOK(), but this will prevent the
1287 downgrade from croaking */
1288 sv_setpvn(buffer_sv, "", 0);
1290 if (SvUTF8(buffer_sv))
1291 sv_utf8_downgrade(buffer_sv, FALSE);
1293 buffer = SvGROW(buffer_sv, size+1);
1294 result = i_io_read(ig, buffer, size);
1296 SvCUR_set(buffer_sv, result);
1297 *SvEND(buffer_sv) = '\0';
1298 SvPOK_only(buffer_sv);
1300 PUSHs(sv_2mortal(newSViv(result)));
1306 i_io_read2(ig, size)
1315 croak("size zero in call to read2()");
1316 buffer_sv = newSV(size);
1317 buffer = SvGROW(buffer_sv, size+1);
1318 result = i_io_read(ig, buffer, size);
1320 SvCUR_set(buffer_sv, result);
1321 *SvEND(buffer_sv) = '\0';
1322 SvPOK_only(buffer_sv);
1324 PUSHs(sv_2mortal(buffer_sv));
1328 SvREFCNT_dec(buffer_sv);
1332 i_io_gets(ig, size = 8192, eol = NEWLINE)
1342 croak("size too small in call to gets()");
1343 buffer_sv = sv_2mortal(newSV(size+1));
1344 buffer = SvPVX(buffer_sv);
1345 result = i_io_gets(ig, buffer, size+1, eol);
1347 SvCUR_set(buffer_sv, result);
1348 *SvEND(buffer_sv) = '\0';
1349 SvPOK_only(buffer_sv);
1355 i_io_write(ig, data_sv)
1363 if (SvUTF8(data_sv)) {
1364 data_sv = sv_2mortal(newSVsv(data_sv));
1365 /* yes, we want this to croak() if the SV can't be downgraded */
1366 sv_utf8_downgrade(data_sv, FALSE);
1369 data = SvPV(data_sv, size);
1370 RETVAL = i_io_write(ig, data, size);
1375 i_io_dump(ig, flags = I_IO_DUMP_DEFAULT)
1380 i_io_set_buffered(ig, flag = 1)
1385 i_io_is_buffered(ig)
1396 MODULE = Imager PACKAGE = Imager
1407 while( (item=i_format_list[i++]) != NULL ) {
1409 PUSHs(sv_2mortal(newSVpv(item,0)));
1413 i_sametype(im, x, y)
1419 i_sametype_chans(im, x, y, channels)
1426 i_init_log(name_sv,level)
1430 const char *name = SvOK(name_sv) ? SvPV_nolen(name_sv) : NULL;
1432 RETVAL = i_init_log(name, level);
1437 i_log_entry(string,level)
1450 i_img_info(im,info);
1452 PUSHs(sv_2mortal(newSViv(info[0])));
1453 PUSHs(sv_2mortal(newSViv(info[1])));
1454 PUSHs(sv_2mortal(newSViv(info[2])));
1455 PUSHs(sv_2mortal(newSViv(info[3])));
1461 i_img_setmask(im,ch_mask)
1470 i_img_getchannels(im)
1479 sv_2mortal(newSVpv((char *)im->idata, im->bytes))
1487 i_img_get_height(im)
1492 i_img_is_monochrome(im)
1498 result = i_img_is_monochrome(im, &zero_is_white);
1500 if (GIMME_V == G_ARRAY) {
1503 PUSHs(sv_2mortal(newSViv(zero_is_white)));
1512 i_line(im,x1,y1,x2,y2,val,endp)
1522 i_line_aa(im,x1,y1,x2,y2,val,endp)
1532 i_box(im,x1,y1,x2,y2,val)
1541 i_box_filled(im,x1,y1,x2,y2,val)
1550 i_box_filledf(im,x1,y1,x2,y2,val)
1556 Imager::Color::Float val
1559 i_box_cfill(im,x1,y1,x2,y2,fill)
1565 Imager::FillHandle fill
1568 i_arc(im,x,y,rad,d1,d2,val)
1578 i_arc_aa(im,x,y,rad,d1,d2,val)
1588 i_arc_cfill(im,x,y,rad,d1,d2,fill)
1595 Imager::FillHandle fill
1598 i_arc_aa_cfill(im,x,y,rad,d1,d2,fill)
1605 Imager::FillHandle fill
1609 i_circle_aa(im,x,y,rad,val)
1617 i_circle_out(im,x,y,rad,val)
1625 i_circle_out_aa(im,x,y,rad,val)
1633 i_arc_out(im,x,y,rad,d1,d2,val)
1643 i_arc_out_aa(im,x,y,rad,d1,d2,val)
1654 i_bezier_multi(im,xc,yc,val)
1667 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_bezier_multi must be a reference to an array\n");
1668 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_bezier_multi must be a reference to an array\n");
1669 if (!SvROK(ST(2))) croak("Imager: Parameter 2 to i_bezier_multi must be a reference to an array\n");
1670 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 to i_bezier_multi 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_bezier_multi 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 i_bezier_multi(im,len,x,y,val);
1689 i_poly_aa(im,xc,yc,val)
1702 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1703 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1704 if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1705 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa 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 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(im,len,x,y,val);
1725 i_poly_aa_cfill(im,xc,yc,fill)
1727 Imager::FillHandle fill
1737 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1738 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1739 if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1740 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1741 av1=(AV*)SvRV(ST(1));
1742 av2=(AV*)SvRV(ST(2));
1743 if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_poly_aa_cfill must be equal length\n");
1745 x=mymalloc( len*sizeof(double) );
1746 y=mymalloc( len*sizeof(double) );
1747 for(i=0;i<len;i++) {
1748 sv1=(*(av_fetch(av1,i,0)));
1749 sv2=(*(av_fetch(av2,i,0)));
1750 x[i]=(double)SvNV(sv1);
1751 y[i]=(double)SvNV(sv2);
1753 RETVAL = i_poly_aa_cfill(im,len,x,y,fill);
1762 i_flood_fill(im,seedx,seedy,dcol)
1769 i_flood_cfill(im,seedx,seedy,fill)
1773 Imager::FillHandle fill
1776 i_flood_fill_border(im,seedx,seedy,dcol, border)
1781 Imager::Color border
1784 i_flood_cfill_border(im,seedx,seedy,fill, border)
1788 Imager::FillHandle fill
1789 Imager::Color border
1793 i_copyto(im,src,x1,y1,x2,y2,tx,ty)
1805 i_copyto_trans(im,src,x1,y1,x2,y2,tx,ty,trans)
1822 i_rubthru(im,src,tx,ty,src_minx,src_miny,src_maxx,src_maxy)
1833 i_compose(out, src, out_left, out_top, src_left, src_top, width, height, combine = ic_normal, opacity = 0.0)
1846 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)
1862 i_combine(src_av, channels_av = NULL)
1866 i_img **imgs = NULL;
1868 int *channels = NULL;
1873 in_count = av_len(src_av) + 1;
1875 imgs = mymalloc(sizeof(i_img*) * in_count);
1876 channels = mymalloc(sizeof(int) * in_count);
1877 for (i = 0; i < in_count; ++i) {
1878 psv = av_fetch(src_av, i, 0);
1879 if (!psv || !*psv || !sv_derived_from(*psv, "Imager::ImgRaw")) {
1882 croak("imgs must contain only images");
1884 tmp = SvIV((SV*)SvRV(*psv));
1885 imgs[i] = INT2PTR(i_img*, tmp);
1887 (psv = av_fetch(channels_av, i, 0)) != NULL &&
1889 channels[i] = SvIV(*psv);
1896 RETVAL = i_combine(imgs, channels, in_count);
1903 i_flipxy(im, direction)
1908 i_rotate90(im, degrees)
1913 i_rotate_exact(im, amount, ...)
1917 i_color *backp = NULL;
1918 i_fcolor *fbackp = NULL;
1922 /* extract the bg colors if any */
1923 /* yes, this is kind of strange */
1924 for (i = 2; i < items; ++i) {
1926 if (sv_derived_from(sv1, "Imager::Color")) {
1927 IV tmp = SvIV((SV*)SvRV(sv1));
1928 backp = INT2PTR(i_color *, tmp);
1930 else if (sv_derived_from(sv1, "Imager::Color::Float")) {
1931 IV tmp = SvIV((SV*)SvRV(sv1));
1932 fbackp = INT2PTR(i_fcolor *, tmp);
1935 RETVAL = i_rotate_exact_bg(im, amount, backp, fbackp);
1940 i_matrix_transform(im, xsize, ysize, matrix, ...)
1950 i_color *backp = NULL;
1951 i_fcolor *fbackp = NULL;
1953 if (!SvROK(ST(3)) || SvTYPE(SvRV(ST(3))) != SVt_PVAV)
1954 croak("i_matrix_transform: parameter 4 must be an array ref\n");
1955 av=(AV*)SvRV(ST(3));
1959 for (i = 0; i < len; ++i) {
1960 sv1=(*(av_fetch(av,i,0)));
1961 matrix[i] = SvNV(sv1);
1965 /* extract the bg colors if any */
1966 /* yes, this is kind of strange */
1967 for (i = 4; i < items; ++i) {
1969 if (sv_derived_from(sv1, "Imager::Color")) {
1970 IV tmp = SvIV((SV*)SvRV(sv1));
1971 backp = INT2PTR(i_color *, tmp);
1973 else if (sv_derived_from(sv1, "Imager::Color::Float")) {
1974 IV tmp = SvIV((SV*)SvRV(sv1));
1975 fbackp = INT2PTR(i_fcolor *, tmp);
1978 RETVAL = i_matrix_transform_bg(im, xsize, ysize, matrix, backp, fbackp);
1983 i_gaussian(im,stdev)
1988 i_unsharp_mask(im,stdev,scale)
2003 len = av_len(coef) + 1;
2004 c_coef=mymalloc( len * sizeof(double) );
2005 for(i = 0; i < len; i++) {
2006 sv1 = (*(av_fetch(coef, i, 0)));
2007 c_coef[i] = (double)SvNV(sv1);
2009 RETVAL = i_conv(im, c_coef, len);
2015 i_convert(src, avmain)
2027 outchan = av_len(avmain)+1;
2028 /* find the biggest */
2030 for (j=0; j < outchan; ++j) {
2031 temp = av_fetch(avmain, j, 0);
2032 if (temp && SvROK(*temp) && SvTYPE(SvRV(*temp)) == SVt_PVAV) {
2033 avsub = (AV*)SvRV(*temp);
2034 len = av_len(avsub)+1;
2039 i_push_errorf(0, "invalid matrix: element %d is not an array ref", j);
2043 coeff = mymalloc(sizeof(double) * outchan * inchan);
2044 for (j = 0; j < outchan; ++j) {
2045 avsub = (AV*)SvRV(*av_fetch(avmain, j, 0));
2046 len = av_len(avsub)+1;
2047 for (i = 0; i < len; ++i) {
2048 temp = av_fetch(avsub, i, 0);
2050 coeff[i+j*inchan] = SvNV(*temp);
2052 coeff[i+j*inchan] = 0;
2055 coeff[i++ + j*inchan] = 0;
2057 RETVAL = i_convert(src, coeff, outchan, inchan);
2067 unsigned int mask = 0;
2073 unsigned char (*maps)[256];
2075 if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
2076 croak("i_map: parameter 2 must be an arrayref\n");
2077 avmain = (AV*)SvRV(ST(1));
2078 len = av_len(avmain)+1;
2079 if (im->channels < len) len = im->channels;
2081 maps = mymalloc( len * sizeof(unsigned char [256]) );
2083 for (j=0; j<len ; j++) {
2084 temp = av_fetch(avmain, j, 0);
2085 if (temp && SvROK(*temp) && (SvTYPE(SvRV(*temp)) == SVt_PVAV) ) {
2086 avsub = (AV*)SvRV(*temp);
2087 if(av_len(avsub) != 255) continue;
2089 for (i=0; i<256 ; i++) {
2091 temp = av_fetch(avsub, i, 0);
2092 val = temp ? SvIV(*temp) : 0;
2094 if (val>255) val = 255;
2099 i_map(im, maps, mask);
2110 i_img_diffd(im1,im2)
2115 i_img_samef(im1, im2, epsilon = i_img_epsilonf(), what=NULL)
2125 _is_color_object(sv)
2129 RETVAL = SvOK(sv) && SvROK(sv) &&
2130 (sv_derived_from(sv, "Imager::Color")
2131 || sv_derived_from(sv, "Imager::Color::Float"));
2143 MODULE = Imager PACKAGE = Imager::Font::TT PREFIX=TT_
2145 #define TT_DESTROY(handle) i_tt_destroy(handle)
2149 Imager::Font::TT handle
2154 (void)items; /* avoid unused warning */
2160 MODULE = Imager PACKAGE = Imager
2164 i_tt_text(handle,im,xb,yb,cl,points,str_sv,len_ignored,smooth,utf8,align=1)
2165 Imager::Font::TT handle
2183 str = SvPV(str_sv, len);
2184 RETVAL = i_tt_text(handle, im, xb, yb, cl, points, str,
2185 len, smooth, utf8, align);
2191 i_tt_cp(handle,im,xb,yb,channel,points,str_sv,len_ignored,smooth,utf8,align=1)
2192 Imager::Font::TT handle
2210 str = SvPV(str_sv, len);
2211 RETVAL = i_tt_cp(handle, im, xb, yb, channel, points, str, len,
2212 smooth, utf8, align);
2218 i_tt_bbox(handle,point,str_sv,len_ignored, utf8)
2219 Imager::Font::TT handle
2224 i_img_dim cords[BOUNDING_BOX_COUNT];
2234 str = SvPV(str_sv, len);
2235 if ((rc=i_tt_bbox(handle,point,str,len,cords, utf8))) {
2237 for (i = 0; i < rc; ++i) {
2238 PUSHs(sv_2mortal(newSViv(cords[i])));
2243 i_tt_has_chars(handle, text_sv, utf8)
2244 Imager::Font::TT handle
2255 if (SvUTF8(text_sv))
2258 text = SvPV(text_sv, len);
2259 work = mymalloc(len);
2260 count = i_tt_has_chars(handle, text, len, utf8, work);
2261 if (GIMME_V == G_ARRAY) {
2263 for (i = 0; i < count; ++i) {
2264 PUSHs(boolSV(work[i]));
2269 PUSHs(sv_2mortal(newSVpv(work, count)));
2274 i_tt_dump_names(handle)
2275 Imager::Font::TT handle
2278 i_tt_face_name(handle)
2279 Imager::Font::TT handle
2284 len = i_tt_face_name(handle, name, sizeof(name));
2287 PUSHs(sv_2mortal(newSVpv(name, len-1)));
2291 i_tt_glyph_name(handle, text_sv, utf8 = 0)
2292 Imager::Font::TT handle
2303 if (SvUTF8(text_sv))
2306 text = SvPV(text_sv, work_len);
2311 ch = i_utf8_advance(&text, &len);
2313 i_push_error(0, "invalid UTF8 character");
2322 if ((outsize = i_tt_glyph_name(handle, ch, name, sizeof(name))) != 0) {
2323 PUSHs(sv_2mortal(newSVpv(name, 0)));
2326 PUSHs(&PL_sv_undef);
2333 i_test_format_probe(ig, length)
2338 i_readpnm_wiol(ig, allow_incomplete)
2340 int allow_incomplete
2344 i_readpnm_multi_wiol(ig, allow_incomplete)
2346 int allow_incomplete
2352 imgs = i_readpnm_multi_wiol(ig, &count, allow_incomplete);
2355 for (i = 0; i < count; ++i) {
2356 SV *sv = sv_newmortal();
2357 sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
2364 i_writeppm_wiol(im, ig)
2373 i_readraw_wiol(ig,x,y,datachannels,storechannels,intrl)
2382 i_writeraw_wiol(im,ig)
2387 i_writebmp_wiol(im,ig)
2392 i_readbmp_wiol(ig, allow_incomplete=0)
2394 int allow_incomplete
2398 i_writetga_wiol(im,ig, wierdpack, compress, idstring)
2407 idlen = SvCUR(ST(4));
2408 RETVAL = i_writetga_wiol(im, ig, wierdpack, compress, idstring, idlen);
2414 i_readtga_wiol(ig, length)
2422 i_scaleaxis(im,Value,Axis)
2428 i_scale_nn(im,scx,scy)
2434 i_scale_mixing(im, width, height)
2444 i_count_colors(im,maxc)
2449 i_get_anonymous_color_histo(im, maxc = 0x40000000)
2454 unsigned int * col_usage = NULL;
2457 col_cnt = i_get_anonymous_color_histo(im, &col_usage, maxc);
2458 EXTEND(SP, col_cnt);
2459 for (i = 0; i < col_cnt; i++) {
2460 PUSHs(sv_2mortal(newSViv( col_usage[i])));
2467 i_transform(im,opx,opy,parm)
2481 if (!SvROK(ST(1))) croak("Imager: Parameter 1 must be a reference to an array\n");
2482 if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to an array\n");
2483 if (!SvROK(ST(3))) croak("Imager: Parameter 3 must be a reference to an array\n");
2484 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 must be a reference to an array\n");
2485 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 must be a reference to an array\n");
2486 if (SvTYPE(SvRV(ST(3))) != SVt_PVAV) croak("Imager: Parameter 3 must be a reference to an array\n");
2487 av=(AV*)SvRV(ST(1));
2489 opx=mymalloc( opxl*sizeof(int) );
2490 for(i=0;i<opxl;i++) {
2491 sv1=(*(av_fetch(av,i,0)));
2492 opx[i]=(int)SvIV(sv1);
2494 av=(AV*)SvRV(ST(2));
2496 opy=mymalloc( opyl*sizeof(int) );
2497 for(i=0;i<opyl;i++) {
2498 sv1=(*(av_fetch(av,i,0)));
2499 opy[i]=(int)SvIV(sv1);
2501 av=(AV*)SvRV(ST(3));
2502 parmlen=av_len(av)+1;
2503 parm=mymalloc( parmlen*sizeof(double) );
2504 for(i=0;i<parmlen;i++) { /* FIXME: Bug? */
2505 sv1=(*(av_fetch(av,i,0)));
2506 parm[i]=(double)SvNV(sv1);
2508 result=i_transform(im,opx,opxl,opy,opyl,parm,parmlen);
2513 SV *result_sv = sv_newmortal();
2515 sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result);
2520 i_transform2(sv_width,sv_height,channels,sv_ops,av_n_regs,av_c_regs,av_in_imgs)
2546 in_imgs_count = av_len(av_in_imgs)+1;
2547 for (i = 0; i < in_imgs_count; ++i) {
2548 sv1 = *av_fetch(av_in_imgs, i, 0);
2549 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2550 croak("sv_in_img must contain only images");
2553 if (in_imgs_count > 0) {
2554 in_imgs = mymalloc(in_imgs_count*sizeof(i_img*));
2555 for (i = 0; i < in_imgs_count; ++i) {
2556 sv1 = *av_fetch(av_in_imgs,i,0);
2557 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2558 croak("Parameter 5 must contain only images");
2560 tmp = SvIV((SV*)SvRV(sv1));
2561 in_imgs[i] = INT2PTR(i_img*, tmp);
2565 /* no input images */
2568 /* default the output size from the first input if possible */
2570 width = SvIV(sv_width);
2571 else if (in_imgs_count)
2572 width = in_imgs[0]->xsize;
2574 croak("No output image width supplied");
2576 if (SvOK(sv_height))
2577 height = SvIV(sv_height);
2578 else if (in_imgs_count)
2579 height = in_imgs[0]->ysize;
2581 croak("No output image height supplied");
2583 ops = (struct rm_op *)SvPV(sv_ops, ops_len);
2584 if (ops_len % sizeof(struct rm_op))
2585 croak("Imager: Parameter 3 must be a bitmap of regops\n");
2586 ops_count = ops_len / sizeof(struct rm_op);
2588 n_regs_count = av_len(av_n_regs)+1;
2589 n_regs = mymalloc(n_regs_count * sizeof(double));
2590 for (i = 0; i < n_regs_count; ++i) {
2591 sv1 = *av_fetch(av_n_regs,i,0);
2593 n_regs[i] = SvNV(sv1);
2595 c_regs_count = av_len(av_c_regs)+1;
2596 c_regs = mymalloc(c_regs_count * sizeof(i_color));
2597 /* I don't bother initializing the colou?r registers */
2599 result=i_transform2(width, height, channels, ops, ops_count,
2600 n_regs, n_regs_count,
2601 c_regs, c_regs_count, in_imgs, in_imgs_count);
2607 SV *result_sv = sv_newmortal();
2609 sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result);
2615 i_contrast(im,intensity)
2628 i_noise(im,amount,type)
2634 i_bumpmap(im,bump,channel,light_x,light_y,strength)
2644 i_bumpmap_complex(im,bump,channel,tx,ty,Lx,Ly,Lz,cd,cs,n,Ia,Il,Is)
2663 i_postlevels(im,levels)
2673 i_watermark(im,wmark,tx,ty,pixdiff)
2675 Imager::ImgRaw wmark
2682 i_autolevels(im,lsat,usat,skew)
2689 i_radnoise(im,xo,yo,rscale,ascale)
2697 i_turbnoise(im, xo, yo, scale)
2720 croak("Usage: i_gradgen(im, xo, yo, ival, dmeasure)");
2721 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2722 croak("i_gradgen: Second argument must be an array ref");
2723 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
2724 croak("i_gradgen: Third argument must be an array ref");
2725 if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
2726 croak("i_gradgen: Fourth argument must be an array ref");
2727 axx = (AV *)SvRV(ST(1));
2728 ayy = (AV *)SvRV(ST(2));
2729 ac = (AV *)SvRV(ST(3));
2730 dmeasure = (int)SvIV(ST(4));
2732 num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
2733 num = num <= av_len(ac) ? num : av_len(ac);
2735 if (num < 2) croak("Usage: i_gradgen array refs must have more than 1 entry each");
2736 xo = mymalloc( sizeof(i_img_dim) * num );
2737 yo = mymalloc( sizeof(i_img_dim) * num );
2738 ival = mymalloc( sizeof(i_color) * num );
2739 for(i = 0; i<num; i++) {
2740 xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0));
2741 yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0));
2742 sv = *av_fetch(ac, i, 0);
2743 if ( !sv_derived_from(sv, "Imager::Color") ) {
2744 free(axx); free(ayy); free(ac);
2745 croak("i_gradgen: Element of fourth argument is not derived from Imager::Color");
2747 ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
2749 i_gradgen(im, num, xo, yo, ival, dmeasure);
2755 i_diff_image(im, im2, mindist=0)
2761 i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2771 double ssample_param
2775 i_fountain_seg *segs;
2777 if (!SvROK(ST(10)) || ! SvTYPE(SvRV(ST(10))))
2778 croak("i_fountain: argument 11 must be an array ref");
2780 asegs = (AV *)SvRV(ST(10));
2781 segs = load_fount_segs(aTHX_ asegs, &count);
2782 RETVAL = i_fountain(im, xa, ya, xb, yb, type, repeat, combine,
2783 super_sample, ssample_param, count, segs);
2789 i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2798 double ssample_param
2802 i_fountain_seg *segs;
2804 if (!SvROK(ST(9)) || ! SvTYPE(SvRV(ST(9))))
2805 croak("i_fountain: argument 11 must be an array ref");
2807 asegs = (AV *)SvRV(ST(9));
2808 segs = load_fount_segs(aTHX_ asegs, &count);
2809 RETVAL = i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine,
2810 super_sample, ssample_param, count, segs);
2816 i_new_fill_opacity(other_fill, alpha_mult)
2817 Imager::FillHandle other_fill
2828 errors = i_errors();
2830 while (errors[i].msg) {
2832 sv = newSVpv(errors[i].msg, strlen(errors[i].msg));
2833 if (!av_store(av, 0, sv)) {
2836 sv = newSViv(errors[i].code);
2837 if (!av_store(av, 1, sv)) {
2840 PUSHs(sv_2mortal(newRV_noinc((SV*)av)));
2848 i_push_error(code, msg)
2853 i_nearest_color(im, ...)
2868 croak("Usage: i_nearest_color(im, xo, yo, ival, dmeasure)");
2869 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2870 croak("i_nearest_color: Second argument must be an array ref");
2871 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
2872 croak("i_nearest_color: Third argument must be an array ref");
2873 if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
2874 croak("i_nearest_color: Fourth argument must be an array ref");
2875 axx = (AV *)SvRV(ST(1));
2876 ayy = (AV *)SvRV(ST(2));
2877 ac = (AV *)SvRV(ST(3));
2878 dmeasure = (int)SvIV(ST(4));
2880 num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
2881 num = num <= av_len(ac) ? num : av_len(ac);
2883 if (num < 2) croak("Usage: i_nearest_color array refs must have more than 1 entry each");
2884 xo = mymalloc( sizeof(i_img_dim) * num );
2885 yo = mymalloc( sizeof(i_img_dim) * num );
2886 ival = mymalloc( sizeof(i_color) * num );
2887 for(i = 0; i<num; i++) {
2888 xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0));
2889 yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0));
2890 sv = *av_fetch(ac, i, 0);
2891 if ( !sv_derived_from(sv, "Imager::Color") ) {
2892 free(axx); free(ayy); free(ac);
2893 croak("i_nearest_color: Element of fourth argument is not derived from Imager::Color");
2895 ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
2897 RETVAL = i_nearest_color(im, num, xo, yo, ival, dmeasure);
2911 rc=DSO_open(filename,&evstr);
2915 PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
2916 PUSHs(sv_2mortal(newSVpvn(evstr, strlen(evstr))));
2919 PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
2925 DSO_close(dso_handle)
2929 DSO_funclist(dso_handle_v)
2933 DSO_handle *dso_handle;
2934 func_ptr *functions;
2936 dso_handle=(DSO_handle*)dso_handle_v;
2937 functions = DSO_funclist(dso_handle);
2939 while( functions[i].name != NULL) {
2941 PUSHs(sv_2mortal(newSVpv(functions[i].name,0)));
2943 PUSHs(sv_2mortal(newSVpv(functions[i++].pcode,0)));
2947 DSO_call(handle,func_index,hv)
2953 if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to a hash\n");
2954 hv=(HV*)SvRV(ST(2));
2955 if (SvTYPE(hv)!=SVt_PVHV) croak("Imager: Parameter 2 must be a reference to a hash\n");
2956 DSO_call( (DSO_handle *)handle,func_index,hv);
2959 i_get_pixel(im, x, y)
2966 color = (i_color *)mymalloc(sizeof(i_color));
2967 if (i_gpix(im, x, y, color) == 0) {
2968 RETVAL = NEWSV(0, 0);
2969 sv_setref_pv(RETVAL, "Imager::Color", (void *)color);
2973 RETVAL = &PL_sv_undef;
2980 i_ppix(im, x, y, cl)
2987 i_img_pal_new(x, y, channels, maxpal)
2994 i_img_to_pal(src, quant)
3000 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
3001 croak("i_img_to_pal: second argument must be a hash ref");
3002 hv = (HV *)SvRV(ST(1));
3003 memset(&quant, 0, sizeof(quant));
3005 quant.mc_size = 256;
3006 ip_handle_quant_opts(aTHX_ &quant, hv);
3007 RETVAL = i_img_to_pal(src, &quant);
3009 ip_copy_colors_back(aTHX_ hv, &quant);
3011 ip_cleanup_quant_opts(aTHX_ &quant);
3020 i_img_make_palette(HV *quant_hv, ...)
3022 size_t count = items - 1;
3024 i_img **imgs = NULL;
3028 croak("Please supply at least one image (%d)", (int)count);
3029 imgs = mymalloc(sizeof(i_img *) * count);
3030 for (i = 0; i < count; ++i) {
3031 SV *img_sv = ST(i + 1);
3032 if (SvROK(img_sv) && sv_derived_from(img_sv, "Imager::ImgRaw")) {
3033 imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(img_sv)));
3037 croak("Image %d is not an image object", (int)i+1);
3040 memset(&quant, 0, sizeof(quant));
3042 quant.mc_size = 256;
3043 ip_handle_quant_opts(aTHX_ &quant, quant_hv);
3044 i_quant_makemap(&quant, imgs, count);
3045 EXTEND(SP, quant.mc_count);
3046 for (i = 0; i < quant.mc_count; ++i) {
3047 SV *sv_c = make_i_color_sv(aTHX_ quant.mc_colors + i);
3050 ip_cleanup_quant_opts(aTHX_ &quant);
3064 work = mymalloc((r-l) * sizeof(i_palidx));
3065 count = i_gpal(im, l, r, y, work);
3066 if (GIMME_V == G_ARRAY) {
3068 for (i = 0; i < count; ++i) {
3069 PUSHs(sv_2mortal(newSViv(work[i])));
3074 PUSHs(sv_2mortal(newSVpv((char *)work, count * sizeof(i_palidx))));
3079 if (GIMME_V != G_ARRAY) {
3081 PUSHs(&PL_sv_undef);
3086 i_ppal(im, l, y, ...)
3095 work = malloc_temp(aTHX_ sizeof(i_palidx) * (items-3));
3096 for (i=0; i < items-3; ++i) {
3097 work[i] = SvIV(ST(i+3));
3099 validate_i_ppal(im, work, items - 3);
3100 RETVAL = i_ppal(im, l, l+items-3, y, work);
3109 i_ppal_p(im, l, y, data)
3115 i_palidx const *work;
3118 work = (i_palidx const *)SvPV(data, len);
3119 len /= sizeof(i_palidx);
3121 validate_i_ppal(im, work, len);
3122 RETVAL = i_ppal(im, l, l+len, y, work);
3131 i_addcolors(im, ...)
3139 croak("i_addcolors: no colors to add");
3140 colors = mymalloc((items-1) * sizeof(i_color));
3141 for (i=0; i < items-1; ++i) {
3142 if (sv_isobject(ST(i+1))
3143 && sv_derived_from(ST(i+1), "Imager::Color")) {
3144 IV tmp = SvIV((SV *)SvRV(ST(i+1)));
3145 colors[i] = *INT2PTR(i_color *, tmp);
3149 croak("i_addcolor: pixels must be Imager::Color objects");
3152 index = i_addcolors(im, colors, items-1);
3155 RETVAL = newSVpv("0 but true", 0);
3157 else if (index == -1) {
3158 RETVAL = &PL_sv_undef;
3161 RETVAL = newSViv(index);
3167 i_setcolors(im, index, ...)
3175 croak("i_setcolors: no colors to add");
3176 colors = mymalloc((items-2) * sizeof(i_color));
3177 for (i=0; i < items-2; ++i) {
3178 if (sv_isobject(ST(i+2))
3179 && sv_derived_from(ST(i+2), "Imager::Color")) {
3180 IV tmp = SvIV((SV *)SvRV(ST(i+2)));
3181 colors[i] = *INT2PTR(i_color *, tmp);
3185 croak("i_setcolors: pixels must be Imager::Color objects");
3188 RETVAL = i_setcolors(im, index, colors, items-2);
3194 i_getcolors(im, index, ...)
3203 croak("i_getcolors: too many arguments");
3205 count = SvIV(ST(2));
3207 croak("i_getcolors: count must be positive");
3208 colors = mymalloc(sizeof(i_color) * count);
3209 if (i_getcolors(im, index, colors, count)) {
3210 for (i = 0; i < count; ++i) {
3211 SV *sv = make_i_color_sv(aTHX_ colors+i);
3227 i_findcolor(im, color)
3233 if (i_findcolor(im, color, &index)) {
3234 RETVAL = newSViv(index);
3237 RETVAL = &PL_sv_undef;
3255 i_gsamp(im, l, r, y, channels)
3260 i_channel_list channels
3266 data = mymalloc(sizeof(i_sample_t) * (r-l) * channels.count); /* XXX: memleak? */
3267 count = i_gsamp(im, l, r, y, data, channels.channels, channels.count);
3268 if (GIMME_V == G_ARRAY) {
3270 for (i = 0; i < count; ++i)
3271 PUSHs(sv_2mortal(newSViv(data[i])));
3275 PUSHs(sv_2mortal(newSVpv((char *)data, count * sizeof(i_sample_t))));
3280 if (GIMME_V != G_ARRAY) {
3282 PUSHs(&PL_sv_undef);
3287 i_gsamp_bits(im, l, r, y, bits, target, offset, channels)
3295 i_channel_list channels
3302 croak("No channel numbers supplied to g_samp()");
3304 data = mymalloc(sizeof(unsigned) * (r-l) * channels.count);
3305 count = i_gsamp_bits(im, l, r, y, data, channels.channels, channels.count, bits);
3306 for (i = 0; i < count; ++i) {
3307 av_store(target, i+offset, newSVuv(data[i]));
3319 i_psamp_bits(im, l, y, bits, channels, data_av, data_offset = 0, pixel_count = -1)
3324 i_channel_list channels
3326 i_img_dim data_offset
3327 i_img_dim pixel_count
3336 data_count = av_len(data_av) + 1;
3337 if (data_offset < 0) {
3338 croak("data_offset must be non-negative");
3340 if (data_offset > data_count) {
3341 croak("data_offset greater than number of samples supplied");
3343 if (pixel_count == -1 ||
3344 data_offset + pixel_count * channels.count > data_count) {
3345 pixel_count = (data_count - data_offset) / channels.count;
3348 data_used = pixel_count * channels.count;
3349 data = mymalloc(sizeof(unsigned) * data_count);
3350 for (i = 0; i < data_used; ++i)
3351 data[i] = SvUV(*av_fetch(data_av, data_offset + i, 0));
3353 RETVAL = i_psamp_bits(im, l, l + pixel_count, y, data, channels.channels,
3354 channels.count, bits);
3362 i_psamp(im, x, y, channels, data, offset = 0, width = -1)
3366 i_channel_list channels
3375 i_push_error(0, "offset must be non-negative");
3379 if (offset > data.count) {
3380 i_push_error(0, "offset greater than number of samples supplied");
3383 data.samples += offset;
3384 data.count -= offset;
3387 width * channels.count > data.count) {
3388 width = data.count / channels.count;
3391 RETVAL = i_psamp(im, x, r, y, data.samples, channels.channels, channels.count);
3396 i_psampf(im, x, y, channels, data, offset = 0, width = -1)
3400 i_channel_list channels
3409 i_push_error(0, "offset must be non-negative");
3413 if (offset > data.count) {
3414 i_push_error(0, "offset greater than number of samples supplied");
3417 data.samples += offset;
3418 data.count -= offset;
3421 width * channels.count > data.count) {
3422 width = data.count / channels.count;
3425 RETVAL = i_psampf(im, x, r, y, data.samples, channels.channels, channels.count);
3430 i_img_masked_new(targ, mask, x, y, w, h)
3440 if (!sv_isobject(ST(1))
3441 || !sv_derived_from(ST(1), "Imager::ImgRaw")) {
3442 croak("i_img_masked_new: parameter 2 must undef or an image");
3444 mask = INT2PTR(i_img *, SvIV((SV *)SvRV(ST(1))));
3448 RETVAL = i_img_masked_new(targ, mask, x, y, w, h);
3453 i_plin(im, l, y, ...)
3464 if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
3465 /* supplied as a byte string */
3466 work = (i_color *)SvPV(ST(3), len);
3467 count = len / sizeof(i_color);
3468 if (count * sizeof(i_color) != len) {
3469 croak("i_plin: length of scalar argument must be multiple of sizeof i_color");
3471 RETVAL = i_plin(im, l, l+count, y, work);
3474 work = mymalloc(sizeof(i_color) * (items-3));
3475 for (i=0; i < items-3; ++i) {
3476 if (sv_isobject(ST(i+3))
3477 && sv_derived_from(ST(i+3), "Imager::Color")) {
3478 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3479 work[i] = *INT2PTR(i_color *, tmp);
3483 croak("i_plin: pixels must be Imager::Color objects");
3486 RETVAL = i_plin(im, l, l+items-3, y, work);
3497 i_ppixf(im, x, y, cl)
3501 Imager::Color::Float cl
3504 i_gsampf(im, l, r, y, channels)
3509 i_channel_list channels
3515 data = mymalloc(sizeof(i_fsample_t) * (r-l) * channels.count);
3516 count = i_gsampf(im, l, r, y, data, channels.channels, channels.count);
3517 if (GIMME_V == G_ARRAY) {
3519 for (i = 0; i < count; ++i)
3520 PUSHs(sv_2mortal(newSVnv(data[i])));
3524 PUSHs(sv_2mortal(newSVpv((void *)data, count * sizeof(i_fsample_t))));
3529 if (GIMME_V != G_ARRAY) {
3531 PUSHs(&PL_sv_undef);
3536 i_plinf(im, l, y, ...)
3547 if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
3548 /* supplied as a byte string */
3549 work = (i_fcolor *)SvPV(ST(3), len);
3550 count = len / sizeof(i_fcolor);
3551 if (count * sizeof(i_fcolor) != len) {
3552 croak("i_plin: length of scalar argument must be multiple of sizeof i_fcolor");
3554 RETVAL = i_plinf(im, l, l+count, y, work);
3557 work = mymalloc(sizeof(i_fcolor) * (items-3));
3558 for (i=0; i < items-3; ++i) {
3559 if (sv_isobject(ST(i+3))
3560 && sv_derived_from(ST(i+3), "Imager::Color::Float")) {
3561 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3562 work[i] = *INT2PTR(i_fcolor *, tmp);
3566 croak("i_plinf: pixels must be Imager::Color::Float objects");
3570 RETVAL = i_plinf(im, l, l+items-3, y, work);
3588 color = (i_fcolor *)mymalloc(sizeof(i_fcolor));
3589 if (i_gpixf(im, x, y, color) == 0) {
3590 RETVAL = NEWSV(0,0);
3591 sv_setref_pv(RETVAL, "Imager::Color::Float", (void *)color);
3595 RETVAL = &PL_sv_undef;
3611 vals = mymalloc((r-l) * sizeof(i_color));
3612 memset(vals, 0, (r-l) * sizeof(i_color));
3613 count = i_glin(im, l, r, y, vals);
3614 if (GIMME_V == G_ARRAY) {
3616 for (i = 0; i < count; ++i) {
3617 SV *sv = make_i_color_sv(aTHX_ vals+i);
3623 PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_color))));
3629 i_glinf(im, l, r, y)
3639 for (i = 0; i < MAXCHANNELS; ++i)
3640 zero.channel[i] = 0;
3642 vals = mymalloc((r-l) * sizeof(i_fcolor));
3643 for (i = 0; i < r-l; ++i)
3645 count = i_glinf(im, l, r, y, vals);
3646 if (GIMME_V == G_ARRAY) {
3648 for (i = 0; i < count; ++i) {
3650 i_fcolor *col = mymalloc(sizeof(i_fcolor));
3652 sv = sv_newmortal();
3653 sv_setref_pv(sv, "Imager::Color::Float", (void *)col);
3659 PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_fcolor))));
3665 i_img_8_new(x, y, ch)
3671 i_img_16_new(x, y, ch)
3681 i_img_double_new(x, y, ch)
3691 i_tags_addn(im, name, code, idata)
3700 name = SvPV(ST(1), len);
3703 RETVAL = i_tags_addn(&im->tags, name, code, idata);
3708 i_tags_add(im, name, code, data, idata)
3718 name = SvPV(ST(1), len);
3722 data = SvPV(ST(3), len);
3727 RETVAL = i_tags_add(&im->tags, name, code, data, len, idata);
3732 i_tags_find(im, name, start)
3739 if (i_tags_find(&im->tags, name, start, &entry)) {
3741 RETVAL = newSVpv("0 but true", 0);
3743 RETVAL = newSViv(entry);
3745 RETVAL = &PL_sv_undef;
3751 i_tags_findn(im, code, start)
3758 if (i_tags_findn(&im->tags, code, start, &entry)) {
3760 RETVAL = newSVpv("0 but true", 0);
3762 RETVAL = newSViv(entry);
3765 RETVAL = &PL_sv_undef;
3771 i_tags_delete(im, entry)
3775 RETVAL = i_tags_delete(&im->tags, entry);
3780 i_tags_delbyname(im, name)
3784 RETVAL = i_tags_delbyname(&im->tags, name);
3789 i_tags_delbycode(im, code)
3793 RETVAL = i_tags_delbycode(&im->tags, code);
3798 i_tags_get(im, index)
3802 if (index >= 0 && index < im->tags.count) {
3803 i_img_tag *entry = im->tags.tags + index;
3807 PUSHs(sv_2mortal(newSVpv(entry->name, 0)));
3810 PUSHs(sv_2mortal(newSViv(entry->code)));
3813 PUSHs(sv_2mortal(newSVpvn(entry->data, entry->size)));
3816 PUSHs(sv_2mortal(newSViv(entry->idata)));
3821 i_tags_get_string(im, what_sv)
3825 char const *name = NULL;
3829 if (SvIOK(what_sv)) {
3830 code = SvIV(what_sv);
3834 name = SvPV_nolen(what_sv);
3837 if (i_tags_get_string(&im->tags, name, code, buffer, sizeof(buffer))) {
3839 PUSHs(sv_2mortal(newSVpv(buffer, 0)));
3846 RETVAL = im->tags.count;
3852 MODULE = Imager PACKAGE = Imager::FillHandle PREFIX=IFILL_
3856 Imager::FillHandle fill
3859 IFILL_CLONE_SKIP(...)
3861 (void)items; /* avoid unused warning for XS variable */
3866 MODULE = Imager PACKAGE = Imager
3869 i_new_fill_solid(cl, combine)
3874 i_new_fill_solidf(cl, combine)
3875 Imager::Color::Float cl
3879 i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy)
3887 unsigned char *cust_hatch;
3891 cust_hatch = (unsigned char *)SvPV(ST(4), len);
3895 RETVAL = i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy);
3900 i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy)
3901 Imager::Color::Float fg
3902 Imager::Color::Float bg
3908 unsigned char *cust_hatch;
3912 cust_hatch = (unsigned char *)SvPV(ST(4), len);
3916 RETVAL = i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy);
3921 i_new_fill_image(src, matrix, xoff, yoff, combine)
3938 if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
3939 croak("i_new_fill_image: parameter must be an arrayref");
3940 av=(AV*)SvRV(ST(1));
3944 for (i = 0; i < len; ++i) {
3945 sv1=(*(av_fetch(av,i,0)));
3946 matrix[i] = SvNV(sv1);
3952 RETVAL = i_new_fill_image(src, matrixp, xoff, yoff, combine);
3956 MODULE = Imager PACKAGE = Imager::Internal::Hlines PREFIX=i_int_hlines_
3958 # this class is only exposed for testing
3961 i_int_hlines_testing()
3963 #if i_int_hlines_testing()
3965 Imager::Internal::Hlines
3966 i_int_hlines_new(start_y, count_y, start_x, count_x)
3972 Imager::Internal::Hlines
3973 i_int_hlines_new_img(im)
3977 i_int_hlines_add(hlines, y, minx, width)
3978 Imager::Internal::Hlines hlines
3984 i_int_hlines_DESTROY(hlines)
3985 Imager::Internal::Hlines hlines
3988 i_int_hlines_dump(hlines)
3989 Imager::Internal::Hlines hlines
3992 i_int_hlines_CLONE_SKIP(cls)
3997 PERL_SET_GLOBAL_CALLBACKS;
3998 PERL_PL_SET_GLOBAL_CALLBACKS;