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 coeff = mymalloc(sizeof(double) * outchan * inchan);
2047 for (j = 0; j < outchan; ++j) {
2048 avsub = (AV*)SvRV(*av_fetch(avmain, j, 0));
2049 len = av_len(avsub)+1;
2050 for (i = 0; i < len; ++i) {
2051 temp = av_fetch(avsub, i, 0);
2053 coeff[i+j*inchan] = SvNV(*temp);
2055 coeff[i+j*inchan] = 0;
2058 coeff[i++ + j*inchan] = 0;
2060 RETVAL = i_convert(src, coeff, outchan, inchan);
2070 unsigned int mask = 0;
2076 unsigned char (*maps)[256];
2078 if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
2079 croak("i_map: parameter 2 must be an arrayref\n");
2080 avmain = (AV*)SvRV(ST(1));
2081 len = av_len(avmain)+1;
2082 if (im->channels < len) len = im->channels;
2084 maps = mymalloc( len * sizeof(unsigned char [256]) );
2086 for (j=0; j<len ; j++) {
2087 temp = av_fetch(avmain, j, 0);
2088 if (temp && SvROK(*temp) && (SvTYPE(SvRV(*temp)) == SVt_PVAV) ) {
2089 avsub = (AV*)SvRV(*temp);
2090 if(av_len(avsub) != 255) continue;
2092 for (i=0; i<256 ; i++) {
2094 temp = av_fetch(avsub, i, 0);
2095 val = temp ? SvIV(*temp) : 0;
2097 if (val>255) val = 255;
2102 i_map(im, maps, mask);
2113 i_img_diffd(im1,im2)
2118 i_img_samef(im1, im2, epsilon = i_img_epsilonf(), what=NULL)
2128 _is_color_object(sv)
2132 RETVAL = SvOK(sv) && SvROK(sv) &&
2133 (sv_derived_from(sv, "Imager::Color")
2134 || sv_derived_from(sv, "Imager::Color::Float"));
2146 MODULE = Imager PACKAGE = Imager::Font::TT PREFIX=TT_
2148 #define TT_DESTROY(handle) i_tt_destroy(handle)
2152 Imager::Font::TT handle
2157 (void)items; /* avoid unused warning */
2163 MODULE = Imager PACKAGE = Imager
2167 i_tt_text(handle,im,xb,yb,cl,points,str_sv,len_ignored,smooth,utf8,align=1)
2168 Imager::Font::TT handle
2186 str = SvPV(str_sv, len);
2187 RETVAL = i_tt_text(handle, im, xb, yb, cl, points, str,
2188 len, smooth, utf8, align);
2194 i_tt_cp(handle,im,xb,yb,channel,points,str_sv,len_ignored,smooth,utf8,align=1)
2195 Imager::Font::TT handle
2213 str = SvPV(str_sv, len);
2214 RETVAL = i_tt_cp(handle, im, xb, yb, channel, points, str, len,
2215 smooth, utf8, align);
2221 i_tt_bbox(handle,point,str_sv,len_ignored, utf8)
2222 Imager::Font::TT handle
2227 i_img_dim cords[BOUNDING_BOX_COUNT];
2237 str = SvPV(str_sv, len);
2238 if ((rc=i_tt_bbox(handle,point,str,len,cords, utf8))) {
2240 for (i = 0; i < rc; ++i) {
2241 PUSHs(sv_2mortal(newSViv(cords[i])));
2246 i_tt_has_chars(handle, text_sv, utf8)
2247 Imager::Font::TT handle
2258 if (SvUTF8(text_sv))
2261 text = SvPV(text_sv, len);
2262 work = mymalloc(len);
2263 count = i_tt_has_chars(handle, text, len, utf8, work);
2264 if (GIMME_V == G_ARRAY) {
2266 for (i = 0; i < count; ++i) {
2267 PUSHs(boolSV(work[i]));
2272 PUSHs(sv_2mortal(newSVpv(work, count)));
2277 i_tt_dump_names(handle)
2278 Imager::Font::TT handle
2281 i_tt_face_name(handle)
2282 Imager::Font::TT handle
2287 len = i_tt_face_name(handle, name, sizeof(name));
2290 PUSHs(sv_2mortal(newSVpv(name, len-1)));
2294 i_tt_glyph_name(handle, text_sv, utf8 = 0)
2295 Imager::Font::TT handle
2306 if (SvUTF8(text_sv))
2309 text = SvPV(text_sv, work_len);
2314 ch = i_utf8_advance(&text, &len);
2316 i_push_error(0, "invalid UTF8 character");
2325 if ((outsize = i_tt_glyph_name(handle, ch, name, sizeof(name))) != 0) {
2326 PUSHs(sv_2mortal(newSVpv(name, 0)));
2329 PUSHs(&PL_sv_undef);
2336 i_test_format_probe(ig, length)
2341 i_readpnm_wiol(ig, allow_incomplete)
2343 int allow_incomplete
2347 i_readpnm_multi_wiol(ig, allow_incomplete)
2349 int allow_incomplete
2355 imgs = i_readpnm_multi_wiol(ig, &count, allow_incomplete);
2358 for (i = 0; i < count; ++i) {
2359 SV *sv = sv_newmortal();
2360 sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
2367 i_writeppm_wiol(im, ig)
2376 i_readraw_wiol(ig,x,y,datachannels,storechannels,intrl)
2385 i_writeraw_wiol(im,ig)
2390 i_writebmp_wiol(im,ig)
2395 i_readbmp_wiol(ig, allow_incomplete=0)
2397 int allow_incomplete
2401 i_writetga_wiol(im,ig, wierdpack, compress, idstring)
2410 idlen = SvCUR(ST(4));
2411 RETVAL = i_writetga_wiol(im, ig, wierdpack, compress, idstring, idlen);
2417 i_readtga_wiol(ig, length)
2425 i_scaleaxis(im,Value,Axis)
2431 i_scale_nn(im,scx,scy)
2437 i_scale_mixing(im, width, height)
2447 i_count_colors(im,maxc)
2452 i_get_anonymous_color_histo(im, maxc = 0x40000000)
2457 unsigned int * col_usage = NULL;
2460 col_cnt = i_get_anonymous_color_histo(im, &col_usage, maxc);
2461 EXTEND(SP, col_cnt);
2462 for (i = 0; i < col_cnt; i++) {
2463 PUSHs(sv_2mortal(newSViv( col_usage[i])));
2470 i_transform(im,opx,opy,parm)
2484 if (!SvROK(ST(1))) croak("Imager: Parameter 1 must be a reference to an array\n");
2485 if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to an array\n");
2486 if (!SvROK(ST(3))) croak("Imager: Parameter 3 must be a reference to an array\n");
2487 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 must be a reference to an array\n");
2488 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 must be a reference to an array\n");
2489 if (SvTYPE(SvRV(ST(3))) != SVt_PVAV) croak("Imager: Parameter 3 must be a reference to an array\n");
2490 av=(AV*)SvRV(ST(1));
2492 opx=mymalloc( opxl*sizeof(int) );
2493 for(i=0;i<opxl;i++) {
2494 sv1=(*(av_fetch(av,i,0)));
2495 opx[i]=(int)SvIV(sv1);
2497 av=(AV*)SvRV(ST(2));
2499 opy=mymalloc( opyl*sizeof(int) );
2500 for(i=0;i<opyl;i++) {
2501 sv1=(*(av_fetch(av,i,0)));
2502 opy[i]=(int)SvIV(sv1);
2504 av=(AV*)SvRV(ST(3));
2505 parmlen=av_len(av)+1;
2506 parm=mymalloc( parmlen*sizeof(double) );
2507 for(i=0;i<parmlen;i++) { /* FIXME: Bug? */
2508 sv1=(*(av_fetch(av,i,0)));
2509 parm[i]=(double)SvNV(sv1);
2511 result=i_transform(im,opx,opxl,opy,opyl,parm,parmlen);
2516 SV *result_sv = sv_newmortal();
2518 sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result);
2523 i_transform2(sv_width,sv_height,channels,sv_ops,av_n_regs,av_c_regs,av_in_imgs)
2549 in_imgs_count = av_len(av_in_imgs)+1;
2550 for (i = 0; i < in_imgs_count; ++i) {
2551 sv1 = *av_fetch(av_in_imgs, i, 0);
2552 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2553 croak("sv_in_img must contain only images");
2556 if (in_imgs_count > 0) {
2557 in_imgs = mymalloc(in_imgs_count*sizeof(i_img*));
2558 for (i = 0; i < in_imgs_count; ++i) {
2559 sv1 = *av_fetch(av_in_imgs,i,0);
2560 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2561 croak("Parameter 5 must contain only images");
2563 tmp = SvIV((SV*)SvRV(sv1));
2564 in_imgs[i] = INT2PTR(i_img*, tmp);
2568 /* no input images */
2571 /* default the output size from the first input if possible */
2573 width = SvIV(sv_width);
2574 else if (in_imgs_count)
2575 width = in_imgs[0]->xsize;
2577 croak("No output image width supplied");
2579 if (SvOK(sv_height))
2580 height = SvIV(sv_height);
2581 else if (in_imgs_count)
2582 height = in_imgs[0]->ysize;
2584 croak("No output image height supplied");
2586 ops = (struct rm_op *)SvPV(sv_ops, ops_len);
2587 if (ops_len % sizeof(struct rm_op))
2588 croak("Imager: Parameter 3 must be a bitmap of regops\n");
2589 ops_count = ops_len / sizeof(struct rm_op);
2591 n_regs_count = av_len(av_n_regs)+1;
2592 n_regs = mymalloc(n_regs_count * sizeof(double));
2593 for (i = 0; i < n_regs_count; ++i) {
2594 sv1 = *av_fetch(av_n_regs,i,0);
2596 n_regs[i] = SvNV(sv1);
2598 c_regs_count = av_len(av_c_regs)+1;
2599 c_regs = mymalloc(c_regs_count * sizeof(i_color));
2600 /* I don't bother initializing the colou?r registers */
2602 result=i_transform2(width, height, channels, ops, ops_count,
2603 n_regs, n_regs_count,
2604 c_regs, c_regs_count, in_imgs, in_imgs_count);
2610 SV *result_sv = sv_newmortal();
2612 sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result);
2618 i_contrast(im,intensity)
2631 i_noise(im,amount,type)
2637 i_bumpmap(im,bump,channel,light_x,light_y,strength)
2647 i_bumpmap_complex(im,bump,channel,tx,ty,Lx,Ly,Lz,cd,cs,n,Ia,Il,Is)
2666 i_postlevels(im,levels)
2676 i_watermark(im,wmark,tx,ty,pixdiff)
2678 Imager::ImgRaw wmark
2685 i_autolevels(im,lsat,usat,skew)
2692 i_radnoise(im,xo,yo,rscale,ascale)
2700 i_turbnoise(im, xo, yo, scale)
2723 croak("Usage: i_gradgen(im, xo, yo, ival, dmeasure)");
2724 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2725 croak("i_gradgen: Second argument must be an array ref");
2726 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
2727 croak("i_gradgen: Third argument must be an array ref");
2728 if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
2729 croak("i_gradgen: Fourth argument must be an array ref");
2730 axx = (AV *)SvRV(ST(1));
2731 ayy = (AV *)SvRV(ST(2));
2732 ac = (AV *)SvRV(ST(3));
2733 dmeasure = (int)SvIV(ST(4));
2735 num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
2736 num = num <= av_len(ac) ? num : av_len(ac);
2738 if (num < 2) croak("Usage: i_gradgen array refs must have more than 1 entry each");
2739 xo = mymalloc( sizeof(i_img_dim) * num );
2740 yo = mymalloc( sizeof(i_img_dim) * num );
2741 ival = mymalloc( sizeof(i_color) * num );
2742 for(i = 0; i<num; i++) {
2743 xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0));
2744 yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0));
2745 sv = *av_fetch(ac, i, 0);
2746 if ( !sv_derived_from(sv, "Imager::Color") ) {
2747 free(axx); free(ayy); free(ac);
2748 croak("i_gradgen: Element of fourth argument is not derived from Imager::Color");
2750 ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
2752 i_gradgen(im, num, xo, yo, ival, dmeasure);
2758 i_diff_image(im, im2, mindist=0)
2764 i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2774 double ssample_param
2778 i_fountain_seg *segs;
2780 if (!SvROK(ST(10)) || ! SvTYPE(SvRV(ST(10))))
2781 croak("i_fountain: argument 11 must be an array ref");
2783 asegs = (AV *)SvRV(ST(10));
2784 segs = load_fount_segs(aTHX_ asegs, &count);
2785 RETVAL = i_fountain(im, xa, ya, xb, yb, type, repeat, combine,
2786 super_sample, ssample_param, count, segs);
2792 i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2801 double ssample_param
2805 i_fountain_seg *segs;
2807 if (!SvROK(ST(9)) || ! SvTYPE(SvRV(ST(9))))
2808 croak("i_fountain: argument 11 must be an array ref");
2810 asegs = (AV *)SvRV(ST(9));
2811 segs = load_fount_segs(aTHX_ asegs, &count);
2812 RETVAL = i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine,
2813 super_sample, ssample_param, count, segs);
2819 i_new_fill_opacity(other_fill, alpha_mult)
2820 Imager::FillHandle other_fill
2831 errors = i_errors();
2833 while (errors[i].msg) {
2835 sv = newSVpv(errors[i].msg, strlen(errors[i].msg));
2836 if (!av_store(av, 0, sv)) {
2839 sv = newSViv(errors[i].code);
2840 if (!av_store(av, 1, sv)) {
2843 PUSHs(sv_2mortal(newRV_noinc((SV*)av)));
2851 i_push_error(code, msg)
2856 i_nearest_color(im, ...)
2871 croak("Usage: i_nearest_color(im, xo, yo, ival, dmeasure)");
2872 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2873 croak("i_nearest_color: Second argument must be an array ref");
2874 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
2875 croak("i_nearest_color: Third argument must be an array ref");
2876 if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
2877 croak("i_nearest_color: Fourth argument must be an array ref");
2878 axx = (AV *)SvRV(ST(1));
2879 ayy = (AV *)SvRV(ST(2));
2880 ac = (AV *)SvRV(ST(3));
2881 dmeasure = (int)SvIV(ST(4));
2883 num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
2884 num = num <= av_len(ac) ? num : av_len(ac);
2886 if (num < 2) croak("Usage: i_nearest_color array refs must have more than 1 entry each");
2887 xo = mymalloc( sizeof(i_img_dim) * num );
2888 yo = mymalloc( sizeof(i_img_dim) * num );
2889 ival = mymalloc( sizeof(i_color) * num );
2890 for(i = 0; i<num; i++) {
2891 xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0));
2892 yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0));
2893 sv = *av_fetch(ac, i, 0);
2894 if ( !sv_derived_from(sv, "Imager::Color") ) {
2895 free(axx); free(ayy); free(ac);
2896 croak("i_nearest_color: Element of fourth argument is not derived from Imager::Color");
2898 ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
2900 RETVAL = i_nearest_color(im, num, xo, yo, ival, dmeasure);
2914 rc=DSO_open(filename,&evstr);
2918 PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
2919 PUSHs(sv_2mortal(newSVpvn(evstr, strlen(evstr))));
2922 PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
2928 DSO_close(dso_handle)
2932 DSO_funclist(dso_handle_v)
2936 DSO_handle *dso_handle;
2937 func_ptr *functions;
2939 dso_handle=(DSO_handle*)dso_handle_v;
2940 functions = DSO_funclist(dso_handle);
2942 while( functions[i].name != NULL) {
2944 PUSHs(sv_2mortal(newSVpv(functions[i].name,0)));
2946 PUSHs(sv_2mortal(newSVpv(functions[i++].pcode,0)));
2950 DSO_call(handle,func_index,hv)
2956 if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to a hash\n");
2957 hv=(HV*)SvRV(ST(2));
2958 if (SvTYPE(hv)!=SVt_PVHV) croak("Imager: Parameter 2 must be a reference to a hash\n");
2959 DSO_call( (DSO_handle *)handle,func_index,hv);
2962 i_get_pixel(im, x, y)
2969 color = (i_color *)mymalloc(sizeof(i_color));
2970 if (i_gpix(im, x, y, color) == 0) {
2971 RETVAL = NEWSV(0, 0);
2972 sv_setref_pv(RETVAL, "Imager::Color", (void *)color);
2976 RETVAL = &PL_sv_undef;
2983 i_ppix(im, x, y, cl)
2990 i_img_pal_new(x, y, channels, maxpal)
2997 i_img_to_pal(src, quant)
3003 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
3004 croak("i_img_to_pal: second argument must be a hash ref");
3005 hv = (HV *)SvRV(ST(1));
3006 memset(&quant, 0, sizeof(quant));
3008 quant.mc_size = 256;
3009 ip_handle_quant_opts(aTHX_ &quant, hv);
3010 RETVAL = i_img_to_pal(src, &quant);
3012 ip_copy_colors_back(aTHX_ hv, &quant);
3014 ip_cleanup_quant_opts(aTHX_ &quant);
3023 i_img_make_palette(HV *quant_hv, ...)
3025 size_t count = items - 1;
3027 i_img **imgs = NULL;
3031 croak("Please supply at least one image (%d)", (int)count);
3032 imgs = mymalloc(sizeof(i_img *) * count);
3033 for (i = 0; i < count; ++i) {
3034 SV *img_sv = ST(i + 1);
3035 if (SvROK(img_sv) && sv_derived_from(img_sv, "Imager::ImgRaw")) {
3036 imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(img_sv)));
3040 croak("Image %d is not an image object", (int)i+1);
3043 memset(&quant, 0, sizeof(quant));
3045 quant.mc_size = 256;
3046 ip_handle_quant_opts(aTHX_ &quant, quant_hv);
3047 i_quant_makemap(&quant, imgs, count);
3048 EXTEND(SP, quant.mc_count);
3049 for (i = 0; i < quant.mc_count; ++i) {
3050 SV *sv_c = make_i_color_sv(aTHX_ quant.mc_colors + i);
3053 ip_cleanup_quant_opts(aTHX_ &quant);
3067 work = mymalloc((r-l) * sizeof(i_palidx));
3068 count = i_gpal(im, l, r, y, work);
3069 if (GIMME_V == G_ARRAY) {
3071 for (i = 0; i < count; ++i) {
3072 PUSHs(sv_2mortal(newSViv(work[i])));
3077 PUSHs(sv_2mortal(newSVpv((char *)work, count * sizeof(i_palidx))));
3082 if (GIMME_V != G_ARRAY) {
3084 PUSHs(&PL_sv_undef);
3089 i_ppal(im, l, y, ...)
3098 work = malloc_temp(aTHX_ sizeof(i_palidx) * (items-3));
3099 for (i=0; i < items-3; ++i) {
3100 work[i] = SvIV(ST(i+3));
3102 validate_i_ppal(im, work, items - 3);
3103 RETVAL = i_ppal(im, l, l+items-3, y, work);
3112 i_ppal_p(im, l, y, data)
3118 i_palidx const *work;
3121 work = (i_palidx const *)SvPV(data, len);
3122 len /= sizeof(i_palidx);
3124 validate_i_ppal(im, work, len);
3125 RETVAL = i_ppal(im, l, l+len, y, work);
3134 i_addcolors(im, ...)
3142 croak("i_addcolors: no colors to add");
3143 colors = mymalloc((items-1) * sizeof(i_color));
3144 for (i=0; i < items-1; ++i) {
3145 if (sv_isobject(ST(i+1))
3146 && sv_derived_from(ST(i+1), "Imager::Color")) {
3147 IV tmp = SvIV((SV *)SvRV(ST(i+1)));
3148 colors[i] = *INT2PTR(i_color *, tmp);
3152 croak("i_addcolor: pixels must be Imager::Color objects");
3155 index = i_addcolors(im, colors, items-1);
3158 RETVAL = newSVpv("0 but true", 0);
3160 else if (index == -1) {
3161 RETVAL = &PL_sv_undef;
3164 RETVAL = newSViv(index);
3170 i_setcolors(im, index, ...)
3178 croak("i_setcolors: no colors to add");
3179 colors = mymalloc((items-2) * sizeof(i_color));
3180 for (i=0; i < items-2; ++i) {
3181 if (sv_isobject(ST(i+2))
3182 && sv_derived_from(ST(i+2), "Imager::Color")) {
3183 IV tmp = SvIV((SV *)SvRV(ST(i+2)));
3184 colors[i] = *INT2PTR(i_color *, tmp);
3188 croak("i_setcolors: pixels must be Imager::Color objects");
3191 RETVAL = i_setcolors(im, index, colors, items-2);
3197 i_getcolors(im, index, ...)
3206 croak("i_getcolors: too many arguments");
3208 count = SvIV(ST(2));
3210 croak("i_getcolors: count must be positive");
3211 colors = mymalloc(sizeof(i_color) * count);
3212 if (i_getcolors(im, index, colors, count)) {
3213 for (i = 0; i < count; ++i) {
3214 SV *sv = make_i_color_sv(aTHX_ colors+i);
3230 i_findcolor(im, color)
3236 if (i_findcolor(im, color, &index)) {
3237 RETVAL = newSViv(index);
3240 RETVAL = &PL_sv_undef;
3258 i_gsamp(im, l, r, y, channels)
3263 i_channel_list channels
3269 data = mymalloc(sizeof(i_sample_t) * (r-l) * channels.count); /* XXX: memleak? */
3270 count = i_gsamp(im, l, r, y, data, channels.channels, channels.count);
3271 if (GIMME_V == G_ARRAY) {
3273 for (i = 0; i < count; ++i)
3274 PUSHs(sv_2mortal(newSViv(data[i])));
3278 PUSHs(sv_2mortal(newSVpv((char *)data, count * sizeof(i_sample_t))));
3283 if (GIMME_V != G_ARRAY) {
3285 PUSHs(&PL_sv_undef);
3290 i_gsamp_bits(im, l, r, y, bits, target, offset, channels)
3298 i_channel_list channels
3305 croak("No channel numbers supplied to g_samp()");
3307 data = mymalloc(sizeof(unsigned) * (r-l) * channels.count);
3308 count = i_gsamp_bits(im, l, r, y, data, channels.channels, channels.count, bits);
3309 for (i = 0; i < count; ++i) {
3310 av_store(target, i+offset, newSVuv(data[i]));
3322 i_psamp_bits(im, l, y, bits, channels, data_av, data_offset = 0, pixel_count = -1)
3327 i_channel_list channels
3329 i_img_dim data_offset
3330 i_img_dim pixel_count
3339 data_count = av_len(data_av) + 1;
3340 if (data_offset < 0) {
3341 croak("data_offset must be non-negative");
3343 if (data_offset > data_count) {
3344 croak("data_offset greater than number of samples supplied");
3346 if (pixel_count == -1 ||
3347 data_offset + pixel_count * channels.count > data_count) {
3348 pixel_count = (data_count - data_offset) / channels.count;
3351 data_used = pixel_count * channels.count;
3352 data = mymalloc(sizeof(unsigned) * data_count);
3353 for (i = 0; i < data_used; ++i)
3354 data[i] = SvUV(*av_fetch(data_av, data_offset + i, 0));
3356 RETVAL = i_psamp_bits(im, l, l + pixel_count, y, data, channels.channels,
3357 channels.count, bits);
3365 i_psamp(im, x, y, channels, data, offset = 0, width = -1)
3369 i_channel_list channels
3378 i_push_error(0, "offset must be non-negative");
3382 if (offset > data.count) {
3383 i_push_error(0, "offset greater than number of samples supplied");
3386 data.samples += offset;
3387 data.count -= offset;
3390 width * channels.count > data.count) {
3391 width = data.count / channels.count;
3394 RETVAL = i_psamp(im, x, r, y, data.samples, channels.channels, channels.count);
3399 i_psampf(im, x, y, channels, data, offset = 0, width = -1)
3403 i_channel_list channels
3412 i_push_error(0, "offset must be non-negative");
3416 if (offset > data.count) {
3417 i_push_error(0, "offset greater than number of samples supplied");
3420 data.samples += offset;
3421 data.count -= offset;
3424 width * channels.count > data.count) {
3425 width = data.count / channels.count;
3428 RETVAL = i_psampf(im, x, r, y, data.samples, channels.channels, channels.count);
3433 i_img_masked_new(targ, mask, x, y, w, h)
3443 if (!sv_isobject(ST(1))
3444 || !sv_derived_from(ST(1), "Imager::ImgRaw")) {
3445 croak("i_img_masked_new: parameter 2 must undef or an image");
3447 mask = INT2PTR(i_img *, SvIV((SV *)SvRV(ST(1))));
3451 RETVAL = i_img_masked_new(targ, mask, x, y, w, h);
3456 i_plin(im, l, y, ...)
3467 if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
3468 /* supplied as a byte string */
3469 work = (i_color *)SvPV(ST(3), len);
3470 count = len / sizeof(i_color);
3471 if (count * sizeof(i_color) != len) {
3472 croak("i_plin: length of scalar argument must be multiple of sizeof i_color");
3474 RETVAL = i_plin(im, l, l+count, y, work);
3477 work = mymalloc(sizeof(i_color) * (items-3));
3478 for (i=0; i < items-3; ++i) {
3479 if (sv_isobject(ST(i+3))
3480 && sv_derived_from(ST(i+3), "Imager::Color")) {
3481 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3482 work[i] = *INT2PTR(i_color *, tmp);
3486 croak("i_plin: pixels must be Imager::Color objects");
3489 RETVAL = i_plin(im, l, l+items-3, y, work);
3500 i_ppixf(im, x, y, cl)
3504 Imager::Color::Float cl
3507 i_gsampf(im, l, r, y, channels)
3512 i_channel_list channels
3518 data = mymalloc(sizeof(i_fsample_t) * (r-l) * channels.count);
3519 count = i_gsampf(im, l, r, y, data, channels.channels, channels.count);
3520 if (GIMME_V == G_ARRAY) {
3522 for (i = 0; i < count; ++i)
3523 PUSHs(sv_2mortal(newSVnv(data[i])));
3527 PUSHs(sv_2mortal(newSVpv((void *)data, count * sizeof(i_fsample_t))));
3532 if (GIMME_V != G_ARRAY) {
3534 PUSHs(&PL_sv_undef);
3539 i_plinf(im, l, y, ...)
3550 if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
3551 /* supplied as a byte string */
3552 work = (i_fcolor *)SvPV(ST(3), len);
3553 count = len / sizeof(i_fcolor);
3554 if (count * sizeof(i_fcolor) != len) {
3555 croak("i_plin: length of scalar argument must be multiple of sizeof i_fcolor");
3557 RETVAL = i_plinf(im, l, l+count, y, work);
3560 work = mymalloc(sizeof(i_fcolor) * (items-3));
3561 for (i=0; i < items-3; ++i) {
3562 if (sv_isobject(ST(i+3))
3563 && sv_derived_from(ST(i+3), "Imager::Color::Float")) {
3564 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3565 work[i] = *INT2PTR(i_fcolor *, tmp);
3569 croak("i_plinf: pixels must be Imager::Color::Float objects");
3573 RETVAL = i_plinf(im, l, l+items-3, y, work);
3591 color = (i_fcolor *)mymalloc(sizeof(i_fcolor));
3592 if (i_gpixf(im, x, y, color) == 0) {
3593 RETVAL = NEWSV(0,0);
3594 sv_setref_pv(RETVAL, "Imager::Color::Float", (void *)color);
3598 RETVAL = &PL_sv_undef;
3614 vals = mymalloc((r-l) * sizeof(i_color));
3615 memset(vals, 0, (r-l) * sizeof(i_color));
3616 count = i_glin(im, l, r, y, vals);
3617 if (GIMME_V == G_ARRAY) {
3619 for (i = 0; i < count; ++i) {
3620 SV *sv = make_i_color_sv(aTHX_ vals+i);
3626 PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_color))));
3632 i_glinf(im, l, r, y)
3642 for (i = 0; i < MAXCHANNELS; ++i)
3643 zero.channel[i] = 0;
3645 vals = mymalloc((r-l) * sizeof(i_fcolor));
3646 for (i = 0; i < r-l; ++i)
3648 count = i_glinf(im, l, r, y, vals);
3649 if (GIMME_V == G_ARRAY) {
3651 for (i = 0; i < count; ++i) {
3653 i_fcolor *col = mymalloc(sizeof(i_fcolor));
3655 sv = sv_newmortal();
3656 sv_setref_pv(sv, "Imager::Color::Float", (void *)col);
3662 PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_fcolor))));
3668 i_img_8_new(x, y, ch)
3674 i_img_16_new(x, y, ch)
3684 i_img_double_new(x, y, ch)
3694 i_tags_addn(im, name, code, idata)
3703 name = SvPV(ST(1), len);
3706 RETVAL = i_tags_addn(&im->tags, name, code, idata);
3711 i_tags_add(im, name, code, data, idata)
3721 name = SvPV(ST(1), len);
3725 data = SvPV(ST(3), len);
3730 RETVAL = i_tags_add(&im->tags, name, code, data, len, idata);
3735 i_tags_find(im, name, start)
3742 if (i_tags_find(&im->tags, name, start, &entry)) {
3744 RETVAL = newSVpv("0 but true", 0);
3746 RETVAL = newSViv(entry);
3748 RETVAL = &PL_sv_undef;
3754 i_tags_findn(im, code, start)
3761 if (i_tags_findn(&im->tags, code, start, &entry)) {
3763 RETVAL = newSVpv("0 but true", 0);
3765 RETVAL = newSViv(entry);
3768 RETVAL = &PL_sv_undef;
3774 i_tags_delete(im, entry)
3778 RETVAL = i_tags_delete(&im->tags, entry);
3783 i_tags_delbyname(im, name)
3787 RETVAL = i_tags_delbyname(&im->tags, name);
3792 i_tags_delbycode(im, code)
3796 RETVAL = i_tags_delbycode(&im->tags, code);
3801 i_tags_get(im, index)
3805 if (index >= 0 && index < im->tags.count) {
3806 i_img_tag *entry = im->tags.tags + index;
3810 PUSHs(sv_2mortal(newSVpv(entry->name, 0)));
3813 PUSHs(sv_2mortal(newSViv(entry->code)));
3816 PUSHs(sv_2mortal(newSVpvn(entry->data, entry->size)));
3819 PUSHs(sv_2mortal(newSViv(entry->idata)));
3824 i_tags_get_string(im, what_sv)
3828 char const *name = NULL;
3832 if (SvIOK(what_sv)) {
3833 code = SvIV(what_sv);
3837 name = SvPV_nolen(what_sv);
3840 if (i_tags_get_string(&im->tags, name, code, buffer, sizeof(buffer))) {
3842 PUSHs(sv_2mortal(newSVpv(buffer, 0)));
3849 RETVAL = im->tags.count;
3855 MODULE = Imager PACKAGE = Imager::FillHandle PREFIX=IFILL_
3859 Imager::FillHandle fill
3862 IFILL_CLONE_SKIP(...)
3864 (void)items; /* avoid unused warning for XS variable */
3869 MODULE = Imager PACKAGE = Imager
3872 i_new_fill_solid(cl, combine)
3877 i_new_fill_solidf(cl, combine)
3878 Imager::Color::Float cl
3882 i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy)
3890 unsigned char *cust_hatch;
3894 cust_hatch = (unsigned char *)SvPV(ST(4), len);
3898 RETVAL = i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy);
3903 i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy)
3904 Imager::Color::Float fg
3905 Imager::Color::Float bg
3911 unsigned char *cust_hatch;
3915 cust_hatch = (unsigned char *)SvPV(ST(4), len);
3919 RETVAL = i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy);
3924 i_new_fill_image(src, matrix, xoff, yoff, combine)
3941 if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
3942 croak("i_new_fill_image: parameter must be an arrayref");
3943 av=(AV*)SvRV(ST(1));
3947 for (i = 0; i < len; ++i) {
3948 sv1=(*(av_fetch(av,i,0)));
3949 matrix[i] = SvNV(sv1);
3955 RETVAL = i_new_fill_image(src, matrixp, xoff, yoff, combine);
3959 MODULE = Imager PACKAGE = Imager::Internal::Hlines PREFIX=i_int_hlines_
3961 # this class is only exposed for testing
3964 i_int_hlines_testing()
3966 #if i_int_hlines_testing()
3968 Imager::Internal::Hlines
3969 i_int_hlines_new(start_y, count_y, start_x, count_x)
3975 Imager::Internal::Hlines
3976 i_int_hlines_new_img(im)
3980 i_int_hlines_add(hlines, y, minx, width)
3981 Imager::Internal::Hlines hlines
3987 i_int_hlines_DESTROY(hlines)
3988 Imager::Internal::Hlines hlines
3991 i_int_hlines_dump(hlines)
3992 Imager::Internal::Hlines hlines
3995 i_int_hlines_CLONE_SKIP(cls)
4000 PERL_SET_GLOBAL_CALLBACKS;
4001 PERL_PL_SET_GLOBAL_CALLBACKS;
4002 work_context = im_context_new();
4003 im_get_context = perl_get_context;