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"
27 #if i_int_hlines_testing()
33 #define ARRAY_COUNT(array) (sizeof(array)/sizeof(*array))
37 Context object management
41 typedef im_context_t Imager__Context;
43 #define im_context_DESTROY(ctx) im_context_refdec((ctx), "DESTROY")
45 #ifdef PERL_IMPLICIT_CONTEXT
47 #define MY_CXT_KEY "Imager::_context" XS_VERSION
55 im_context_t fallback_context;
60 MY_CXT.ctx = im_context_new();
61 sv_setref_pv(get_sv("Imager::_context", GV_ADD), "Imager::Context", MY_CXT.ctx);
63 /* Ideally we'd free this reference, but the error message memory
64 was never released on exit, so the associated memory here is reasonable
66 With logging enabled we always need at least one context, since
67 objects may be released fairly late and attempt to get the log file.
69 im_context_refinc(MY_CXT.ctx, "start_context");
70 fallback_context = MY_CXT.ctx;
74 perl_get_context(void) {
78 return MY_CXT.ctx ? MY_CXT.ctx : fallback_context;
83 static im_context_t perl_context;
87 perl_context = im_context_new();
88 im_context_refinc(perl_context, "start_context");
92 perl_get_context(void) {
98 /* used to represent channel lists parameters */
99 typedef struct i_channel_list_tag {
106 const i_sample_t *samples;
111 const i_fsample_t *samples;
116 const i_polygon_t *polygons;
121 Allocate memory that will be discarded when mortals are discarded.
126 malloc_temp(pTHX_ size_t size) {
127 SV *sv = sv_2mortal(newSV(size));
133 calloc_temp(pTHX_ size_t size) {
134 void *result = malloc_temp(aTHX_ size);
135 memset(result, 0, size);
140 /* for use with the T_AVARRAY typemap */
141 #define doublePtr(size) ((double *)calloc_temp(aTHX_ sizeof(double) * (size)))
142 #define SvDouble(sv, pname) (SvNV(sv))
144 #define intPtr(size) ((int *)calloc_temp(aTHX_ sizeof(int) * (size)))
145 #define SvInt(sv, pname) (SvIV(sv))
147 #define i_img_dimPtr(size) ((i_img_dim *)calloc_temp(aTHX_ sizeof(i_img_dim) * (size)))
148 #define SvI_img_dim(sv, pname) (SvIV(sv))
150 #define i_colorPtr(size) ((i_color *)calloc_temp(aTHX_ sizeof(i_color *) * (size)))
152 #define SvI_color(sv, pname) S_sv_to_i_color(aTHX_ sv, pname)
155 S_sv_to_i_color(pTHX_ SV *sv, const char *pname) {
156 if (!sv_derived_from(sv, "Imager::Color")) {
157 croak("%s: not a color object", pname);
159 return *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
162 /* These functions are all shared - then comes platform dependant code */
163 static int getstr(void *hv_t,char *key,char **store) {
168 mm_log((1,"getstr(hv_t %p, key %s, store %p)\n",hv_t,key,store));
170 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
172 svpp=hv_fetch(hv, key, strlen(key), 0);
173 *store=SvPV(*svpp, PL_na );
178 static int getint(void *hv_t,char *key,int *store) {
183 mm_log((1,"getint(hv_t %p, key %s, store %p)\n",hv_t,key,store));
185 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
187 svpp=hv_fetch(hv, key, strlen(key), 0);
188 *store=(int)SvIV(*svpp);
192 static int getdouble(void *hv_t,char* key,double *store) {
197 mm_log((1,"getdouble(hv_t %p, key %s, store %p)\n",hv_t,key,store));
199 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
200 svpp=hv_fetch(hv, key, strlen(key), 0);
201 *store=(double)SvNV(*svpp);
205 static int getvoid(void *hv_t,char* key,void **store) {
210 mm_log((1,"getvoid(hv_t %p, key %s, store %p)\n",hv_t,key,store));
212 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
214 svpp=hv_fetch(hv, key, strlen(key), 0);
215 *store = INT2PTR(void*, SvIV(*svpp));
220 static int getobj(void *hv_t,char *key,char *type,void **store) {
225 mm_log((1,"getobj(hv_t %p, key %s,type %s, store %p)\n",hv_t,key,type,store));
227 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
229 svpp=hv_fetch(hv, key, strlen(key), 0);
231 if (sv_derived_from(*svpp,type)) {
232 IV tmp = SvIV((SV*)SvRV(*svpp));
233 *store = INT2PTR(void*, tmp);
235 mm_log((1,"getobj: key exists in hash but is not of correct type"));
242 UTIL_table_t i_UTIL_table={getstr,getint,getdouble,getvoid,getobj};
245 free_buffer(void *p) {
251 i_log_entry(char *string, int level) {
252 mm_log((level, "%s", string));
256 make_i_color_sv(pTHX_ const i_color *c) {
258 i_color *col = mymalloc(sizeof(i_color));
261 sv_setref_pv(sv, "Imager::Color", (void *)col);
266 #define CBDATA_BUFSIZE 8192
269 /* the SVs we use to call back to Perl */
277 call_reader(struct cbdata *cbd, void *buf, size_t size,
285 if (!SvOK(cbd->readcb)) {
286 mm_log((1, "read callback called but no readcb supplied\n"));
287 i_push_error(0, "read callback called but no readcb supplied");
295 PUSHs(sv_2mortal(newSViv(size)));
296 PUSHs(sv_2mortal(newSViv(maxread)));
299 count = perl_call_sv(cbd->readcb, G_SCALAR);
304 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
310 char *ptr = SvPVbyte(data, len);
312 croak("Too much data returned in reader callback (wanted %d, got %d, expected %d)",
313 (int)size, (int)len, (int)maxread);
315 memcpy(buf, ptr, len);
330 io_seeker(void *p, off_t offset, int whence) {
332 struct cbdata *cbd = p;
337 if (!SvOK(cbd->seekcb)) {
338 mm_log((1, "seek callback called but no seekcb supplied\n"));
339 i_push_error(0, "seek callback called but no seekcb supplied");
347 PUSHs(sv_2mortal(newSViv(offset)));
348 PUSHs(sv_2mortal(newSViv(whence)));
351 count = perl_call_sv(cbd->seekcb, G_SCALAR);
356 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
368 io_writer(void *p, void const *data, size_t size) {
370 struct cbdata *cbd = p;
376 if (!SvOK(cbd->writecb)) {
377 mm_log((1, "write callback called but no writecb supplied\n"));
378 i_push_error(0, "write callback called but no writecb supplied");
386 PUSHs(sv_2mortal(newSVpv((char *)data, size)));
389 count = perl_call_sv(cbd->writecb, G_SCALAR);
393 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
396 success = SvTRUE(sv);
403 return success ? size : -1;
407 io_reader(void *p, void *data, size_t size) {
408 struct cbdata *cbd = p;
410 return call_reader(cbd, data, size, size);
413 static int io_closer(void *p) {
415 struct cbdata *cbd = p;
418 if (SvOK(cbd->closecb)) {
427 count = perl_call_sv(cbd->closecb, G_SCALAR);
433 success = SvTRUE(sv);
443 return success ? 0 : -1;
446 static void io_destroyer(void *p) {
448 struct cbdata *cbd = p;
450 SvREFCNT_dec(cbd->writecb);
451 SvREFCNT_dec(cbd->readcb);
452 SvREFCNT_dec(cbd->seekcb);
453 SvREFCNT_dec(cbd->closecb);
458 im_SvREFSCALAR(SV *sv) {
459 svtype type = SvTYPE(sv);
469 #if PERL_VERSION > 10
480 describe_sv(SV *sv) {
483 svtype type = SvTYPE(SvRV(sv));
485 case SVt_PVCV: return "CV";
486 case SVt_PVGV: return "GV";
487 case SVt_PVLV: return "LV";
488 default: return "some reference";
492 return "non-reference scalar";
501 do_io_new_buffer(pTHX_ SV *data_sv) {
508 if (SvROK(data_sv)) {
509 if (im_SvREFSCALAR(SvRV(data_sv))) {
513 i_push_errorf(0, "data is not a scalar or a reference to scalar");
521 /* previously this would keep the SV around, but this is unsafe in
522 many ways, so always copy the bytes */
523 data = SvPVbyte(sv, length);
524 data_copy = mymalloc(length);
525 memcpy(data_copy, data, length);
526 return io_new_buffer(data_copy, length, free_buffer, data_copy);
530 do_io_new_cb(pTHX_ SV *writecb, SV *readcb, SV *seekcb, SV *closecb) {
533 cbd = mymalloc(sizeof(struct cbdata));
534 cbd->writecb = newSVsv(writecb);
535 cbd->readcb = newSVsv(readcb);
536 cbd->seekcb = newSVsv(seekcb);
537 cbd->closecb = newSVsv(closecb);
539 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)));
541 return io_new_cb(cbd, io_reader, io_writer, io_seeker, io_closer,
549 static int lookup_name(const struct value_name *names, int count, char *name, int def_value)
552 for (i = 0; i < count; ++i)
553 if (strEQ(names[i].name, name))
554 return names[i].value;
558 static struct value_name transp_names[] =
561 { "threshold", tr_threshold },
562 { "errdiff", tr_errdiff },
563 { "ordered", tr_ordered, },
566 static struct value_name make_color_names[] =
568 { "none", mc_none, },
569 { "webmap", mc_web_map, },
570 { "addi", mc_addi, },
571 { "mediancut", mc_median_cut, },
572 { "mono", mc_mono, },
573 { "monochrome", mc_mono, },
574 { "gray", mc_gray, },
575 { "gray4", mc_gray4, },
576 { "gray16", mc_gray16, },
579 static struct value_name translate_names[] =
581 { "giflib", pt_giflib, },
582 { "closest", pt_closest, },
583 { "perturb", pt_perturb, },
584 { "errdiff", pt_errdiff, },
587 static struct value_name errdiff_names[] =
589 { "floyd", ed_floyd, },
590 { "jarvis", ed_jarvis, },
591 { "stucki", ed_stucki, },
592 { "custom", ed_custom, },
595 static struct value_name orddith_names[] =
597 { "random", od_random, },
598 { "dot8", od_dot8, },
599 { "dot4", od_dot4, },
600 { "hline", od_hline, },
601 { "vline", od_vline, },
602 { "/line", od_slashline, },
603 { "slashline", od_slashline, },
604 { "\\line", od_backline, },
605 { "backline", od_backline, },
606 { "tiny", od_tiny, },
607 { "custom", od_custom, },
610 /* look through the hash for quantization options */
612 ip_handle_quant_opts(pTHX_ i_quantize *quant, HV *hv)
614 /*** POSSIBLY BROKEN: do I need to unref the SV from hv_fetch ***/
620 quant->mc_colors = mymalloc(quant->mc_size * sizeof(i_color));
622 sv = hv_fetch(hv, "transp", 6, 0);
623 if (sv && *sv && (str = SvPV(*sv, len))) {
625 lookup_name(transp_names, sizeof(transp_names)/sizeof(*transp_names),
627 if (quant->transp != tr_none) {
628 quant->tr_threshold = 127;
629 sv = hv_fetch(hv, "tr_threshold", 12, 0);
631 quant->tr_threshold = SvIV(*sv);
633 if (quant->transp == tr_errdiff) {
634 sv = hv_fetch(hv, "tr_errdiff", 10, 0);
635 if (sv && *sv && (str = SvPV(*sv, len)))
636 quant->tr_errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
638 if (quant->transp == tr_ordered) {
639 quant->tr_orddith = od_tiny;
640 sv = hv_fetch(hv, "tr_orddith", 10, 0);
641 if (sv && *sv && (str = SvPV(*sv, len)))
642 quant->tr_orddith = lookup_name(orddith_names, sizeof(orddith_names)/sizeof(*orddith_names), str, od_random);
644 if (quant->tr_orddith == od_custom) {
645 sv = hv_fetch(hv, "tr_map", 6, 0);
646 if (sv && *sv && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
647 AV *av = (AV*)SvRV(*sv);
648 len = av_len(av) + 1;
649 if (len > sizeof(quant->tr_custom))
650 len = sizeof(quant->tr_custom);
651 for (i = 0; i < len; ++i) {
652 SV **sv2 = av_fetch(av, i, 0);
654 quant->tr_custom[i] = SvIV(*sv2);
657 while (i < sizeof(quant->tr_custom))
658 quant->tr_custom[i++] = 0;
663 quant->make_colors = mc_median_cut;
664 sv = hv_fetch(hv, "make_colors", 11, 0);
665 if (sv && *sv && (str = SvPV(*sv, len))) {
667 lookup_name(make_color_names, sizeof(make_color_names)/sizeof(*make_color_names), str, mc_median_cut);
669 sv = hv_fetch(hv, "colors", 6, 0);
670 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
671 /* needs to be an array of Imager::Color
672 note that the caller allocates the mc_color array and sets mc_size
674 AV *av = (AV *)SvRV(*sv);
675 quant->mc_count = av_len(av)+1;
676 if (quant->mc_count > quant->mc_size)
677 quant->mc_count = quant->mc_size;
678 for (i = 0; i < quant->mc_count; ++i) {
679 SV **sv1 = av_fetch(av, i, 0);
680 if (sv1 && *sv1 && SvROK(*sv1) && sv_derived_from(*sv1, "Imager::Color")) {
681 i_color *col = INT2PTR(i_color *, SvIV((SV*)SvRV(*sv1)));
682 quant->mc_colors[i] = *col;
686 sv = hv_fetch(hv, "max_colors", 10, 0);
689 if (i <= quant->mc_size && i >= quant->mc_count)
693 quant->translate = pt_closest;
694 sv = hv_fetch(hv, "translate", 9, 0);
695 if (sv && *sv && (str = SvPV(*sv, len))) {
696 quant->translate = lookup_name(translate_names, sizeof(translate_names)/sizeof(*translate_names), str, pt_closest);
698 sv = hv_fetch(hv, "errdiff", 7, 0);
699 if (sv && *sv && (str = SvPV(*sv, len))) {
700 quant->errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
702 if (quant->translate == pt_errdiff && quant->errdiff == ed_custom) {
703 /* get the error diffusion map */
704 sv = hv_fetch(hv, "errdiff_width", 13, 0);
706 quant->ed_width = SvIV(*sv);
707 sv = hv_fetch(hv, "errdiff_height", 14, 0);
709 quant->ed_height = SvIV(*sv);
710 sv = hv_fetch(hv, "errdiff_orig", 12, 0);
712 quant->ed_orig = SvIV(*sv);
713 if (quant->ed_width > 0 && quant->ed_height > 0) {
715 quant->ed_map = mymalloc(sizeof(int)*quant->ed_width*quant->ed_height);
716 sv = hv_fetch(hv, "errdiff_map", 11, 0);
717 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
718 AV *av = (AV*)SvRV(*sv);
719 len = av_len(av) + 1;
720 if (len > quant->ed_width * quant->ed_height)
721 len = quant->ed_width * quant->ed_height;
722 for (i = 0; i < len; ++i) {
723 SV **sv2 = av_fetch(av, i, 0);
725 quant->ed_map[i] = SvIV(*sv2);
726 sum += quant->ed_map[i];
732 myfree(quant->ed_map);
734 quant->errdiff = ed_floyd;
738 sv = hv_fetch(hv, "perturb", 7, 0);
740 quant->perturb = SvIV(*sv);
744 ip_cleanup_quant_opts(pTHX_ i_quantize *quant) {
745 myfree(quant->mc_colors);
747 myfree(quant->ed_map);
750 /* copies the color map from the hv into the colors member of the HV */
752 ip_copy_colors_back(pTHX_ HV *hv, i_quantize *quant) {
758 sv = hv_fetch(hv, "colors", 6, 0);
759 if (!sv || !*sv || !SvROK(*sv) || SvTYPE(SvRV(*sv)) != SVt_PVAV) {
764 av = (AV *)SvRV(*sv);
766 av_extend(av, quant->mc_count+1);
767 for (i = 0; i < quant->mc_count; ++i) {
768 i_color *in = quant->mc_colors+i;
769 Imager__Color c = ICL_new_internal(in->rgb.r, in->rgb.g, in->rgb.b, 255);
770 work = sv_newmortal();
771 sv_setref_pv(work, "Imager::Color", (void *)c);
777 static struct value_name
778 poly_fill_mode_names[] =
780 { "evenodd", i_pfm_evenodd },
781 { "nonzero", i_pfm_nonzero }
784 static i_poly_fill_mode_t
785 S_get_poly_fill_mode(pTHX_ SV *sv) {
786 if (looks_like_number(sv)) {
788 if (work < (IV)i_pfm_evenodd || work > (IV)i_pfm_nonzero)
789 work = (IV)i_pfm_evenodd;
790 return (i_poly_fill_mode_t)work;
793 return (i_poly_fill_mode_t)lookup_name
794 (poly_fill_mode_names, ARRAY_COUNT(poly_fill_mode_names),
795 SvPV_nolen(sv), i_pfm_evenodd);
800 S_get_polygon_list(pTHX_ i_polygon_list *polys, SV *sv) {
806 if (!SvOK(sv) || !SvROK(sv) || SvTYPE(SvRV(sv)) != SVt_PVAV)
807 croak("polys must be an arrayref");
810 polys->count = av_len(av) + 1;
811 if (polys->count < 1)
812 croak("polypolygon: no polygons provided");
813 s = malloc_temp(aTHX_ sizeof(i_polygon_t) * polys->count);
814 for (i = 0; i < polys->count; ++i) {
815 SV **poly_sv = av_fetch(av, i, 0);
819 double *x_data, *y_data;
824 croak("poly_polygon: nothing found for polygon %d", i);
825 /* needs to be another av */
826 SvGETMAGIC(*poly_sv);
827 if (!SvOK(*poly_sv) || !SvROK(*poly_sv) || SvTYPE(SvRV(*poly_sv)) != SVt_PVAV)
828 croak("poly_polygon: polygon %d isn't an arrayref", i);
829 poly_av = (AV*)SvRV(*poly_sv);
830 /* with two elements */
831 if (av_len(poly_av) != 1)
832 croak("poly_polygon: polygon %d should contain two arrays", i);
833 x_sv = av_fetch(poly_av, 0, 0);
834 y_sv = av_fetch(poly_av, 1, 0);
836 croak("poly_polygon: polygon %d has no x elements", i);
838 croak("poly_polygon: polygon %d has no y elements", i);
841 if (!SvOK(*x_sv) || !SvROK(*x_sv) || SvTYPE(SvRV(*x_sv)) != SVt_PVAV)
842 croak("poly_polygon: polygon %d x elements isn't an array", i);
843 if (!SvOK(*y_sv) || !SvROK(*y_sv) || SvTYPE(SvRV(*y_sv)) != SVt_PVAV)
844 croak("poly_polygon: polygon %d y elements isn't an array", i);
845 x_av = (AV*)SvRV(*x_sv);
846 y_av = (AV*)SvRV(*y_sv);
847 if (av_len(x_av) != av_len(y_av))
848 croak("poly_polygon: polygon %d x and y arrays different lengths", i+1);
849 point_count = av_len(x_av)+1;
850 x_data = malloc_temp(aTHX_ sizeof(double) * point_count * 2);
851 y_data = x_data + point_count;
853 for (j = 0; j < point_count; ++j) {
854 SV **x_item_sv = av_fetch(x_av, j, 0);
855 SV **y_item_sv = av_fetch(y_av, j, 0);
856 x_data[j] = x_item_sv ? SvNV(*x_item_sv) : 0;
857 y_data[j] = y_item_sv ? SvNV(*y_item_sv) : 0;
861 s[i].count = point_count;
866 /* loads the segments of a fountain fill into an array */
867 static i_fountain_seg *
868 load_fount_segs(pTHX_ AV *asegs, int *count) {
869 /* Each element of segs must contain:
870 [ start, middle, end, c0, c1, segtype, colortrans ]
871 start, middle, end are doubles from 0 to 1
872 c0, c1 are Imager::Color::Float or Imager::Color objects
873 segtype, colortrans are ints
877 i_fountain_seg *segs;
881 *count = av_len(asegs)+1;
883 croak("i_fountain must have at least one segment");
884 segs = mymalloc(sizeof(i_fountain_seg) * *count);
885 for(i = 0; i < *count; i++) {
886 SV **sv1 = av_fetch(asegs, i, 0);
887 if (!sv1 || !*sv1 || !SvROK(*sv1)
888 || SvTYPE(SvRV(*sv1)) != SVt_PVAV) {
890 croak("i_fountain: segs must be an arrayref of arrayrefs");
892 aseg = (AV *)SvRV(*sv1);
893 if (av_len(aseg) != 7-1) {
895 croak("i_fountain: a segment must have 7 members");
897 for (j = 0; j < 3; ++j) {
898 SV **sv2 = av_fetch(aseg, j, 0);
901 croak("i_fountain: XS error");
903 work[j] = SvNV(*sv2);
905 segs[i].start = work[0];
906 segs[i].middle = work[1];
907 segs[i].end = work[2];
908 for (j = 0; j < 2; ++j) {
909 SV **sv3 = av_fetch(aseg, 3+j, 0);
910 if (!sv3 || !*sv3 || !SvROK(*sv3) ||
911 (!sv_derived_from(*sv3, "Imager::Color")
912 && !sv_derived_from(*sv3, "Imager::Color::Float"))) {
914 croak("i_fountain: segs must contain colors in elements 3 and 4");
916 if (sv_derived_from(*sv3, "Imager::Color::Float")) {
917 segs[i].c[j] = *INT2PTR(i_fcolor *, SvIV((SV *)SvRV(*sv3)));
920 i_color c = *INT2PTR(i_color *, SvIV((SV *)SvRV(*sv3)));
922 for (ch = 0; ch < MAXCHANNELS; ++ch) {
923 segs[i].c[j].channel[ch] = c.channel[ch] / 255.0;
927 for (j = 0; j < 2; ++j) {
928 SV **sv2 = av_fetch(aseg, j+5, 0);
931 croak("i_fountain: XS error");
933 worki[j] = SvIV(*sv2);
935 segs[i].type = worki[0];
936 segs[i].color = worki[1];
942 /* validates the indexes supplied to i_ppal
944 i_ppal() doesn't do that for speed, but I'm not comfortable doing that
949 validate_i_ppal(i_img *im, i_palidx const *indexes, int count) {
950 int color_count = i_colorcount(im);
953 if (color_count == -1)
954 croak("i_plin() called on direct color image");
956 for (i = 0; i < count; ++i) {
957 if (indexes[i] >= color_count) {
958 croak("i_plin() called with out of range color index %d (max %d)",
959 indexes[i], color_count-1);
964 /* I don't think ICLF_* names belong at the C interface
965 this makes the XS code think we have them, to let us avoid
966 putting function bodies in the XS code
968 #define ICLF_new_internal(r, g, b, a) i_fcolor_new((r), (g), (b), (a))
969 #define ICLF_DESTROY(cl) i_fcolor_destroy(cl)
972 #define i_log_enabled() 1
974 #define i_log_enabled() 0
977 #if i_int_hlines_testing()
979 typedef i_int_hlines *Imager__Internal__Hlines;
981 static i_int_hlines *
982 i_int_hlines_new(i_img_dim start_y, i_img_dim count_y, i_img_dim start_x, i_img_dim count_x) {
983 i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
984 i_int_init_hlines(result, start_y, count_y, start_x, count_x);
989 static i_int_hlines *
990 i_int_hlines_new_img(i_img *im) {
991 i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
992 i_int_init_hlines_img(result, im);
998 i_int_hlines_DESTROY(i_int_hlines *hlines) {
999 i_int_hlines_destroy(hlines);
1003 #define i_int_hlines_CLONE_SKIP(cls) 1
1005 static int seg_compare(const void *vleft, const void *vright) {
1006 const i_int_hline_seg *left = vleft;
1007 const i_int_hline_seg *right = vright;
1009 return left->minx - right->minx;
1013 i_int_hlines_dump(i_int_hlines *hlines) {
1015 SV *dump = newSVpvf("start_y: %" i_DF " limit_y: %" i_DF " start_x: %" i_DF " limit_x: %" i_DF"\n",
1016 i_DFc(hlines->start_y), i_DFc(hlines->limit_y), i_DFc(hlines->start_x), i_DFc(hlines->limit_x));
1019 for (y = hlines->start_y; y < hlines->limit_y; ++y) {
1020 i_int_hline_entry *entry = hlines->entries[y-hlines->start_y];
1023 /* sort the segments, if any */
1025 qsort(entry->segs, entry->count, sizeof(i_int_hline_seg), seg_compare);
1027 sv_catpvf(dump, " %" i_DF " (%" i_DF "):", i_DFc(y), i_DFc(entry->count));
1028 for (i = 0; i < entry->count; ++i) {
1029 sv_catpvf(dump, " [%" i_DF ", %" i_DF ")", i_DFc(entry->segs[i].minx),
1030 i_DFc(entry->segs[i].x_limit));
1032 sv_catpv(dump, "\n");
1042 i_sv_off_t(pTHX_ SV *sv) {
1043 #if LSEEKSIZE > IVSIZE
1044 return (off_t)SvNV(sv);
1046 return (off_t)SvIV(sv);
1051 i_new_sv_off_t(pTHX_ off_t off) {
1052 #if LSEEKSIZE > IVSIZE
1053 return newSVnv(off);
1055 return newSViv(off);
1059 static im_pl_ext_funcs im_perl_funcs =
1061 IMAGER_PL_API_VERSION,
1062 IMAGER_PL_API_LEVEL,
1063 ip_handle_quant_opts,
1064 ip_cleanup_quant_opts,
1068 #define PERL_PL_SET_GLOBAL_CALLBACKS \
1069 sv_setiv(get_sv(PERL_PL_FUNCTION_TABLE_NAME, 1), PTR2IV(&im_perl_funcs));
1071 #define IIM_new i_img_8_new
1072 #define IIM_DESTROY i_img_destroy
1075 #ifdef IMEXIF_ENABLE
1076 #define i_exif_enabled() 1
1078 #define i_exif_enabled() 0
1081 /* trying to use more C style names, map them here */
1082 #define i_io_DESTROY(ig) io_glue_destroy(ig)
1084 #define i_img_get_width(im) ((im)->xsize)
1085 #define i_img_get_height(im) ((im)->ysize)
1087 #define i_img_epsilonf() (DBL_EPSILON * 4)
1089 /* avoid some xsubpp strangeness */
1090 #define NEWLINE '\n'
1092 MODULE = Imager PACKAGE = Imager::Color PREFIX = ICL_
1095 ICL_new_internal(r,g,b,a)
1107 ICL_set_internal(cl,r,g,b,a)
1114 ICL_set_internal(cl, r, g, b, a);
1128 PUSHs(sv_2mortal(newSViv(cl->rgba.r)));
1129 PUSHs(sv_2mortal(newSViv(cl->rgba.g)));
1130 PUSHs(sv_2mortal(newSViv(cl->rgba.b)));
1131 PUSHs(sv_2mortal(newSViv(cl->rgba.a)));
1137 RETVAL = mymalloc(sizeof(i_color));
1139 i_hsv_to_rgb(RETVAL);
1147 RETVAL = mymalloc(sizeof(i_color));
1149 i_rgb_to_hsv(RETVAL);
1155 MODULE = Imager PACKAGE = Imager::Color::Float PREFIX=ICLF_
1157 Imager::Color::Float
1158 ICLF_new_internal(r, g, b, a)
1166 Imager::Color::Float cl
1170 Imager::Color::Float cl
1174 EXTEND(SP, MAXCHANNELS);
1175 for (ch = 0; ch < MAXCHANNELS; ++ch) {
1176 /* printf("%d: %g\n", ch, cl->channel[ch]); */
1177 PUSHs(sv_2mortal(newSVnv(cl->channel[ch])));
1181 ICLF_set_internal(cl,r,g,b,a)
1182 Imager::Color::Float cl
1195 Imager::Color::Float
1197 Imager::Color::Float c
1199 RETVAL = mymalloc(sizeof(i_fcolor));
1201 i_hsv_to_rgbf(RETVAL);
1205 Imager::Color::Float
1207 Imager::Color::Float c
1209 RETVAL = mymalloc(sizeof(i_fcolor));
1211 i_rgb_to_hsvf(RETVAL);
1215 MODULE = Imager PACKAGE = Imager::ImgRaw PREFIX = IIM_
1229 MODULE = Imager PACKAGE = Imager
1243 io_new_buffer(data_sv)
1247 RETVAL = do_io_new_buffer(aTHX_ data_sv);
1254 io_new_cb(writecb, readcb, seekcb, closecb, maxwrite = CBDATA_BUFSIZE)
1260 RETVAL = do_io_new_cb(aTHX_ writecb, readcb, seekcb, closecb);
1268 unsigned char* data;
1272 tlength = io_slurp(ig, &data);
1273 RETVAL = newSVpv((char *)data,tlength);
1280 i_set_image_file_limits(width, height, bytes)
1286 i_get_image_file_limits()
1288 i_img_dim width, height;
1291 if (i_get_image_file_limits(&width, &height, &bytes)) {
1293 PUSHs(sv_2mortal(newSViv(width)));
1294 PUSHs(sv_2mortal(newSViv(height)));
1295 PUSHs(sv_2mortal(newSVuv(bytes)));
1299 i_int_check_image_file_limits(width, height, channels, sample_size)
1306 MODULE = Imager PACKAGE = Imager::IO PREFIX = io_
1309 io_new_fd(class, fd)
1312 RETVAL = io_new_fd(fd);
1317 io_new_buffer(class, data_sv)
1321 RETVAL = do_io_new_buffer(aTHX_ data_sv);
1328 io_new_cb(class, writecb, readcb, seekcb, closecb)
1334 RETVAL = do_io_new_cb(aTHX_ writecb, readcb, seekcb, closecb);
1339 io_new_bufchain(class)
1341 RETVAL = io_new_bufchain();
1346 io__new_perlio(class, io)
1349 RETVAL = im_io_new_perlio(aTHX_ io);
1357 unsigned char* data;
1361 tlength = io_slurp(ig, &data);
1362 RETVAL = newSVpv((char *)data,tlength);
1367 MODULE = Imager PACKAGE = Imager::IO PREFIX = i_io_
1370 i_io_raw_write(ig, data_sv)
1377 data = SvPVbyte(data_sv, size);
1378 RETVAL = i_io_raw_write(ig, data, size);
1383 i_io_raw_read(ig, buffer_sv, size)
1392 croak("size negative in call to i_io_raw_read()");
1393 /* prevent an undefined value warning if they supplied an
1395 Orginally conditional on !SvOK(), but this will prevent the
1396 downgrade from croaking */
1397 sv_setpvn(buffer_sv, "", 0);
1399 if (SvUTF8(buffer_sv))
1400 sv_utf8_downgrade(buffer_sv, FALSE);
1402 buffer = SvGROW(buffer_sv, size+1);
1403 result = i_io_raw_read(ig, buffer, size);
1405 SvCUR_set(buffer_sv, result);
1406 *SvEND(buffer_sv) = '\0';
1407 SvPOK_only(buffer_sv);
1409 PUSHs(sv_2mortal(newSViv(result)));
1415 i_io_raw_read2(ig, size)
1424 croak("size negative in call to i_io_read2()");
1425 buffer_sv = newSV(size);
1426 buffer = SvGROW(buffer_sv, size+1);
1427 result = i_io_raw_read(ig, buffer, size);
1429 SvCUR_set(buffer_sv, result);
1430 *SvEND(buffer_sv) = '\0';
1431 SvPOK_only(buffer_sv);
1433 PUSHs(sv_2mortal(buffer_sv));
1437 SvREFCNT_dec(buffer_sv);
1441 i_io_raw_seek(ig, position, whence)
1455 i_io_CLONE_SKIP(...)
1457 (void)items; /* avoid unused warning for XS variable */
1484 i_io_seek(ig, off, whence)
1490 i_io_peekn(ig, size)
1498 buffer_sv = newSV(size+1);
1499 buffer = SvGROW(buffer_sv, size+1);
1500 result = i_io_peekn(ig, buffer, size);
1502 SvCUR_set(buffer_sv, result);
1503 *SvEND(buffer_sv) = '\0';
1504 SvPOK_only(buffer_sv);
1506 PUSHs(sv_2mortal(buffer_sv));
1510 SvREFCNT_dec(buffer_sv);
1514 i_io_read(ig, buffer_sv, size)
1523 croak("size negative in call to i_io_read()");
1524 /* prevent an undefined value warning if they supplied an
1526 Orginally conditional on !SvOK(), but this will prevent the
1527 downgrade from croaking */
1528 sv_setpvn(buffer_sv, "", 0);
1530 if (SvUTF8(buffer_sv))
1531 sv_utf8_downgrade(buffer_sv, FALSE);
1533 buffer = SvGROW(buffer_sv, size+1);
1534 result = i_io_read(ig, buffer, size);
1536 SvCUR_set(buffer_sv, result);
1537 *SvEND(buffer_sv) = '\0';
1538 SvPOK_only(buffer_sv);
1540 PUSHs(sv_2mortal(newSViv(result)));
1546 i_io_read2(ig, size)
1555 croak("size zero in call to read2()");
1556 buffer_sv = newSV(size);
1557 buffer = SvGROW(buffer_sv, size+1);
1558 result = i_io_read(ig, buffer, size);
1560 SvCUR_set(buffer_sv, result);
1561 *SvEND(buffer_sv) = '\0';
1562 SvPOK_only(buffer_sv);
1564 PUSHs(sv_2mortal(buffer_sv));
1568 SvREFCNT_dec(buffer_sv);
1572 i_io_gets(ig, size = 8192, eol = NEWLINE)
1582 croak("size too small in call to gets()");
1583 buffer_sv = sv_2mortal(newSV(size+1));
1584 buffer = SvPVX(buffer_sv);
1585 result = i_io_gets(ig, buffer, size+1, eol);
1587 SvCUR_set(buffer_sv, result);
1588 *SvEND(buffer_sv) = '\0';
1589 SvPOK_only(buffer_sv);
1595 i_io_write(ig, data_sv)
1602 data = SvPVbyte(data_sv, size);
1603 RETVAL = i_io_write(ig, data, size);
1608 i_io_dump(ig, flags = I_IO_DUMP_DEFAULT)
1613 i_io_set_buffered(ig, flag = 1)
1618 i_io_is_buffered(ig)
1629 MODULE = Imager PACKAGE = Imager
1640 while( (item=i_format_list[i++]) != NULL ) {
1642 PUSHs(sv_2mortal(newSVpv(item,0)));
1646 i_sametype(im, x, y)
1652 i_sametype_chans(im, x, y, channels)
1659 i_init_log(name_sv,level)
1663 const char *name = SvOK(name_sv) ? SvPV_nolen(name_sv) : NULL;
1665 RETVAL = i_init_log(name, level);
1670 i_log_entry(string,level)
1683 i_img_info(im,info);
1685 PUSHs(sv_2mortal(newSViv(info[0])));
1686 PUSHs(sv_2mortal(newSViv(info[1])));
1687 PUSHs(sv_2mortal(newSViv(info[2])));
1688 PUSHs(sv_2mortal(newSViv(info[3])));
1694 i_img_setmask(im,ch_mask)
1703 i_img_getchannels(im)
1712 sv_2mortal(newSVpv((char *)im->idata, im->bytes))
1720 i_img_get_height(im)
1725 i_img_is_monochrome(im)
1731 result = i_img_is_monochrome(im, &zero_is_white);
1733 if (GIMME_V == G_ARRAY) {
1736 PUSHs(sv_2mortal(newSViv(zero_is_white)));
1745 i_line(im,x1,y1,x2,y2,val,endp)
1755 i_line_aa(im,x1,y1,x2,y2,val,endp)
1765 i_box(im,x1,y1,x2,y2,val)
1774 i_box_filled(im,x1,y1,x2,y2,val)
1783 i_box_filledf(im,x1,y1,x2,y2,val)
1789 Imager::Color::Float val
1792 i_box_cfill(im,x1,y1,x2,y2,fill)
1798 Imager::FillHandle fill
1801 i_arc(im,x,y,rad,d1,d2,val)
1811 i_arc_aa(im,x,y,rad,d1,d2,val)
1821 i_arc_cfill(im,x,y,rad,d1,d2,fill)
1828 Imager::FillHandle fill
1831 i_arc_aa_cfill(im,x,y,rad,d1,d2,fill)
1838 Imager::FillHandle fill
1842 i_circle_aa(im,x,y,rad,val)
1850 i_circle_aa_fill(im,x,y,rad,fill)
1855 Imager::FillHandle fill
1858 i_circle_out(im,x,y,rad,val)
1866 i_circle_out_aa(im,x,y,rad,val)
1874 i_arc_out(im,x,y,rad,d1,d2,val)
1884 i_arc_out_aa(im,x,y,rad,d1,d2,val)
1895 i_bezier_multi(im,x,y,val)
1904 if (size_x != size_y)
1905 croak("Imager: x and y arrays to i_bezier_multi must be equal length\n");
1906 i_bezier_multi(im,size_x,x,y,val);
1909 i_poly_aa_m(im,x,y,mode,val)
1913 i_poly_fill_mode_t mode
1919 if (size_x != size_y)
1920 croak("Imager: x and y arrays to i_poly_aa must be equal length\n");
1921 RETVAL = i_poly_aa_m(im, size_x, x, y, mode, val);
1926 i_poly_aa_cfill_m(im, x, y, mode, fill)
1930 i_poly_fill_mode_t mode
1931 Imager::FillHandle fill
1936 if (size_x != size_y)
1937 croak("Imager: x and y arrays to i_poly_aa_cfill must be equal length\n");
1938 RETVAL = i_poly_aa_cfill_m(im, size_x, x, y, mode, fill);
1943 i_poly_poly_aa(im, polys, mode, color)
1945 i_polygon_list polys
1946 i_poly_fill_mode_t mode
1949 RETVAL = i_poly_poly_aa(im, polys.count, polys.polygons, mode, color);
1954 i_poly_poly_aa_cfill(im, polys, mode, fill)
1956 i_polygon_list polys
1957 i_poly_fill_mode_t mode
1958 Imager::FillHandle fill
1960 RETVAL = i_poly_poly_aa_cfill(im, polys.count, polys.polygons, mode, fill);
1965 i_flood_fill(im,seedx,seedy,dcol)
1972 i_flood_cfill(im,seedx,seedy,fill)
1976 Imager::FillHandle fill
1979 i_flood_fill_border(im,seedx,seedy,dcol, border)
1984 Imager::Color border
1987 i_flood_cfill_border(im,seedx,seedy,fill, border)
1991 Imager::FillHandle fill
1992 Imager::Color border
1996 i_copyto(im,src,x1,y1,x2,y2,tx,ty)
2008 i_copyto_trans(im,src,x1,y1,x2,y2,tx,ty,trans)
2025 i_rubthru(im,src,tx,ty,src_minx,src_miny,src_maxx,src_maxy)
2036 i_compose(out, src, out_left, out_top, src_left, src_top, width, height, combine = ic_normal, opacity = 0.0)
2049 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)
2065 i_combine(src_av, channels_av = NULL)
2069 i_img **imgs = NULL;
2071 int *channels = NULL;
2076 in_count = av_len(src_av) + 1;
2078 imgs = mymalloc(sizeof(i_img*) * in_count);
2079 channels = mymalloc(sizeof(int) * in_count);
2080 for (i = 0; i < in_count; ++i) {
2081 psv = av_fetch(src_av, i, 0);
2082 if (!psv || !*psv || !sv_derived_from(*psv, "Imager::ImgRaw")) {
2085 croak("imgs must contain only images");
2087 tmp = SvIV((SV*)SvRV(*psv));
2088 imgs[i] = INT2PTR(i_img*, tmp);
2090 (psv = av_fetch(channels_av, i, 0)) != NULL &&
2092 channels[i] = SvIV(*psv);
2099 RETVAL = i_combine(imgs, channels, in_count);
2106 i_flipxy(im, direction)
2111 i_rotate90(im, degrees)
2116 i_rotate_exact(im, amount, ...)
2120 i_color *backp = NULL;
2121 i_fcolor *fbackp = NULL;
2125 /* extract the bg colors if any */
2126 /* yes, this is kind of strange */
2127 for (i = 2; i < items; ++i) {
2129 if (sv_derived_from(sv1, "Imager::Color")) {
2130 IV tmp = SvIV((SV*)SvRV(sv1));
2131 backp = INT2PTR(i_color *, tmp);
2133 else if (sv_derived_from(sv1, "Imager::Color::Float")) {
2134 IV tmp = SvIV((SV*)SvRV(sv1));
2135 fbackp = INT2PTR(i_fcolor *, tmp);
2138 RETVAL = i_rotate_exact_bg(im, amount, backp, fbackp);
2143 i_matrix_transform(im, xsize, ysize, matrix_av, ...)
2153 i_color *backp = NULL;
2154 i_fcolor *fbackp = NULL;
2156 len=av_len(matrix_av)+1;
2159 for (i = 0; i < len; ++i) {
2160 sv1=(*(av_fetch(matrix_av,i,0)));
2161 matrix[i] = SvNV(sv1);
2165 /* extract the bg colors if any */
2166 /* yes, this is kind of strange */
2167 for (i = 4; i < items; ++i) {
2169 if (sv_derived_from(sv1, "Imager::Color")) {
2170 IV tmp = SvIV((SV*)SvRV(sv1));
2171 backp = INT2PTR(i_color *, tmp);
2173 else if (sv_derived_from(sv1, "Imager::Color::Float")) {
2174 IV tmp = SvIV((SV*)SvRV(sv1));
2175 fbackp = INT2PTR(i_fcolor *, tmp);
2178 RETVAL = i_matrix_transform_bg(im, xsize, ysize, matrix, backp, fbackp);
2183 i_gaussian(im,stdev)
2188 i_unsharp_mask(im,stdev,scale)
2203 len = av_len(coef) + 1;
2204 c_coef=mymalloc( len * sizeof(double) );
2205 for(i = 0; i < len; i++) {
2206 sv1 = (*(av_fetch(coef, i, 0)));
2207 c_coef[i] = (double)SvNV(sv1);
2209 RETVAL = i_conv(im, c_coef, len);
2215 i_convert(src, avmain)
2227 outchan = av_len(avmain)+1;
2228 /* find the biggest */
2230 for (j=0; j < outchan; ++j) {
2231 temp = av_fetch(avmain, j, 0);
2232 if (temp && SvROK(*temp) && SvTYPE(SvRV(*temp)) == SVt_PVAV) {
2233 avsub = (AV*)SvRV(*temp);
2234 len = av_len(avsub)+1;
2239 i_push_errorf(0, "invalid matrix: element %d is not an array ref", j);
2243 coeff = mymalloc(sizeof(double) * outchan * inchan);
2244 for (j = 0; j < outchan; ++j) {
2245 avsub = (AV*)SvRV(*av_fetch(avmain, j, 0));
2246 len = av_len(avsub)+1;
2247 for (i = 0; i < len; ++i) {
2248 temp = av_fetch(avsub, i, 0);
2250 coeff[i+j*inchan] = SvNV(*temp);
2252 coeff[i+j*inchan] = 0;
2255 coeff[i++ + j*inchan] = 0;
2257 RETVAL = i_convert(src, coeff, outchan, inchan);
2268 unsigned int mask = 0;
2273 unsigned char (*maps)[256];
2275 len = av_len(pmaps_av)+1;
2276 if (im->channels < len)
2278 maps = mymalloc( len * sizeof(unsigned char [256]) );
2279 for (j=0; j<len ; j++) {
2280 temp = av_fetch(pmaps_av, j, 0);
2281 if (temp && SvROK(*temp) && (SvTYPE(SvRV(*temp)) == SVt_PVAV) ) {
2282 avsub = (AV*)SvRV(*temp);
2283 if(av_len(avsub) != 255)
2286 for (i=0; i<256 ; i++) {
2288 temp = av_fetch(avsub, i, 0);
2289 val = temp ? SvIV(*temp) : 0;
2291 if (val>255) val = 255;
2296 i_map(im, maps, mask);
2308 i_img_diffd(im1,im2)
2313 i_img_samef(im1, im2, epsilon = i_img_epsilonf(), what=NULL)
2323 _is_color_object(sv)
2327 RETVAL = SvOK(sv) && SvROK(sv) &&
2328 (sv_derived_from(sv, "Imager::Color")
2329 || sv_derived_from(sv, "Imager::Color::Float"));
2341 MODULE = Imager PACKAGE = Imager::Font::TT PREFIX=TT_
2343 #define TT_DESTROY(handle) i_tt_destroy(handle)
2347 Imager::Font::TT handle
2352 (void)items; /* avoid unused warning */
2358 MODULE = Imager PACKAGE = Imager
2362 i_tt_text(handle,im,xb,yb,cl,points,str_sv,smooth,utf8,align=1)
2363 Imager::Font::TT handle
2377 str = SvPV(str_sv, len);
2382 RETVAL = i_tt_text(handle, im, xb, yb, cl, points, str,
2383 len, smooth, utf8, align);
2389 i_tt_cp(handle,im,xb,yb,channel,points,str_sv,smooth,utf8,align=1)
2390 Imager::Font::TT handle
2404 str = SvPV(str_sv, len);
2409 RETVAL = i_tt_cp(handle, im, xb, yb, channel, points, str, len,
2410 smooth, utf8, align);
2416 i_tt_bbox(handle,point,str_sv,utf8)
2417 Imager::Font::TT handle
2422 i_img_dim cords[BOUNDING_BOX_COUNT];
2428 str = SvPV(str_sv, len);
2433 if ((rc=i_tt_bbox(handle,point,str,len,cords, utf8))) {
2435 for (i = 0; i < rc; ++i) {
2436 PUSHs(sv_2mortal(newSViv(cords[i])));
2441 i_tt_has_chars(handle, text_sv, utf8)
2442 Imager::Font::TT handle
2453 text = SvPV(text_sv, len);
2455 if (SvUTF8(text_sv))
2458 work = mymalloc(len);
2459 count = i_tt_has_chars(handle, text, len, utf8, work);
2460 if (GIMME_V == G_ARRAY) {
2462 for (i = 0; i < count; ++i) {
2463 PUSHs(boolSV(work[i]));
2468 PUSHs(sv_2mortal(newSVpv(work, count)));
2473 i_tt_dump_names(handle)
2474 Imager::Font::TT handle
2477 i_tt_face_name(handle)
2478 Imager::Font::TT handle
2483 len = i_tt_face_name(handle, name, sizeof(name));
2486 PUSHs(sv_2mortal(newSVpv(name, len-1)));
2490 i_tt_glyph_name(handle, text_sv, utf8 = 0)
2491 Imager::Font::TT handle
2503 text = SvPV(text_sv, work_len);
2505 if (SvUTF8(text_sv))
2512 ch = i_utf8_advance(&text, &len);
2514 i_push_error(0, "invalid UTF8 character");
2522 EXTEND(SP, count+1);
2523 if ((outsize = i_tt_glyph_name(handle, ch, name, sizeof(name))) != 0) {
2524 ST(count) = sv_2mortal(newSVpv(name, 0));
2527 ST(count) = &PL_sv_undef;
2536 i_test_format_probe(ig, length)
2541 i_readpnm_wiol(ig, allow_incomplete)
2543 int allow_incomplete
2547 i_readpnm_multi_wiol(ig, allow_incomplete)
2549 int allow_incomplete
2555 imgs = i_readpnm_multi_wiol(ig, &count, allow_incomplete);
2558 for (i = 0; i < count; ++i) {
2559 SV *sv = sv_newmortal();
2560 sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
2567 i_writeppm_wiol(im, ig)
2576 i_readraw_wiol(ig,x,y,datachannels,storechannels,intrl)
2585 i_writeraw_wiol(im,ig)
2590 i_writebmp_wiol(im,ig)
2595 i_readbmp_wiol(ig, allow_incomplete=0)
2597 int allow_incomplete
2601 i_writetga_wiol(im,ig, wierdpack, compress, idstring)
2610 idlen = SvCUR(ST(4));
2611 RETVAL = i_writetga_wiol(im, ig, wierdpack, compress, idstring, idlen);
2617 i_readtga_wiol(ig, length)
2625 i_scaleaxis(im,Value,Axis)
2631 i_scale_nn(im,scx,scy)
2637 i_scale_mixing(im, width, height)
2647 i_count_colors(im,maxc)
2652 i_get_anonymous_color_histo(im, maxc = 0x40000000)
2657 unsigned int * col_usage = NULL;
2660 col_cnt = i_get_anonymous_color_histo(im, &col_usage, maxc);
2661 EXTEND(SP, col_cnt);
2662 for (i = 0; i < col_cnt; i++) {
2663 PUSHs(sv_2mortal(newSViv( col_usage[i])));
2670 i_transform(im, opx, opy, parm)
2676 STRLEN size_opx, size_opy, size_parm;
2679 result=i_transform(im,opx,size_opx,opy,size_opy,parm,size_parm);
2681 SV *result_sv = sv_newmortal();
2683 sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result);
2688 i_transform2(sv_width,sv_height,channels,sv_ops,av_n_regs,av_c_regs,av_in_imgs)
2714 in_imgs_count = av_len(av_in_imgs)+1;
2715 for (i = 0; i < in_imgs_count; ++i) {
2716 sv1 = *av_fetch(av_in_imgs, i, 0);
2717 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2718 croak("sv_in_img must contain only images");
2721 if (in_imgs_count > 0) {
2722 in_imgs = mymalloc(in_imgs_count*sizeof(i_img*));
2723 for (i = 0; i < in_imgs_count; ++i) {
2724 sv1 = *av_fetch(av_in_imgs,i,0);
2725 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2726 croak("Parameter 5 must contain only images");
2728 tmp = SvIV((SV*)SvRV(sv1));
2729 in_imgs[i] = INT2PTR(i_img*, tmp);
2733 /* no input images */
2736 /* default the output size from the first input if possible */
2738 width = SvIV(sv_width);
2739 else if (in_imgs_count)
2740 width = in_imgs[0]->xsize;
2742 croak("No output image width supplied");
2744 if (SvOK(sv_height))
2745 height = SvIV(sv_height);
2746 else if (in_imgs_count)
2747 height = in_imgs[0]->ysize;
2749 croak("No output image height supplied");
2751 ops = (struct rm_op *)SvPV(sv_ops, ops_len);
2752 if (ops_len % sizeof(struct rm_op))
2753 croak("Imager: Parameter 3 must be a bitmap of regops\n");
2754 ops_count = ops_len / sizeof(struct rm_op);
2756 n_regs_count = av_len(av_n_regs)+1;
2757 n_regs = mymalloc(n_regs_count * sizeof(double));
2758 for (i = 0; i < n_regs_count; ++i) {
2759 sv1 = *av_fetch(av_n_regs,i,0);
2761 n_regs[i] = SvNV(sv1);
2763 c_regs_count = av_len(av_c_regs)+1;
2764 c_regs = mymalloc(c_regs_count * sizeof(i_color));
2765 /* I don't bother initializing the colou?r registers */
2767 result=i_transform2(width, height, channels, ops, ops_count,
2768 n_regs, n_regs_count,
2769 c_regs, c_regs_count, in_imgs, in_imgs_count);
2775 SV *result_sv = sv_newmortal();
2777 sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result);
2783 i_contrast(im,intensity)
2796 i_noise(im,amount,type)
2802 i_bumpmap(im,bump,channel,light_x,light_y,strength)
2812 i_bumpmap_complex(im,bump,channel,tx,ty,Lx,Ly,Lz,cd,cs,n,Ia,Il,Is)
2831 i_postlevels(im,levels)
2841 i_watermark(im,wmark,tx,ty,pixdiff)
2843 Imager::ImgRaw wmark
2850 i_autolevels(im,lsat,usat,skew)
2857 i_autolevels_mono(im,lsat,usat)
2863 i_radnoise(im,xo,yo,rscale,ascale)
2871 i_turbnoise(im, xo, yo, scale)
2879 i_gradgen(im, xo, yo, ac, dmeasure)
2890 if (size_xo != size_yo || size_xo != size_ac)
2891 croak("i_gradgen: x, y and color arrays must be the same size");
2893 croak("Usage: i_gradgen array refs must have more than 1 entry each");
2894 i_gradgen(im, size_xo, xo, yo, ac, dmeasure);
2897 i_diff_image(im, im2, mindist=0)
2903 i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2913 double ssample_param
2917 i_fountain_seg *segs;
2919 if (!SvROK(ST(10)) || ! SvTYPE(SvRV(ST(10))))
2920 croak("i_fountain: argument 11 must be an array ref");
2922 asegs = (AV *)SvRV(ST(10));
2923 segs = load_fount_segs(aTHX_ asegs, &count);
2924 RETVAL = i_fountain(im, xa, ya, xb, yb, type, repeat, combine,
2925 super_sample, ssample_param, count, segs);
2931 i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2940 double ssample_param
2944 i_fountain_seg *segs;
2946 if (!SvROK(ST(9)) || ! SvTYPE(SvRV(ST(9))))
2947 croak("i_fountain: argument 11 must be an array ref");
2949 asegs = (AV *)SvRV(ST(9));
2950 segs = load_fount_segs(aTHX_ asegs, &count);
2951 RETVAL = i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine,
2952 super_sample, ssample_param, count, segs);
2958 i_new_fill_opacity(other_fill, alpha_mult)
2959 Imager::FillHandle other_fill
2970 errors = i_errors();
2972 while (errors[i].msg) {
2974 sv = newSVpv(errors[i].msg, strlen(errors[i].msg));
2975 if (!av_store(av, 0, sv)) {
2978 sv = newSViv(errors[i].code);
2979 if (!av_store(av, 1, sv)) {
2982 PUSHs(sv_2mortal(newRV_noinc((SV*)av)));
2990 i_push_error(code, msg)
2995 i_nearest_color(im, ...)
3010 croak("Usage: i_nearest_color(im, xo, yo, ival, dmeasure)");
3011 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
3012 croak("i_nearest_color: Second argument must be an array ref");
3013 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
3014 croak("i_nearest_color: Third argument must be an array ref");
3015 if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
3016 croak("i_nearest_color: Fourth argument must be an array ref");
3017 axx = (AV *)SvRV(ST(1));
3018 ayy = (AV *)SvRV(ST(2));
3019 ac = (AV *)SvRV(ST(3));
3020 dmeasure = (int)SvIV(ST(4));
3022 num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
3023 num = num <= av_len(ac) ? num : av_len(ac);
3025 if (num < 2) croak("Usage: i_nearest_color array refs must have more than 1 entry each");
3026 xo = mymalloc( sizeof(i_img_dim) * num );
3027 yo = mymalloc( sizeof(i_img_dim) * num );
3028 ival = mymalloc( sizeof(i_color) * num );
3029 for(i = 0; i<num; i++) {
3030 xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0));
3031 yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0));
3032 sv = *av_fetch(ac, i, 0);
3033 if ( !sv_derived_from(sv, "Imager::Color") ) {
3034 free(axx); free(ayy); free(ac);
3035 croak("i_nearest_color: Element of fourth argument is not derived from Imager::Color");
3037 ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
3039 RETVAL = i_nearest_color(im, num, xo, yo, ival, dmeasure);
3053 rc=DSO_open(filename,&evstr);
3057 PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
3058 PUSHs(sv_2mortal(newSVpvn(evstr, strlen(evstr))));
3061 PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
3067 DSO_close(dso_handle)
3071 DSO_funclist(dso_handle_v)
3075 DSO_handle *dso_handle;
3076 func_ptr *functions;
3078 dso_handle=(DSO_handle*)dso_handle_v;
3079 functions = DSO_funclist(dso_handle);
3081 while( functions[i].name != NULL) {
3083 PUSHs(sv_2mortal(newSVpv(functions[i].name,0)));
3085 PUSHs(sv_2mortal(newSVpv(functions[i++].pcode,0)));
3089 DSO_call(handle,func_index,hv)
3094 DSO_call( (DSO_handle *)handle,func_index,hv);
3097 i_get_pixel(im, x, y)
3102 RETVAL = (i_color *)mymalloc(sizeof(i_color));
3103 if (i_gpix(im, x, y, RETVAL) != 0) {
3112 i_ppix(im, x, y, cl)
3119 i_img_pal_new(x, y, channels, maxpal)
3126 i_img_to_pal(src, quant)
3132 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
3133 croak("i_img_to_pal: second argument must be a hash ref");
3134 hv = (HV *)SvRV(ST(1));
3135 memset(&quant, 0, sizeof(quant));
3137 quant.mc_size = 256;
3138 ip_handle_quant_opts(aTHX_ &quant, hv);
3139 RETVAL = i_img_to_pal(src, &quant);
3141 ip_copy_colors_back(aTHX_ hv, &quant);
3143 ip_cleanup_quant_opts(aTHX_ &quant);
3152 i_img_make_palette(HV *quant_hv, ...)
3154 size_t count = items - 1;
3156 i_img **imgs = NULL;
3160 croak("Please supply at least one image (%d)", (int)count);
3161 imgs = mymalloc(sizeof(i_img *) * count);
3162 for (i = 0; i < count; ++i) {
3163 SV *img_sv = ST(i + 1);
3164 if (SvROK(img_sv) && sv_derived_from(img_sv, "Imager::ImgRaw")) {
3165 imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(img_sv)));
3169 croak("Image %d is not an image object", (int)i+1);
3172 memset(&quant, 0, sizeof(quant));
3174 quant.mc_size = 256;
3175 ip_handle_quant_opts(aTHX_ &quant, quant_hv);
3176 i_quant_makemap(&quant, imgs, count);
3177 EXTEND(SP, quant.mc_count);
3178 for (i = 0; i < quant.mc_count; ++i) {
3179 SV *sv_c = make_i_color_sv(aTHX_ quant.mc_colors + i);
3182 ip_cleanup_quant_opts(aTHX_ &quant);
3196 work = mymalloc((r-l) * sizeof(i_palidx));
3197 count = i_gpal(im, l, r, y, work);
3198 if (GIMME_V == G_ARRAY) {
3200 for (i = 0; i < count; ++i) {
3201 PUSHs(sv_2mortal(newSViv(work[i])));
3206 PUSHs(sv_2mortal(newSVpv((char *)work, count * sizeof(i_palidx))));
3211 if (GIMME_V != G_ARRAY) {
3213 PUSHs(&PL_sv_undef);
3218 i_ppal(im, l, y, ...)
3227 work = malloc_temp(aTHX_ sizeof(i_palidx) * (items-3));
3228 for (i=0; i < items-3; ++i) {
3229 work[i] = SvIV(ST(i+3));
3231 validate_i_ppal(im, work, items - 3);
3232 RETVAL = i_ppal(im, l, l+items-3, y, work);
3241 i_ppal_p(im, l, y, data)
3247 i_palidx const *work;
3250 work = (i_palidx const *)SvPV(data, len);
3251 len /= sizeof(i_palidx);
3253 validate_i_ppal(im, work, len);
3254 RETVAL = i_ppal(im, l, l+len, y, work);
3263 i_addcolors(im, ...)
3270 croak("i_addcolors: no colors to add");
3271 colors = mymalloc((items-1) * sizeof(i_color));
3272 for (i=0; i < items-1; ++i) {
3273 if (sv_isobject(ST(i+1))
3274 && sv_derived_from(ST(i+1), "Imager::Color")) {
3275 IV tmp = SvIV((SV *)SvRV(ST(i+1)));
3276 colors[i] = *INT2PTR(i_color *, tmp);
3280 croak("i_addcolor: pixels must be Imager::Color objects");
3283 RETVAL = i_addcolors(im, colors, items-1);
3288 i_setcolors(im, index, ...)
3296 croak("i_setcolors: no colors to add");
3297 colors = mymalloc((items-2) * sizeof(i_color));
3298 for (i=0; i < items-2; ++i) {
3299 if (sv_isobject(ST(i+2))
3300 && sv_derived_from(ST(i+2), "Imager::Color")) {
3301 IV tmp = SvIV((SV *)SvRV(ST(i+2)));
3302 colors[i] = *INT2PTR(i_color *, tmp);
3306 croak("i_setcolors: pixels must be Imager::Color objects");
3309 RETVAL = i_setcolors(im, index, colors, items-2);
3315 i_getcolors(im, index, count=1)
3324 croak("i_getcolors: count must be positive");
3325 colors = malloc_temp(aTHX_ sizeof(i_color) * count);
3326 if (i_getcolors(im, index, colors, count)) {
3328 for (i = 0; i < count; ++i) {
3329 SV *sv = make_i_color_sv(aTHX_ colors+i);
3343 i_findcolor(im, color)
3347 if (!i_findcolor(im, color, &RETVAL)) {
3366 i_gsamp(im, l, r, y, channels)
3371 i_channel_list channels
3377 data = mymalloc(sizeof(i_sample_t) * (r-l) * channels.count);
3378 count = i_gsamp(im, l, r, y, data, channels.channels, channels.count);
3379 if (GIMME_V == G_ARRAY) {
3381 for (i = 0; i < count; ++i)
3382 PUSHs(sv_2mortal(newSViv(data[i])));
3386 PUSHs(sv_2mortal(newSVpv((char *)data, count * sizeof(i_sample_t))));
3391 if (GIMME_V != G_ARRAY) {
3397 i_gsamp_bits(im, l, r, y, bits, target, offset, channels)
3405 i_channel_list channels
3412 croak("No channel numbers supplied to g_samp()");
3414 data = mymalloc(sizeof(unsigned) * (r-l) * channels.count);
3415 count = i_gsamp_bits(im, l, r, y, data, channels.channels, channels.count, bits);
3416 for (i = 0; i < count; ++i) {
3417 av_store(target, i+offset, newSVuv(data[i]));
3429 i_psamp_bits(im, l, y, bits, channels, data_av, data_offset = 0, pixel_count = -1)
3434 i_channel_list channels
3436 i_img_dim data_offset
3437 i_img_dim pixel_count
3446 data_count = av_len(data_av) + 1;
3447 if (data_offset < 0) {
3448 croak("data_offset must be non-negative");
3450 if (data_offset > data_count) {
3451 croak("data_offset greater than number of samples supplied");
3453 if (pixel_count == -1 ||
3454 data_offset + pixel_count * channels.count > data_count) {
3455 pixel_count = (data_count - data_offset) / channels.count;
3458 data_used = pixel_count * channels.count;
3459 data = mymalloc(sizeof(unsigned) * data_count);
3460 for (i = 0; i < data_used; ++i)
3461 data[i] = SvUV(*av_fetch(data_av, data_offset + i, 0));
3463 RETVAL = i_psamp_bits(im, l, l + pixel_count, y, data, channels.channels,
3464 channels.count, bits);
3472 i_psamp(im, x, y, channels, data, offset = 0, width = -1)
3476 i_channel_list channels
3485 i_push_error(0, "offset must be non-negative");
3489 if (offset > data.count) {
3490 i_push_error(0, "offset greater than number of samples supplied");
3493 data.samples += offset;
3494 data.count -= offset;
3497 width * channels.count > data.count) {
3498 width = data.count / channels.count;
3501 RETVAL = i_psamp(im, x, r, y, data.samples, channels.channels, channels.count);
3506 i_psampf(im, x, y, channels, data, offset = 0, width = -1)
3510 i_channel_list channels
3519 i_push_error(0, "offset must be non-negative");
3523 if (offset > data.count) {
3524 i_push_error(0, "offset greater than number of samples supplied");
3527 data.samples += offset;
3528 data.count -= offset;
3531 width * channels.count > data.count) {
3532 width = data.count / channels.count;
3535 RETVAL = i_psampf(im, x, r, y, data.samples, channels.channels, channels.count);
3540 i_img_masked_new(targ, mask, x, y, w, h)
3550 if (!sv_isobject(ST(1))
3551 || !sv_derived_from(ST(1), "Imager::ImgRaw")) {
3552 croak("i_img_masked_new: parameter 2 must undef or an image");
3554 mask = INT2PTR(i_img *, SvIV((SV *)SvRV(ST(1))));
3558 RETVAL = i_img_masked_new(targ, mask, x, y, w, h);
3563 i_plin(im, l, y, ...)
3574 if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
3575 /* supplied as a byte string */
3576 work = (i_color *)SvPV(ST(3), len);
3577 count = len / sizeof(i_color);
3578 if (count * sizeof(i_color) != len) {
3579 croak("i_plin: length of scalar argument must be multiple of sizeof i_color");
3581 RETVAL = i_plin(im, l, l+count, y, work);
3584 work = mymalloc(sizeof(i_color) * (items-3));
3585 for (i=0; i < items-3; ++i) {
3586 if (sv_isobject(ST(i+3))
3587 && sv_derived_from(ST(i+3), "Imager::Color")) {
3588 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3589 work[i] = *INT2PTR(i_color *, tmp);
3593 croak("i_plin: pixels must be Imager::Color objects");
3596 RETVAL = i_plin(im, l, l+items-3, y, work);
3607 i_ppixf(im, x, y, cl)
3611 Imager::Color::Float cl
3614 i_gsampf(im, l, r, y, channels)
3619 i_channel_list channels
3625 data = mymalloc(sizeof(i_fsample_t) * (r-l) * channels.count);
3626 count = i_gsampf(im, l, r, y, data, channels.channels, channels.count);
3627 if (GIMME_V == G_ARRAY) {
3629 for (i = 0; i < count; ++i)
3630 PUSHs(sv_2mortal(newSVnv(data[i])));
3634 PUSHs(sv_2mortal(newSVpv((void *)data, count * sizeof(i_fsample_t))));
3639 if (GIMME_V != G_ARRAY) {
3645 i_plinf(im, l, y, ...)
3656 if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
3657 /* supplied as a byte string */
3658 work = (i_fcolor *)SvPV(ST(3), len);
3659 count = len / sizeof(i_fcolor);
3660 if (count * sizeof(i_fcolor) != len) {
3661 croak("i_plin: length of scalar argument must be multiple of sizeof i_fcolor");
3663 RETVAL = i_plinf(im, l, l+count, y, work);
3666 work = mymalloc(sizeof(i_fcolor) * (items-3));
3667 for (i=0; i < items-3; ++i) {
3668 if (sv_isobject(ST(i+3))
3669 && sv_derived_from(ST(i+3), "Imager::Color::Float")) {
3670 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3671 work[i] = *INT2PTR(i_fcolor *, tmp);
3675 croak("i_plinf: pixels must be Imager::Color::Float objects");
3679 RETVAL = i_plinf(im, l, l+items-3, y, work);
3689 Imager::Color::Float
3695 RETVAL = (i_fcolor *)mymalloc(sizeof(i_fcolor));
3696 if (i_gpixf(im, x, y, RETVAL) != 0) {
3714 vals = mymalloc((r-l) * sizeof(i_color));
3715 memset(vals, 0, (r-l) * sizeof(i_color));
3716 count = i_glin(im, l, r, y, vals);
3717 if (GIMME_V == G_ARRAY) {
3719 for (i = 0; i < count; ++i) {
3720 SV *sv = make_i_color_sv(aTHX_ vals+i);
3726 PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_color))));
3732 i_glinf(im, l, r, y)
3742 for (i = 0; i < MAXCHANNELS; ++i)
3743 zero.channel[i] = 0;
3745 vals = mymalloc((r-l) * sizeof(i_fcolor));
3746 for (i = 0; i < r-l; ++i)
3748 count = i_glinf(im, l, r, y, vals);
3749 if (GIMME_V == G_ARRAY) {
3751 for (i = 0; i < count; ++i) {
3753 i_fcolor *col = mymalloc(sizeof(i_fcolor));
3755 sv = sv_newmortal();
3756 sv_setref_pv(sv, "Imager::Color::Float", (void *)col);
3762 PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_fcolor))));
3768 i_img_8_new(x, y, ch)
3774 i_img_16_new(x, y, ch)
3784 i_img_double_new(x, y, ch)
3794 i_tags_addn(im, name_sv, code, idata)
3803 SvGETMAGIC(name_sv);
3805 name = SvPV_nomg(name_sv, len);
3808 RETVAL = i_tags_addn(&im->tags, name, code, idata);
3813 i_tags_add(im, name_sv, code, data_sv, idata)
3824 SvGETMAGIC(name_sv);
3826 name = SvPV_nomg(name_sv, len);
3829 SvGETMAGIC(data_sv);
3831 data = SvPV(data_sv, len);
3836 RETVAL = i_tags_add(&im->tags, name, code, data, len, idata);
3841 i_tags_find(im, name, start)
3848 if (i_tags_find(&im->tags, name, start, &entry)) {
3857 i_tags_findn(im, code, start)
3864 if (i_tags_findn(&im->tags, code, start, &entry)) {
3874 i_tags_delete(im, entry)
3878 RETVAL = i_tags_delete(&im->tags, entry);
3883 i_tags_delbyname(im, name)
3887 RETVAL = i_tags_delbyname(&im->tags, name);
3892 i_tags_delbycode(im, code)
3896 RETVAL = i_tags_delbycode(&im->tags, code);
3901 i_tags_get(im, index)
3905 if (index >= 0 && index < im->tags.count) {
3906 i_img_tag *entry = im->tags.tags + index;
3910 PUSHs(sv_2mortal(newSVpv(entry->name, 0)));
3913 PUSHs(sv_2mortal(newSViv(entry->code)));
3916 PUSHs(sv_2mortal(newSVpvn(entry->data, entry->size)));
3919 PUSHs(sv_2mortal(newSViv(entry->idata)));
3924 i_tags_get_string(im, what_sv)
3928 char const *name = NULL;
3932 if (SvIOK(what_sv)) {
3933 code = SvIV(what_sv);
3937 name = SvPV_nolen(what_sv);
3940 if (i_tags_get_string(&im->tags, name, code, buffer, sizeof(buffer))) {
3942 PUSHs(sv_2mortal(newSVpv(buffer, 0)));
3949 RETVAL = im->tags.count;
3955 MODULE = Imager PACKAGE = Imager::FillHandle PREFIX=IFILL_
3959 Imager::FillHandle fill
3962 IFILL_CLONE_SKIP(...)
3964 (void)items; /* avoid unused warning for XS variable */
3969 MODULE = Imager PACKAGE = Imager
3972 i_new_fill_solid(cl, combine)
3977 i_new_fill_solidf(cl, combine)
3978 Imager::Color::Float cl
3982 i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch_sv, dx, dy)
3991 unsigned char *cust_hatch;
3994 SvGETMAGIC(cust_hatch_sv);
3995 if (SvOK(cust_hatch_sv)) {
3996 cust_hatch = (unsigned char *)SvPV_nomg(cust_hatch_sv, len);
4000 RETVAL = i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy);
4005 i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch_sv, dx, dy)
4006 Imager::Color::Float fg
4007 Imager::Color::Float bg
4014 unsigned char *cust_hatch;
4017 SvGETMAGIC(cust_hatch_sv);
4018 if (SvOK(cust_hatch_sv)) {
4019 cust_hatch = (unsigned char *)SvPV(cust_hatch_sv, len);
4023 RETVAL = i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy);
4028 i_new_fill_image(src, matrix_sv, xoff, yoff, combine)
4042 SvGETMAGIC(matrix_sv);
4043 if (!SvOK(matrix_sv)) {
4047 if (!SvROK(matrix_sv) || SvTYPE(SvRV(matrix_sv)) != SVt_PVAV)
4048 croak("i_new_fill_image: matrix parameter must be an arrayref or undef");
4049 av=(AV*)SvRV(matrix_sv);
4053 for (i = 0; i < len; ++i) {
4054 sv1=(*(av_fetch(av,i,0)));
4055 matrix[i] = SvNV(sv1);
4061 RETVAL = i_new_fill_image(src, matrixp, xoff, yoff, combine);
4065 MODULE = Imager PACKAGE = Imager::Internal::Hlines PREFIX=i_int_hlines_
4067 # this class is only exposed for testing
4070 i_int_hlines_testing()
4072 #if i_int_hlines_testing()
4074 Imager::Internal::Hlines
4075 i_int_hlines_new(start_y, count_y, start_x, count_x)
4081 Imager::Internal::Hlines
4082 i_int_hlines_new_img(im)
4086 i_int_hlines_add(hlines, y, minx, width)
4087 Imager::Internal::Hlines hlines
4093 i_int_hlines_DESTROY(hlines)
4094 Imager::Internal::Hlines hlines
4097 i_int_hlines_dump(hlines)
4098 Imager::Internal::Hlines hlines
4101 i_int_hlines_CLONE_SKIP(cls)
4105 MODULE = Imager PACKAGE = Imager::Context PREFIX=im_context_
4108 im_context_DESTROY(ctx)
4111 #ifdef PERL_IMPLICIT_CONTEXT
4114 im_context_CLONE(...)
4118 /* the following sv_setref_pv() will free this inc */
4119 im_context_refinc(MY_CXT.ctx, "CLONE");
4120 MY_CXT.ctx = im_context_clone(MY_CXT.ctx, "CLONE");
4121 sv_setref_pv(get_sv("Imager::_context", GV_ADD), "Imager::Context", MY_CXT.ctx);
4126 PERL_SET_GLOBAL_CALLBACKS;
4127 PERL_PL_SET_GLOBAL_CALLBACKS;
4128 #ifdef PERL_IMPLICIT_CONTEXT
4134 start_context(aTHX);
4135 im_get_context = perl_get_context;