1 #define PERL_NO_GET_CONTEXT
8 #define NEED_newRV_noinc
9 #define NEED_sv_2pv_nolen
10 #define NEED_sv_2pvbyte
16 #define i_int_hlines_testing() 1
23 #include "imextpltypes.h"
26 #if i_int_hlines_testing()
32 /* used to represent channel lists parameters */
33 typedef struct i_channel_list_tag {
40 const i_sample_t *samples;
45 const i_fsample_t *samples;
50 Allocate memory that will be discarded when mortals are discarded.
55 malloc_temp(pTHX_ size_t size) {
56 SV *sv = sv_2mortal(newSV(size));
61 /* These functions are all shared - then comes platform dependant code */
62 static int getstr(void *hv_t,char *key,char **store) {
67 mm_log((1,"getstr(hv_t %p, key %s, store %p)\n",hv_t,key,store));
69 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
71 svpp=hv_fetch(hv, key, strlen(key), 0);
72 *store=SvPV(*svpp, PL_na );
77 static int getint(void *hv_t,char *key,int *store) {
82 mm_log((1,"getint(hv_t %p, key %s, store %p)\n",hv_t,key,store));
84 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
86 svpp=hv_fetch(hv, key, strlen(key), 0);
87 *store=(int)SvIV(*svpp);
91 static int getdouble(void *hv_t,char* key,double *store) {
96 mm_log((1,"getdouble(hv_t %p, key %s, store %p)\n",hv_t,key,store));
98 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
99 svpp=hv_fetch(hv, key, strlen(key), 0);
100 *store=(double)SvNV(*svpp);
104 static int getvoid(void *hv_t,char* key,void **store) {
109 mm_log((1,"getvoid(hv_t %p, key %s, store %p)\n",hv_t,key,store));
111 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
113 svpp=hv_fetch(hv, key, strlen(key), 0);
114 *store = INT2PTR(void*, SvIV(*svpp));
119 static int getobj(void *hv_t,char *key,char *type,void **store) {
124 mm_log((1,"getobj(hv_t %p, key %s,type %s, store %p)\n",hv_t,key,type,store));
126 if ( !hv_exists(hv,key,strlen(key)) ) return 0;
128 svpp=hv_fetch(hv, key, strlen(key), 0);
130 if (sv_derived_from(*svpp,type)) {
131 IV tmp = SvIV((SV*)SvRV(*svpp));
132 *store = INT2PTR(void*, tmp);
134 mm_log((1,"getobj: key exists in hash but is not of correct type"));
141 UTIL_table_t i_UTIL_table={getstr,getint,getdouble,getvoid,getobj};
143 void my_SvREFCNT_dec(void *p) {
145 SvREFCNT_dec((SV*)p);
150 i_log_entry(char *string, int level) {
151 mm_log((level, "%s", string));
155 make_i_color_sv(pTHX_ const i_color *c) {
157 i_color *col = mymalloc(sizeof(i_color));
160 sv_setref_pv(sv, "Imager::Color", (void *)col);
165 #define CBDATA_BUFSIZE 8192
168 /* the SVs we use to call back to Perl */
176 call_reader(struct cbdata *cbd, void *buf, size_t size,
184 if (!SvOK(cbd->readcb))
191 PUSHs(sv_2mortal(newSViv(size)));
192 PUSHs(sv_2mortal(newSViv(maxread)));
195 count = perl_call_sv(cbd->readcb, G_SCALAR);
200 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
206 char *ptr = SvPVbyte(data, len);
208 croak("Too much data returned in reader callback (wanted %d, got %d, expected %d)",
209 (int)size, (int)len, (int)maxread);
211 memcpy(buf, ptr, len);
226 io_seeker(void *p, off_t offset, int whence) {
228 struct cbdata *cbd = p;
233 if (!SvOK(cbd->seekcb))
240 PUSHs(sv_2mortal(newSViv(offset)));
241 PUSHs(sv_2mortal(newSViv(whence)));
244 count = perl_call_sv(cbd->seekcb, G_SCALAR);
249 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
261 io_writer(void *p, void const *data, size_t size) {
263 struct cbdata *cbd = p;
269 if (!SvOK(cbd->writecb))
276 PUSHs(sv_2mortal(newSVpv((char *)data, size)));
279 count = perl_call_sv(cbd->writecb, G_SCALAR);
283 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
286 success = SvTRUE(sv);
293 return success ? size : -1;
297 io_reader(void *p, void *data, size_t size) {
298 struct cbdata *cbd = p;
300 return call_reader(cbd, data, size, size);
303 static int io_closer(void *p) {
305 struct cbdata *cbd = p;
308 if (SvOK(cbd->closecb)) {
318 count = perl_call_sv(cbd->closecb, G_SCALAR);
323 success = SvTRUE(sv);
330 return success ? 0 : -1;
333 static void io_destroyer(void *p) {
335 struct cbdata *cbd = p;
337 SvREFCNT_dec(cbd->writecb);
338 SvREFCNT_dec(cbd->readcb);
339 SvREFCNT_dec(cbd->seekcb);
340 SvREFCNT_dec(cbd->closecb);
345 do_io_new_buffer(pTHX_ SV *data_sv) {
349 data = SvPVbyte(data_sv, length);
350 SvREFCNT_inc(data_sv);
351 return io_new_buffer(data, length, my_SvREFCNT_dec, data_sv);
355 do_io_new_cb(pTHX_ SV *writecb, SV *readcb, SV *seekcb, SV *closecb) {
358 cbd = mymalloc(sizeof(struct cbdata));
359 cbd->writecb = newSVsv(writecb);
360 cbd->readcb = newSVsv(readcb);
361 cbd->seekcb = newSVsv(seekcb);
362 cbd->closecb = newSVsv(closecb);
364 return io_new_cb(cbd, io_reader, io_writer, io_seeker, io_closer,
372 static int lookup_name(struct value_name *names, int count, char *name, int def_value)
375 for (i = 0; i < count; ++i)
376 if (strEQ(names[i].name, name))
377 return names[i].value;
381 static struct value_name transp_names[] =
384 { "threshold", tr_threshold },
385 { "errdiff", tr_errdiff },
386 { "ordered", tr_ordered, },
389 static struct value_name make_color_names[] =
391 { "none", mc_none, },
392 { "webmap", mc_web_map, },
393 { "addi", mc_addi, },
394 { "mediancut", mc_median_cut, },
395 { "mono", mc_mono, },
396 { "monochrome", mc_mono, },
397 { "gray", mc_gray, },
398 { "gray4", mc_gray4, },
399 { "gray16", mc_gray16, },
402 static struct value_name translate_names[] =
404 { "giflib", pt_giflib, },
405 { "closest", pt_closest, },
406 { "perturb", pt_perturb, },
407 { "errdiff", pt_errdiff, },
410 static struct value_name errdiff_names[] =
412 { "floyd", ed_floyd, },
413 { "jarvis", ed_jarvis, },
414 { "stucki", ed_stucki, },
415 { "custom", ed_custom, },
418 static struct value_name orddith_names[] =
420 { "random", od_random, },
421 { "dot8", od_dot8, },
422 { "dot4", od_dot4, },
423 { "hline", od_hline, },
424 { "vline", od_vline, },
425 { "/line", od_slashline, },
426 { "slashline", od_slashline, },
427 { "\\line", od_backline, },
428 { "backline", od_backline, },
429 { "tiny", od_tiny, },
430 { "custom", od_custom, },
433 /* look through the hash for quantization options */
435 ip_handle_quant_opts(pTHX_ i_quantize *quant, HV *hv)
437 /*** POSSIBLY BROKEN: do I need to unref the SV from hv_fetch ***/
443 quant->mc_colors = mymalloc(quant->mc_size * sizeof(i_color));
445 sv = hv_fetch(hv, "transp", 6, 0);
446 if (sv && *sv && (str = SvPV(*sv, len))) {
448 lookup_name(transp_names, sizeof(transp_names)/sizeof(*transp_names),
450 if (quant->transp != tr_none) {
451 quant->tr_threshold = 127;
452 sv = hv_fetch(hv, "tr_threshold", 12, 0);
454 quant->tr_threshold = SvIV(*sv);
456 if (quant->transp == tr_errdiff) {
457 sv = hv_fetch(hv, "tr_errdiff", 10, 0);
458 if (sv && *sv && (str = SvPV(*sv, len)))
459 quant->tr_errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
461 if (quant->transp == tr_ordered) {
462 quant->tr_orddith = od_tiny;
463 sv = hv_fetch(hv, "tr_orddith", 10, 0);
464 if (sv && *sv && (str = SvPV(*sv, len)))
465 quant->tr_orddith = lookup_name(orddith_names, sizeof(orddith_names)/sizeof(*orddith_names), str, od_random);
467 if (quant->tr_orddith == od_custom) {
468 sv = hv_fetch(hv, "tr_map", 6, 0);
469 if (sv && *sv && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
470 AV *av = (AV*)SvRV(*sv);
471 len = av_len(av) + 1;
472 if (len > sizeof(quant->tr_custom))
473 len = sizeof(quant->tr_custom);
474 for (i = 0; i < len; ++i) {
475 SV **sv2 = av_fetch(av, i, 0);
477 quant->tr_custom[i] = SvIV(*sv2);
480 while (i < sizeof(quant->tr_custom))
481 quant->tr_custom[i++] = 0;
486 quant->make_colors = mc_median_cut;
487 sv = hv_fetch(hv, "make_colors", 11, 0);
488 if (sv && *sv && (str = SvPV(*sv, len))) {
490 lookup_name(make_color_names, sizeof(make_color_names)/sizeof(*make_color_names), str, mc_median_cut);
492 sv = hv_fetch(hv, "colors", 6, 0);
493 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
494 /* needs to be an array of Imager::Color
495 note that the caller allocates the mc_color array and sets mc_size
497 AV *av = (AV *)SvRV(*sv);
498 quant->mc_count = av_len(av)+1;
499 if (quant->mc_count > quant->mc_size)
500 quant->mc_count = quant->mc_size;
501 for (i = 0; i < quant->mc_count; ++i) {
502 SV **sv1 = av_fetch(av, i, 0);
503 if (sv1 && *sv1 && SvROK(*sv1) && sv_derived_from(*sv1, "Imager::Color")) {
504 i_color *col = INT2PTR(i_color *, SvIV((SV*)SvRV(*sv1)));
505 quant->mc_colors[i] = *col;
509 sv = hv_fetch(hv, "max_colors", 10, 0);
512 if (i <= quant->mc_size && i >= quant->mc_count)
516 quant->translate = pt_closest;
517 sv = hv_fetch(hv, "translate", 9, 0);
518 if (sv && *sv && (str = SvPV(*sv, len))) {
519 quant->translate = lookup_name(translate_names, sizeof(translate_names)/sizeof(*translate_names), str, pt_closest);
521 sv = hv_fetch(hv, "errdiff", 7, 0);
522 if (sv && *sv && (str = SvPV(*sv, len))) {
523 quant->errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
525 if (quant->translate == pt_errdiff && quant->errdiff == ed_custom) {
526 /* get the error diffusion map */
527 sv = hv_fetch(hv, "errdiff_width", 13, 0);
529 quant->ed_width = SvIV(*sv);
530 sv = hv_fetch(hv, "errdiff_height", 14, 0);
532 quant->ed_height = SvIV(*sv);
533 sv = hv_fetch(hv, "errdiff_orig", 12, 0);
535 quant->ed_orig = SvIV(*sv);
536 if (quant->ed_width > 0 && quant->ed_height > 0) {
538 quant->ed_map = mymalloc(sizeof(int)*quant->ed_width*quant->ed_height);
539 sv = hv_fetch(hv, "errdiff_map", 11, 0);
540 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
541 AV *av = (AV*)SvRV(*sv);
542 len = av_len(av) + 1;
543 if (len > quant->ed_width * quant->ed_height)
544 len = quant->ed_width * quant->ed_height;
545 for (i = 0; i < len; ++i) {
546 SV **sv2 = av_fetch(av, i, 0);
548 quant->ed_map[i] = SvIV(*sv2);
549 sum += quant->ed_map[i];
555 myfree(quant->ed_map);
557 quant->errdiff = ed_floyd;
561 sv = hv_fetch(hv, "perturb", 7, 0);
563 quant->perturb = SvIV(*sv);
567 ip_cleanup_quant_opts(pTHX_ i_quantize *quant) {
568 myfree(quant->mc_colors);
570 myfree(quant->ed_map);
573 /* copies the color map from the hv into the colors member of the HV */
575 ip_copy_colors_back(pTHX_ HV *hv, i_quantize *quant) {
581 sv = hv_fetch(hv, "colors", 6, 0);
582 if (!sv || !*sv || !SvROK(*sv) || SvTYPE(SvRV(*sv)) != SVt_PVAV) {
587 av = (AV *)SvRV(*sv);
589 av_extend(av, quant->mc_count+1);
590 for (i = 0; i < quant->mc_count; ++i) {
591 i_color *in = quant->mc_colors+i;
592 Imager__Color c = ICL_new_internal(in->rgb.r, in->rgb.g, in->rgb.b, 255);
593 work = sv_newmortal();
594 sv_setref_pv(work, "Imager::Color", (void *)c);
600 /* loads the segments of a fountain fill into an array */
601 static i_fountain_seg *
602 load_fount_segs(pTHX_ AV *asegs, int *count) {
603 /* Each element of segs must contain:
604 [ start, middle, end, c0, c1, segtype, colortrans ]
605 start, middle, end are doubles from 0 to 1
606 c0, c1 are Imager::Color::Float or Imager::Color objects
607 segtype, colortrans are ints
611 i_fountain_seg *segs;
615 *count = av_len(asegs)+1;
617 croak("i_fountain must have at least one segment");
618 segs = mymalloc(sizeof(i_fountain_seg) * *count);
619 for(i = 0; i < *count; i++) {
620 SV **sv1 = av_fetch(asegs, i, 0);
621 if (!sv1 || !*sv1 || !SvROK(*sv1)
622 || SvTYPE(SvRV(*sv1)) != SVt_PVAV) {
624 croak("i_fountain: segs must be an arrayref of arrayrefs");
626 aseg = (AV *)SvRV(*sv1);
627 if (av_len(aseg) != 7-1) {
629 croak("i_fountain: a segment must have 7 members");
631 for (j = 0; j < 3; ++j) {
632 SV **sv2 = av_fetch(aseg, j, 0);
635 croak("i_fountain: XS error");
637 work[j] = SvNV(*sv2);
639 segs[i].start = work[0];
640 segs[i].middle = work[1];
641 segs[i].end = work[2];
642 for (j = 0; j < 2; ++j) {
643 SV **sv3 = av_fetch(aseg, 3+j, 0);
644 if (!sv3 || !*sv3 || !SvROK(*sv3) ||
645 (!sv_derived_from(*sv3, "Imager::Color")
646 && !sv_derived_from(*sv3, "Imager::Color::Float"))) {
648 croak("i_fountain: segs must contain colors in elements 3 and 4");
650 if (sv_derived_from(*sv3, "Imager::Color::Float")) {
651 segs[i].c[j] = *INT2PTR(i_fcolor *, SvIV((SV *)SvRV(*sv3)));
654 i_color c = *INT2PTR(i_color *, SvIV((SV *)SvRV(*sv3)));
656 for (ch = 0; ch < MAXCHANNELS; ++ch) {
657 segs[i].c[j].channel[ch] = c.channel[ch] / 255.0;
661 for (j = 0; j < 2; ++j) {
662 SV **sv2 = av_fetch(aseg, j+5, 0);
665 croak("i_fountain: XS error");
667 worki[j] = SvIV(*sv2);
669 segs[i].type = worki[0];
670 segs[i].color = worki[1];
676 /* validates the indexes supplied to i_ppal
678 i_ppal() doesn't do that for speed, but I'm not comfortable doing that
683 validate_i_ppal(i_img *im, i_palidx const *indexes, int count) {
684 int color_count = i_colorcount(im);
687 if (color_count == -1)
688 croak("i_plin() called on direct color image");
690 for (i = 0; i < count; ++i) {
691 if (indexes[i] >= color_count) {
692 croak("i_plin() called with out of range color index %d (max %d)",
693 indexes[i], color_count-1);
699 /* I don't think ICLF_* names belong at the C interface
700 this makes the XS code think we have them, to let us avoid
701 putting function bodies in the XS code
703 #define ICLF_new_internal(r, g, b, a) i_fcolor_new((r), (g), (b), (a))
704 #define ICLF_DESTROY(cl) i_fcolor_destroy(cl)
707 #define i_log_enabled() 1
709 #define i_log_enabled() 0
712 #if i_int_hlines_testing()
714 typedef i_int_hlines *Imager__Internal__Hlines;
716 static i_int_hlines *
717 i_int_hlines_new(i_img_dim start_y, i_img_dim count_y, i_img_dim start_x, i_img_dim count_x) {
718 i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
719 i_int_init_hlines(result, start_y, count_y, start_x, count_x);
724 static i_int_hlines *
725 i_int_hlines_new_img(i_img *im) {
726 i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
727 i_int_init_hlines_img(result, im);
733 i_int_hlines_DESTROY(i_int_hlines *hlines) {
734 i_int_hlines_destroy(hlines);
738 #define i_int_hlines_CLONE_SKIP(cls) 1
740 static int seg_compare(const void *vleft, const void *vright) {
741 const i_int_hline_seg *left = vleft;
742 const i_int_hline_seg *right = vright;
744 return left->minx - right->minx;
748 i_int_hlines_dump(i_int_hlines *hlines) {
750 SV *dump = newSVpvf("start_y: %" i_DF " limit_y: %" i_DF " start_x: %" i_DF " limit_x: %" i_DF"\n",
751 i_DFc(hlines->start_y), i_DFc(hlines->limit_y), i_DFc(hlines->start_x), i_DFc(hlines->limit_x));
754 for (y = hlines->start_y; y < hlines->limit_y; ++y) {
755 i_int_hline_entry *entry = hlines->entries[y-hlines->start_y];
758 /* sort the segments, if any */
760 qsort(entry->segs, entry->count, sizeof(i_int_hline_seg), seg_compare);
762 sv_catpvf(dump, " %" i_DF " (%" i_DF "):", i_DFc(y), i_DFc(entry->count));
763 for (i = 0; i < entry->count; ++i) {
764 sv_catpvf(dump, " [%" i_DF ", %" i_DF ")", i_DFc(entry->segs[i].minx),
765 i_DFc(entry->segs[i].x_limit));
767 sv_catpv(dump, "\n");
777 i_sv_off_t(pTHX_ SV *sv) {
778 #if LSEEKSIZE > IVSIZE
779 return (off_t)SvNV(sv);
781 return (off_t)SvIV(sv);
786 i_new_sv_off_t(pTHX_ off_t off) {
787 #if LSEEKSIZE > IVSIZE
794 static im_pl_ext_funcs im_perl_funcs =
796 IMAGER_PL_API_VERSION,
798 ip_handle_quant_opts,
799 ip_cleanup_quant_opts,
803 #define PERL_PL_SET_GLOBAL_CALLBACKS \
804 sv_setiv(get_sv(PERL_PL_FUNCTION_TABLE_NAME, 1), PTR2IV(&im_perl_funcs));
807 #define i_exif_enabled() 1
809 #define i_exif_enabled() 0
812 /* trying to use more C style names, map them here */
813 #define i_io_DESTROY(ig) io_glue_destroy(ig)
815 #define i_img_get_width(im) ((im)->xsize)
816 #define i_img_get_height(im) ((im)->ysize)
818 #define i_img_epsilonf() (DBL_EPSILON * 4)
820 /* avoid some xsubpp strangeness */
823 MODULE = Imager PACKAGE = Imager::Color PREFIX = ICL_
826 ICL_new_internal(r,g,b,a)
838 ICL_set_internal(cl,r,g,b,a)
845 ICL_set_internal(cl, r, g, b, a);
859 PUSHs(sv_2mortal(newSVnv(cl->rgba.r)));
860 PUSHs(sv_2mortal(newSVnv(cl->rgba.g)));
861 PUSHs(sv_2mortal(newSVnv(cl->rgba.b)));
862 PUSHs(sv_2mortal(newSVnv(cl->rgba.a)));
868 RETVAL = mymalloc(sizeof(i_color));
870 i_hsv_to_rgb(RETVAL);
878 RETVAL = mymalloc(sizeof(i_color));
880 i_rgb_to_hsv(RETVAL);
886 MODULE = Imager PACKAGE = Imager::Color::Float PREFIX=ICLF_
889 ICLF_new_internal(r, g, b, a)
897 Imager::Color::Float cl
901 Imager::Color::Float cl
905 EXTEND(SP, MAXCHANNELS);
906 for (ch = 0; ch < MAXCHANNELS; ++ch) {
907 /* printf("%d: %g\n", ch, cl->channel[ch]); */
908 PUSHs(sv_2mortal(newSVnv(cl->channel[ch])));
912 ICLF_set_internal(cl,r,g,b,a)
913 Imager::Color::Float cl
928 Imager::Color::Float c
930 RETVAL = mymalloc(sizeof(i_fcolor));
932 i_hsv_to_rgbf(RETVAL);
938 Imager::Color::Float c
940 RETVAL = mymalloc(sizeof(i_fcolor));
942 i_rgb_to_hsvf(RETVAL);
946 MODULE = Imager PACKAGE = Imager::ImgRaw PREFIX = IIM_
960 MODULE = Imager PACKAGE = Imager
974 io_new_buffer(data_sv)
977 RETVAL = do_io_new_buffer(aTHX_ data_sv);
982 io_new_cb(writecb, readcb, seekcb, closecb, maxwrite = CBDATA_BUFSIZE)
989 RETVAL = do_io_new_cb(aTHX_ writecb, readcb, seekcb, closecb);
1001 tlength = io_slurp(ig, &data);
1002 RETVAL = newSVpv((char *)data,tlength);
1009 i_set_image_file_limits(width, height, bytes)
1015 i_get_image_file_limits()
1017 i_img_dim width, height;
1020 if (i_get_image_file_limits(&width, &height, &bytes)) {
1022 PUSHs(sv_2mortal(newSViv(width)));
1023 PUSHs(sv_2mortal(newSViv(height)));
1024 PUSHs(sv_2mortal(newSVuv(bytes)));
1027 MODULE = Imager PACKAGE = Imager::IO PREFIX = io_
1030 io_new_fd(class, fd)
1033 RETVAL = io_new_fd(fd);
1038 io_new_buffer(class, data_sv)
1041 RETVAL = do_io_new_buffer(aTHX_ data_sv);
1046 io_new_cb(class, writecb, readcb, seekcb, closecb)
1052 RETVAL = do_io_new_cb(aTHX_ writecb, readcb, seekcb, closecb);
1057 io_new_bufchain(class)
1059 RETVAL = io_new_bufchain();
1067 unsigned char* data;
1071 tlength = io_slurp(ig, &data);
1072 RETVAL = newSVpv((char *)data,tlength);
1077 MODULE = Imager PACKAGE = Imager::IO PREFIX = i_io_
1080 i_io_raw_write(ig, data_sv)
1088 if (SvUTF8(data_sv)) {
1089 data_sv = sv_2mortal(newSVsv(data_sv));
1090 /* yes, we want this to croak() if the SV can't be downgraded */
1091 sv_utf8_downgrade(data_sv, FALSE);
1094 data = SvPV(data_sv, size);
1095 RETVAL = i_io_raw_write(ig, data, size);
1100 i_io_raw_read(ig, buffer_sv, size)
1109 croak("size negative in call to i_io_raw_read()");
1110 /* prevent an undefined value warning if they supplied an
1112 Orginally conditional on !SvOK(), but this will prevent the
1113 downgrade from croaking */
1114 sv_setpvn(buffer_sv, "", 0);
1116 if (SvUTF8(buffer_sv))
1117 sv_utf8_downgrade(buffer_sv, FALSE);
1119 buffer = SvGROW(buffer_sv, size+1);
1120 result = i_io_raw_read(ig, buffer, size);
1122 SvCUR_set(buffer_sv, result);
1123 *SvEND(buffer_sv) = '\0';
1124 SvPOK_only(buffer_sv);
1126 PUSHs(sv_2mortal(newSViv(result)));
1132 i_io_raw_read2(ig, size)
1141 croak("size negative in call to i_io_read2()");
1142 buffer_sv = newSV(size);
1143 buffer = SvGROW(buffer_sv, size+1);
1144 result = i_io_raw_read(ig, buffer, size);
1146 SvCUR_set(buffer_sv, result);
1147 *SvEND(buffer_sv) = '\0';
1148 SvPOK_only(buffer_sv);
1150 PUSHs(sv_2mortal(buffer_sv));
1154 SvREFCNT_dec(buffer_sv);
1158 i_io_raw_seek(ig, position, whence)
1172 i_io_CLONE_SKIP(...)
1174 (void)items; /* avoid unused warning for XS variable */
1201 i_io_seek(ig, off, whence)
1207 i_io_peekn(ig, size)
1215 buffer_sv = newSV(size+1);
1216 buffer = SvGROW(buffer_sv, size+1);
1217 result = i_io_peekn(ig, buffer, size);
1219 SvCUR_set(buffer_sv, result);
1220 *SvEND(buffer_sv) = '\0';
1221 SvPOK_only(buffer_sv);
1223 PUSHs(sv_2mortal(buffer_sv));
1227 SvREFCNT_dec(buffer_sv);
1231 i_io_read(ig, buffer_sv, size)
1240 croak("size negative in call to i_io_read()");
1241 /* prevent an undefined value warning if they supplied an
1243 Orginally conditional on !SvOK(), but this will prevent the
1244 downgrade from croaking */
1245 sv_setpvn(buffer_sv, "", 0);
1247 if (SvUTF8(buffer_sv))
1248 sv_utf8_downgrade(buffer_sv, FALSE);
1250 buffer = SvGROW(buffer_sv, size+1);
1251 result = i_io_read(ig, buffer, size);
1253 SvCUR_set(buffer_sv, result);
1254 *SvEND(buffer_sv) = '\0';
1255 SvPOK_only(buffer_sv);
1257 PUSHs(sv_2mortal(newSViv(result)));
1263 i_io_read2(ig, size)
1272 croak("size zero in call to read2()");
1273 buffer_sv = newSV(size);
1274 buffer = SvGROW(buffer_sv, size+1);
1275 result = i_io_read(ig, buffer, size);
1277 SvCUR_set(buffer_sv, result);
1278 *SvEND(buffer_sv) = '\0';
1279 SvPOK_only(buffer_sv);
1281 PUSHs(sv_2mortal(buffer_sv));
1285 SvREFCNT_dec(buffer_sv);
1289 i_io_gets(ig, size = 8192, eol = NEWLINE)
1299 croak("size too small in call to gets()");
1300 buffer_sv = sv_2mortal(newSV(size+1));
1301 buffer = SvPVX(buffer_sv);
1302 result = i_io_gets(ig, buffer, size+1, eol);
1304 SvCUR_set(buffer_sv, result);
1305 *SvEND(buffer_sv) = '\0';
1306 SvPOK_only(buffer_sv);
1312 i_io_write(ig, data_sv)
1320 if (SvUTF8(data_sv)) {
1321 data_sv = sv_2mortal(newSVsv(data_sv));
1322 /* yes, we want this to croak() if the SV can't be downgraded */
1323 sv_utf8_downgrade(data_sv, FALSE);
1326 data = SvPV(data_sv, size);
1327 RETVAL = i_io_write(ig, data, size);
1332 i_io_dump(ig, flags = I_IO_DUMP_DEFAULT)
1337 i_io_set_buffered(ig, flag = 1)
1342 i_io_is_buffered(ig)
1353 MODULE = Imager PACKAGE = Imager
1364 while( (item=i_format_list[i++]) != NULL ) {
1366 PUSHs(sv_2mortal(newSVpv(item,0)));
1379 i_img_empty_ch(im,x,y,ch)
1386 i_sametype(im, x, y)
1392 i_sametype_chans(im, x, y, channels)
1399 i_init_log(name_sv,level)
1403 const char *name = SvOK(name_sv) ? SvPV_nolen(name_sv) : NULL;
1405 RETVAL = i_init_log(name, level);
1410 i_log_entry(string,level)
1431 i_img_info(im,info);
1433 PUSHs(sv_2mortal(newSViv(info[0])));
1434 PUSHs(sv_2mortal(newSViv(info[1])));
1435 PUSHs(sv_2mortal(newSViv(info[2])));
1436 PUSHs(sv_2mortal(newSViv(info[3])));
1442 i_img_setmask(im,ch_mask)
1451 i_img_getchannels(im)
1460 sv_2mortal(newSVpv((char *)im->idata, im->bytes))
1468 i_img_get_height(im)
1473 i_img_is_monochrome(im)
1479 result = i_img_is_monochrome(im, &zero_is_white);
1481 if (GIMME_V == G_ARRAY) {
1484 PUSHs(sv_2mortal(newSViv(zero_is_white)));
1493 i_line(im,x1,y1,x2,y2,val,endp)
1503 i_line_aa(im,x1,y1,x2,y2,val,endp)
1513 i_box(im,x1,y1,x2,y2,val)
1522 i_box_filled(im,x1,y1,x2,y2,val)
1531 i_box_filledf(im,x1,y1,x2,y2,val)
1537 Imager::Color::Float val
1540 i_box_cfill(im,x1,y1,x2,y2,fill)
1546 Imager::FillHandle fill
1549 i_arc(im,x,y,rad,d1,d2,val)
1559 i_arc_aa(im,x,y,rad,d1,d2,val)
1569 i_arc_cfill(im,x,y,rad,d1,d2,fill)
1576 Imager::FillHandle fill
1579 i_arc_aa_cfill(im,x,y,rad,d1,d2,fill)
1586 Imager::FillHandle fill
1590 i_circle_aa(im,x,y,rad,val)
1598 i_circle_out(im,x,y,rad,val)
1606 i_circle_out_aa(im,x,y,rad,val)
1614 i_arc_out(im,x,y,rad,d1,d2,val)
1624 i_arc_out_aa(im,x,y,rad,d1,d2,val)
1635 i_bezier_multi(im,xc,yc,val)
1648 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_bezier_multi must be a reference to an array\n");
1649 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_bezier_multi must be a reference to an array\n");
1650 if (!SvROK(ST(2))) croak("Imager: Parameter 2 to i_bezier_multi must be a reference to an array\n");
1651 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 to i_bezier_multi must be a reference to an array\n");
1652 av1=(AV*)SvRV(ST(1));
1653 av2=(AV*)SvRV(ST(2));
1654 if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_bezier_multi must be equal length\n");
1656 x=mymalloc( len*sizeof(double) );
1657 y=mymalloc( len*sizeof(double) );
1658 for(i=0;i<len;i++) {
1659 sv1=(*(av_fetch(av1,i,0)));
1660 sv2=(*(av_fetch(av2,i,0)));
1661 x[i]=(double)SvNV(sv1);
1662 y[i]=(double)SvNV(sv2);
1664 i_bezier_multi(im,len,x,y,val);
1670 i_poly_aa(im,xc,yc,val)
1683 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1684 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1685 if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1686 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1687 av1=(AV*)SvRV(ST(1));
1688 av2=(AV*)SvRV(ST(2));
1689 if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_poly_aa must be equal length\n");
1691 x=mymalloc( len*sizeof(double) );
1692 y=mymalloc( len*sizeof(double) );
1693 for(i=0;i<len;i++) {
1694 sv1=(*(av_fetch(av1,i,0)));
1695 sv2=(*(av_fetch(av2,i,0)));
1696 x[i]=(double)SvNV(sv1);
1697 y[i]=(double)SvNV(sv2);
1699 RETVAL = i_poly_aa(im,len,x,y,val);
1706 i_poly_aa_cfill(im,xc,yc,fill)
1708 Imager::FillHandle fill
1718 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1719 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1720 if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1721 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1722 av1=(AV*)SvRV(ST(1));
1723 av2=(AV*)SvRV(ST(2));
1724 if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_poly_aa_cfill must be equal length\n");
1726 x=mymalloc( len*sizeof(double) );
1727 y=mymalloc( len*sizeof(double) );
1728 for(i=0;i<len;i++) {
1729 sv1=(*(av_fetch(av1,i,0)));
1730 sv2=(*(av_fetch(av2,i,0)));
1731 x[i]=(double)SvNV(sv1);
1732 y[i]=(double)SvNV(sv2);
1734 RETVAL = i_poly_aa_cfill(im,len,x,y,fill);
1743 i_flood_fill(im,seedx,seedy,dcol)
1750 i_flood_cfill(im,seedx,seedy,fill)
1754 Imager::FillHandle fill
1757 i_flood_fill_border(im,seedx,seedy,dcol, border)
1762 Imager::Color border
1765 i_flood_cfill_border(im,seedx,seedy,fill, border)
1769 Imager::FillHandle fill
1770 Imager::Color border
1774 i_copyto(im,src,x1,y1,x2,y2,tx,ty)
1786 i_copyto_trans(im,src,x1,y1,x2,y2,tx,ty,trans)
1803 i_rubthru(im,src,tx,ty,src_minx,src_miny,src_maxx,src_maxy)
1814 i_compose(out, src, out_left, out_top, src_left, src_top, width, height, combine = ic_normal, opacity = 0.0)
1827 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)
1843 i_combine(src_av, channels_av = NULL)
1847 i_img **imgs = NULL;
1849 int *channels = NULL;
1854 in_count = av_len(src_av) + 1;
1856 imgs = mymalloc(sizeof(i_img*) * in_count);
1857 channels = mymalloc(sizeof(int) * in_count);
1858 for (i = 0; i < in_count; ++i) {
1859 psv = av_fetch(src_av, i, 0);
1860 if (!psv || !*psv || !sv_derived_from(*psv, "Imager::ImgRaw")) {
1863 croak("imgs must contain only images");
1865 tmp = SvIV((SV*)SvRV(*psv));
1866 imgs[i] = INT2PTR(i_img*, tmp);
1868 (psv = av_fetch(channels_av, i, 0)) != NULL &&
1870 channels[i] = SvIV(*psv);
1877 RETVAL = i_combine(imgs, channels, in_count);
1884 i_flipxy(im, direction)
1889 i_rotate90(im, degrees)
1894 i_rotate_exact(im, amount, ...)
1898 i_color *backp = NULL;
1899 i_fcolor *fbackp = NULL;
1903 /* extract the bg colors if any */
1904 /* yes, this is kind of strange */
1905 for (i = 2; i < items; ++i) {
1907 if (sv_derived_from(sv1, "Imager::Color")) {
1908 IV tmp = SvIV((SV*)SvRV(sv1));
1909 backp = INT2PTR(i_color *, tmp);
1911 else if (sv_derived_from(sv1, "Imager::Color::Float")) {
1912 IV tmp = SvIV((SV*)SvRV(sv1));
1913 fbackp = INT2PTR(i_fcolor *, tmp);
1916 RETVAL = i_rotate_exact_bg(im, amount, backp, fbackp);
1921 i_matrix_transform(im, xsize, ysize, matrix, ...)
1931 i_color *backp = NULL;
1932 i_fcolor *fbackp = NULL;
1934 if (!SvROK(ST(3)) || SvTYPE(SvRV(ST(3))) != SVt_PVAV)
1935 croak("i_matrix_transform: parameter 4 must be an array ref\n");
1936 av=(AV*)SvRV(ST(3));
1940 for (i = 0; i < len; ++i) {
1941 sv1=(*(av_fetch(av,i,0)));
1942 matrix[i] = SvNV(sv1);
1946 /* extract the bg colors if any */
1947 /* yes, this is kind of strange */
1948 for (i = 4; i < items; ++i) {
1950 if (sv_derived_from(sv1, "Imager::Color")) {
1951 IV tmp = SvIV((SV*)SvRV(sv1));
1952 backp = INT2PTR(i_color *, tmp);
1954 else if (sv_derived_from(sv1, "Imager::Color::Float")) {
1955 IV tmp = SvIV((SV*)SvRV(sv1));
1956 fbackp = INT2PTR(i_fcolor *, tmp);
1959 RETVAL = i_matrix_transform_bg(im, xsize, ysize, matrix, backp, fbackp);
1964 i_gaussian(im,stdev)
1969 i_unsharp_mask(im,stdev,scale)
1984 len = av_len(coef) + 1;
1985 c_coef=mymalloc( len * sizeof(double) );
1986 for(i = 0; i < len; i++) {
1987 sv1 = (*(av_fetch(coef, i, 0)));
1988 c_coef[i] = (double)SvNV(sv1);
1990 RETVAL = i_conv(im, c_coef, len);
1996 i_convert(src, avmain)
2008 outchan = av_len(avmain)+1;
2009 /* find the biggest */
2011 for (j=0; j < outchan; ++j) {
2012 temp = av_fetch(avmain, j, 0);
2013 if (temp && SvROK(*temp) && SvTYPE(SvRV(*temp)) == SVt_PVAV) {
2014 avsub = (AV*)SvRV(*temp);
2015 len = av_len(avsub)+1;
2020 coeff = mymalloc(sizeof(double) * outchan * inchan);
2021 for (j = 0; j < outchan; ++j) {
2022 avsub = (AV*)SvRV(*av_fetch(avmain, j, 0));
2023 len = av_len(avsub)+1;
2024 for (i = 0; i < len; ++i) {
2025 temp = av_fetch(avsub, i, 0);
2027 coeff[i+j*inchan] = SvNV(*temp);
2029 coeff[i+j*inchan] = 0;
2032 coeff[i++ + j*inchan] = 0;
2034 RETVAL = i_convert(src, coeff, outchan, inchan);
2044 unsigned int mask = 0;
2050 unsigned char (*maps)[256];
2052 if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
2053 croak("i_map: parameter 2 must be an arrayref\n");
2054 avmain = (AV*)SvRV(ST(1));
2055 len = av_len(avmain)+1;
2056 if (im->channels < len) len = im->channels;
2058 maps = mymalloc( len * sizeof(unsigned char [256]) );
2060 for (j=0; j<len ; j++) {
2061 temp = av_fetch(avmain, j, 0);
2062 if (temp && SvROK(*temp) && (SvTYPE(SvRV(*temp)) == SVt_PVAV) ) {
2063 avsub = (AV*)SvRV(*temp);
2064 if(av_len(avsub) != 255) continue;
2066 for (i=0; i<256 ; i++) {
2068 temp = av_fetch(avsub, i, 0);
2069 val = temp ? SvIV(*temp) : 0;
2071 if (val>255) val = 255;
2076 i_map(im, maps, mask);
2087 i_img_diffd(im1,im2)
2092 i_img_samef(im1, im2, epsilon = i_img_epsilonf(), what=NULL)
2102 _is_color_object(sv)
2106 RETVAL = SvOK(sv) && SvROK(sv) &&
2107 (sv_derived_from(sv, "Imager::Color")
2108 || sv_derived_from(sv, "Imager::Color::Float"));
2120 MODULE = Imager PACKAGE = Imager::Font::TT PREFIX=TT_
2122 #define TT_DESTROY(handle) i_tt_destroy(handle)
2126 Imager::Font::TT handle
2131 (void)items; /* avoid unused warning */
2137 MODULE = Imager PACKAGE = Imager
2141 i_tt_text(handle,im,xb,yb,cl,points,str_sv,len_ignored,smooth,utf8,align=1)
2142 Imager::Font::TT handle
2160 str = SvPV(str_sv, len);
2161 RETVAL = i_tt_text(handle, im, xb, yb, cl, points, str,
2162 len, smooth, utf8, align);
2168 i_tt_cp(handle,im,xb,yb,channel,points,str_sv,len_ignored,smooth,utf8,align=1)
2169 Imager::Font::TT handle
2187 str = SvPV(str_sv, len);
2188 RETVAL = i_tt_cp(handle, im, xb, yb, channel, points, str, len,
2189 smooth, utf8, align);
2195 i_tt_bbox(handle,point,str_sv,len_ignored, utf8)
2196 Imager::Font::TT handle
2201 i_img_dim cords[BOUNDING_BOX_COUNT];
2211 str = SvPV(str_sv, len);
2212 if ((rc=i_tt_bbox(handle,point,str,len,cords, utf8))) {
2214 for (i = 0; i < rc; ++i) {
2215 PUSHs(sv_2mortal(newSViv(cords[i])));
2220 i_tt_has_chars(handle, text_sv, utf8)
2221 Imager::Font::TT handle
2232 if (SvUTF8(text_sv))
2235 text = SvPV(text_sv, len);
2236 work = mymalloc(len);
2237 count = i_tt_has_chars(handle, text, len, utf8, work);
2238 if (GIMME_V == G_ARRAY) {
2240 for (i = 0; i < count; ++i) {
2241 PUSHs(boolSV(work[i]));
2246 PUSHs(sv_2mortal(newSVpv(work, count)));
2251 i_tt_dump_names(handle)
2252 Imager::Font::TT handle
2255 i_tt_face_name(handle)
2256 Imager::Font::TT handle
2261 len = i_tt_face_name(handle, name, sizeof(name));
2264 PUSHs(sv_2mortal(newSVpv(name, len-1)));
2268 i_tt_glyph_name(handle, text_sv, utf8 = 0)
2269 Imager::Font::TT handle
2280 if (SvUTF8(text_sv))
2283 text = SvPV(text_sv, work_len);
2288 ch = i_utf8_advance(&text, &len);
2290 i_push_error(0, "invalid UTF8 character");
2299 if ((outsize = i_tt_glyph_name(handle, ch, name, sizeof(name))) != 0) {
2300 PUSHs(sv_2mortal(newSVpv(name, 0)));
2303 PUSHs(&PL_sv_undef);
2310 i_test_format_probe(ig, length)
2315 i_readpnm_wiol(ig, allow_incomplete)
2317 int allow_incomplete
2321 i_readpnm_multi_wiol(ig, allow_incomplete)
2323 int allow_incomplete
2329 imgs = i_readpnm_multi_wiol(ig, &count, allow_incomplete);
2332 for (i = 0; i < count; ++i) {
2333 SV *sv = sv_newmortal();
2334 sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
2341 i_writeppm_wiol(im, ig)
2350 i_readraw_wiol(ig,x,y,datachannels,storechannels,intrl)
2359 i_writeraw_wiol(im,ig)
2364 i_writebmp_wiol(im,ig)
2369 i_readbmp_wiol(ig, allow_incomplete=0)
2371 int allow_incomplete
2375 i_writetga_wiol(im,ig, wierdpack, compress, idstring)
2384 idlen = SvCUR(ST(4));
2385 RETVAL = i_writetga_wiol(im, ig, wierdpack, compress, idstring, idlen);
2391 i_readtga_wiol(ig, length)
2399 i_scaleaxis(im,Value,Axis)
2405 i_scale_nn(im,scx,scy)
2411 i_scale_mixing(im, width, height)
2421 i_count_colors(im,maxc)
2426 i_get_anonymous_color_histo(im, maxc = 0x40000000)
2431 unsigned int * col_usage = NULL;
2434 col_cnt = i_get_anonymous_color_histo(im, &col_usage, maxc);
2435 EXTEND(SP, col_cnt);
2436 for (i = 0; i < col_cnt; i++) {
2437 PUSHs(sv_2mortal(newSViv( col_usage[i])));
2444 i_transform(im,opx,opy,parm)
2458 if (!SvROK(ST(1))) croak("Imager: Parameter 1 must be a reference to an array\n");
2459 if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to an array\n");
2460 if (!SvROK(ST(3))) croak("Imager: Parameter 3 must be a reference to an array\n");
2461 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 must be a reference to an array\n");
2462 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 must be a reference to an array\n");
2463 if (SvTYPE(SvRV(ST(3))) != SVt_PVAV) croak("Imager: Parameter 3 must be a reference to an array\n");
2464 av=(AV*)SvRV(ST(1));
2466 opx=mymalloc( opxl*sizeof(int) );
2467 for(i=0;i<opxl;i++) {
2468 sv1=(*(av_fetch(av,i,0)));
2469 opx[i]=(int)SvIV(sv1);
2471 av=(AV*)SvRV(ST(2));
2473 opy=mymalloc( opyl*sizeof(int) );
2474 for(i=0;i<opyl;i++) {
2475 sv1=(*(av_fetch(av,i,0)));
2476 opy[i]=(int)SvIV(sv1);
2478 av=(AV*)SvRV(ST(3));
2479 parmlen=av_len(av)+1;
2480 parm=mymalloc( parmlen*sizeof(double) );
2481 for(i=0;i<parmlen;i++) { /* FIXME: Bug? */
2482 sv1=(*(av_fetch(av,i,0)));
2483 parm[i]=(double)SvNV(sv1);
2485 result=i_transform(im,opx,opxl,opy,opyl,parm,parmlen);
2490 SV *result_sv = sv_newmortal();
2492 sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result);
2497 i_transform2(sv_width,sv_height,channels,sv_ops,av_n_regs,av_c_regs,av_in_imgs)
2523 in_imgs_count = av_len(av_in_imgs)+1;
2524 for (i = 0; i < in_imgs_count; ++i) {
2525 sv1 = *av_fetch(av_in_imgs, i, 0);
2526 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2527 croak("sv_in_img must contain only images");
2530 if (in_imgs_count > 0) {
2531 in_imgs = mymalloc(in_imgs_count*sizeof(i_img*));
2532 for (i = 0; i < in_imgs_count; ++i) {
2533 sv1 = *av_fetch(av_in_imgs,i,0);
2534 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2535 croak("Parameter 5 must contain only images");
2537 tmp = SvIV((SV*)SvRV(sv1));
2538 in_imgs[i] = INT2PTR(i_img*, tmp);
2542 /* no input images */
2545 /* default the output size from the first input if possible */
2547 width = SvIV(sv_width);
2548 else if (in_imgs_count)
2549 width = in_imgs[0]->xsize;
2551 croak("No output image width supplied");
2553 if (SvOK(sv_height))
2554 height = SvIV(sv_height);
2555 else if (in_imgs_count)
2556 height = in_imgs[0]->ysize;
2558 croak("No output image height supplied");
2560 ops = (struct rm_op *)SvPV(sv_ops, ops_len);
2561 if (ops_len % sizeof(struct rm_op))
2562 croak("Imager: Parameter 3 must be a bitmap of regops\n");
2563 ops_count = ops_len / sizeof(struct rm_op);
2565 n_regs_count = av_len(av_n_regs)+1;
2566 n_regs = mymalloc(n_regs_count * sizeof(double));
2567 for (i = 0; i < n_regs_count; ++i) {
2568 sv1 = *av_fetch(av_n_regs,i,0);
2570 n_regs[i] = SvNV(sv1);
2572 c_regs_count = av_len(av_c_regs)+1;
2573 c_regs = mymalloc(c_regs_count * sizeof(i_color));
2574 /* I don't bother initializing the colou?r registers */
2576 result=i_transform2(width, height, channels, ops, ops_count,
2577 n_regs, n_regs_count,
2578 c_regs, c_regs_count, in_imgs, in_imgs_count);
2584 SV *result_sv = sv_newmortal();
2586 sv_setref_pv(result_sv, "Imager::ImgRaw", (void*)result);
2592 i_contrast(im,intensity)
2605 i_noise(im,amount,type)
2611 i_bumpmap(im,bump,channel,light_x,light_y,strength)
2621 i_bumpmap_complex(im,bump,channel,tx,ty,Lx,Ly,Lz,cd,cs,n,Ia,Il,Is)
2640 i_postlevels(im,levels)
2650 i_watermark(im,wmark,tx,ty,pixdiff)
2652 Imager::ImgRaw wmark
2659 i_autolevels(im,lsat,usat,skew)
2666 i_radnoise(im,xo,yo,rscale,ascale)
2674 i_turbnoise(im, xo, yo, scale)
2697 croak("Usage: i_gradgen(im, xo, yo, ival, dmeasure)");
2698 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2699 croak("i_gradgen: Second argument must be an array ref");
2700 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
2701 croak("i_gradgen: Third argument must be an array ref");
2702 if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
2703 croak("i_gradgen: Fourth argument must be an array ref");
2704 axx = (AV *)SvRV(ST(1));
2705 ayy = (AV *)SvRV(ST(2));
2706 ac = (AV *)SvRV(ST(3));
2707 dmeasure = (int)SvIV(ST(4));
2709 num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
2710 num = num <= av_len(ac) ? num : av_len(ac);
2712 if (num < 2) croak("Usage: i_gradgen array refs must have more than 1 entry each");
2713 xo = mymalloc( sizeof(i_img_dim) * num );
2714 yo = mymalloc( sizeof(i_img_dim) * num );
2715 ival = mymalloc( sizeof(i_color) * num );
2716 for(i = 0; i<num; i++) {
2717 xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0));
2718 yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0));
2719 sv = *av_fetch(ac, i, 0);
2720 if ( !sv_derived_from(sv, "Imager::Color") ) {
2721 free(axx); free(ayy); free(ac);
2722 croak("i_gradgen: Element of fourth argument is not derived from Imager::Color");
2724 ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
2726 i_gradgen(im, num, xo, yo, ival, dmeasure);
2732 i_diff_image(im, im2, mindist=0)
2738 i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2748 double ssample_param
2752 i_fountain_seg *segs;
2754 if (!SvROK(ST(10)) || ! SvTYPE(SvRV(ST(10))))
2755 croak("i_fountain: argument 11 must be an array ref");
2757 asegs = (AV *)SvRV(ST(10));
2758 segs = load_fount_segs(aTHX_ asegs, &count);
2759 RETVAL = i_fountain(im, xa, ya, xb, yb, type, repeat, combine,
2760 super_sample, ssample_param, count, segs);
2766 i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2775 double ssample_param
2779 i_fountain_seg *segs;
2781 if (!SvROK(ST(9)) || ! SvTYPE(SvRV(ST(9))))
2782 croak("i_fountain: argument 11 must be an array ref");
2784 asegs = (AV *)SvRV(ST(9));
2785 segs = load_fount_segs(aTHX_ asegs, &count);
2786 RETVAL = i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine,
2787 super_sample, ssample_param, count, segs);
2793 i_new_fill_opacity(other_fill, alpha_mult)
2794 Imager::FillHandle other_fill
2805 errors = i_errors();
2807 while (errors[i].msg) {
2809 sv = newSVpv(errors[i].msg, strlen(errors[i].msg));
2810 if (!av_store(av, 0, sv)) {
2813 sv = newSViv(errors[i].code);
2814 if (!av_store(av, 1, sv)) {
2817 PUSHs(sv_2mortal(newRV_noinc((SV*)av)));
2825 i_push_error(code, msg)
2830 i_nearest_color(im, ...)
2845 croak("Usage: i_nearest_color(im, xo, yo, ival, dmeasure)");
2846 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2847 croak("i_nearest_color: Second argument must be an array ref");
2848 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
2849 croak("i_nearest_color: Third argument must be an array ref");
2850 if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
2851 croak("i_nearest_color: Fourth argument must be an array ref");
2852 axx = (AV *)SvRV(ST(1));
2853 ayy = (AV *)SvRV(ST(2));
2854 ac = (AV *)SvRV(ST(3));
2855 dmeasure = (int)SvIV(ST(4));
2857 num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
2858 num = num <= av_len(ac) ? num : av_len(ac);
2860 if (num < 2) croak("Usage: i_nearest_color array refs must have more than 1 entry each");
2861 xo = mymalloc( sizeof(i_img_dim) * num );
2862 yo = mymalloc( sizeof(i_img_dim) * num );
2863 ival = mymalloc( sizeof(i_color) * num );
2864 for(i = 0; i<num; i++) {
2865 xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0));
2866 yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0));
2867 sv = *av_fetch(ac, i, 0);
2868 if ( !sv_derived_from(sv, "Imager::Color") ) {
2869 free(axx); free(ayy); free(ac);
2870 croak("i_nearest_color: Element of fourth argument is not derived from Imager::Color");
2872 ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
2874 RETVAL = i_nearest_color(im, num, xo, yo, ival, dmeasure);
2888 rc=DSO_open(filename,&evstr);
2892 PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
2893 PUSHs(sv_2mortal(newSVpvn(evstr, strlen(evstr))));
2896 PUSHs(sv_2mortal(newSViv(PTR2IV(rc))));
2902 DSO_close(dso_handle)
2906 DSO_funclist(dso_handle_v)
2910 DSO_handle *dso_handle;
2911 func_ptr *functions;
2913 dso_handle=(DSO_handle*)dso_handle_v;
2914 functions = DSO_funclist(dso_handle);
2916 while( functions[i].name != NULL) {
2918 PUSHs(sv_2mortal(newSVpv(functions[i].name,0)));
2920 PUSHs(sv_2mortal(newSVpv(functions[i++].pcode,0)));
2924 DSO_call(handle,func_index,hv)
2930 if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to a hash\n");
2931 hv=(HV*)SvRV(ST(2));
2932 if (SvTYPE(hv)!=SVt_PVHV) croak("Imager: Parameter 2 must be a reference to a hash\n");
2933 DSO_call( (DSO_handle *)handle,func_index,hv);
2936 i_get_pixel(im, x, y)
2943 color = (i_color *)mymalloc(sizeof(i_color));
2944 if (i_gpix(im, x, y, color) == 0) {
2945 RETVAL = NEWSV(0, 0);
2946 sv_setref_pv(RETVAL, "Imager::Color", (void *)color);
2950 RETVAL = &PL_sv_undef;
2957 i_ppix(im, x, y, cl)
2964 i_img_pal_new(x, y, channels, maxpal)
2971 i_img_to_pal(src, quant)
2977 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2978 croak("i_img_to_pal: second argument must be a hash ref");
2979 hv = (HV *)SvRV(ST(1));
2980 memset(&quant, 0, sizeof(quant));
2982 quant.mc_size = 256;
2983 ip_handle_quant_opts(aTHX_ &quant, hv);
2984 RETVAL = i_img_to_pal(src, &quant);
2986 ip_copy_colors_back(aTHX_ hv, &quant);
2988 ip_cleanup_quant_opts(aTHX_ &quant);
2997 i_img_make_palette(HV *quant_hv, ...)
2999 size_t count = items - 1;
3001 i_img **imgs = NULL;
3005 croak("Please supply at least one image (%d)", (int)count);
3006 imgs = mymalloc(sizeof(i_img *) * count);
3007 for (i = 0; i < count; ++i) {
3008 SV *img_sv = ST(i + 1);
3009 if (SvROK(img_sv) && sv_derived_from(img_sv, "Imager::ImgRaw")) {
3010 imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(img_sv)));
3014 croak("Image %d is not an image object", (int)i+1);
3017 memset(&quant, 0, sizeof(quant));
3019 quant.mc_size = 256;
3020 ip_handle_quant_opts(aTHX_ &quant, quant_hv);
3021 i_quant_makemap(&quant, imgs, count);
3022 EXTEND(SP, quant.mc_count);
3023 for (i = 0; i < quant.mc_count; ++i) {
3024 SV *sv_c = make_i_color_sv(aTHX_ quant.mc_colors + i);
3027 ip_cleanup_quant_opts(aTHX_ &quant);
3041 work = mymalloc((r-l) * sizeof(i_palidx));
3042 count = i_gpal(im, l, r, y, work);
3043 if (GIMME_V == G_ARRAY) {
3045 for (i = 0; i < count; ++i) {
3046 PUSHs(sv_2mortal(newSViv(work[i])));
3051 PUSHs(sv_2mortal(newSVpv((char *)work, count * sizeof(i_palidx))));
3056 if (GIMME_V != G_ARRAY) {
3058 PUSHs(&PL_sv_undef);
3063 i_ppal(im, l, y, ...)
3072 work = malloc_temp(aTHX_ sizeof(i_palidx) * (items-3));
3073 for (i=0; i < items-3; ++i) {
3074 work[i] = SvIV(ST(i+3));
3076 validate_i_ppal(im, work, items - 3);
3077 RETVAL = i_ppal(im, l, l+items-3, y, work);
3086 i_ppal_p(im, l, y, data)
3092 i_palidx const *work;
3095 work = (i_palidx const *)SvPV(data, len);
3096 len /= sizeof(i_palidx);
3098 validate_i_ppal(im, work, len);
3099 RETVAL = i_ppal(im, l, l+len, y, work);
3108 i_addcolors(im, ...)
3116 croak("i_addcolors: no colors to add");
3117 colors = mymalloc((items-1) * sizeof(i_color));
3118 for (i=0; i < items-1; ++i) {
3119 if (sv_isobject(ST(i+1))
3120 && sv_derived_from(ST(i+1), "Imager::Color")) {
3121 IV tmp = SvIV((SV *)SvRV(ST(i+1)));
3122 colors[i] = *INT2PTR(i_color *, tmp);
3126 croak("i_addcolor: pixels must be Imager::Color objects");
3129 index = i_addcolors(im, colors, items-1);
3132 RETVAL = newSVpv("0 but true", 0);
3134 else if (index == -1) {
3135 RETVAL = &PL_sv_undef;
3138 RETVAL = newSViv(index);
3144 i_setcolors(im, index, ...)
3152 croak("i_setcolors: no colors to add");
3153 colors = mymalloc((items-2) * sizeof(i_color));
3154 for (i=0; i < items-2; ++i) {
3155 if (sv_isobject(ST(i+2))
3156 && sv_derived_from(ST(i+2), "Imager::Color")) {
3157 IV tmp = SvIV((SV *)SvRV(ST(i+2)));
3158 colors[i] = *INT2PTR(i_color *, tmp);
3162 croak("i_setcolors: pixels must be Imager::Color objects");
3165 RETVAL = i_setcolors(im, index, colors, items-2);
3171 i_getcolors(im, index, ...)
3180 croak("i_getcolors: too many arguments");
3182 count = SvIV(ST(2));
3184 croak("i_getcolors: count must be positive");
3185 colors = mymalloc(sizeof(i_color) * count);
3186 if (i_getcolors(im, index, colors, count)) {
3187 for (i = 0; i < count; ++i) {
3188 SV *sv = make_i_color_sv(aTHX_ colors+i);
3204 i_findcolor(im, color)
3210 if (i_findcolor(im, color, &index)) {
3211 RETVAL = newSViv(index);
3214 RETVAL = &PL_sv_undef;
3232 i_gsamp(im, l, r, y, channels)
3237 i_channel_list channels
3243 data = mymalloc(sizeof(i_sample_t) * (r-l) * channels.count); /* XXX: memleak? */
3244 count = i_gsamp(im, l, r, y, data, channels.channels, channels.count);
3245 if (GIMME_V == G_ARRAY) {
3247 for (i = 0; i < count; ++i)
3248 PUSHs(sv_2mortal(newSViv(data[i])));
3252 PUSHs(sv_2mortal(newSVpv((char *)data, count * sizeof(i_sample_t))));
3257 if (GIMME_V != G_ARRAY) {
3259 PUSHs(&PL_sv_undef);
3264 i_gsamp_bits(im, l, r, y, bits, target, offset, channels)
3272 i_channel_list channels
3279 croak("No channel numbers supplied to g_samp()");
3281 data = mymalloc(sizeof(unsigned) * (r-l) * channels.count);
3282 count = i_gsamp_bits(im, l, r, y, data, channels.channels, channels.count, bits);
3283 for (i = 0; i < count; ++i) {
3284 av_store(target, i+offset, newSVuv(data[i]));
3296 i_psamp_bits(im, l, y, bits, channels, data_av, data_offset = 0, pixel_count = -1)
3301 i_channel_list channels
3303 i_img_dim data_offset
3304 i_img_dim pixel_count
3313 data_count = av_len(data_av) + 1;
3314 if (data_offset < 0) {
3315 croak("data_offset must be non-negative");
3317 if (data_offset > data_count) {
3318 croak("data_offset greater than number of samples supplied");
3320 if (pixel_count == -1 ||
3321 data_offset + pixel_count * channels.count > data_count) {
3322 pixel_count = (data_count - data_offset) / channels.count;
3325 data_used = pixel_count * channels.count;
3326 data = mymalloc(sizeof(unsigned) * data_count);
3327 for (i = 0; i < data_used; ++i)
3328 data[i] = SvUV(*av_fetch(data_av, data_offset + i, 0));
3330 RETVAL = i_psamp_bits(im, l, l + pixel_count, y, data, channels.channels,
3331 channels.count, bits);
3339 i_psamp(im, x, y, channels, data, offset = 0, width = -1)
3343 i_channel_list channels
3352 i_push_error(0, "offset must be non-negative");
3356 if (offset > data.count) {
3357 i_push_error(0, "offset greater than number of samples supplied");
3360 data.samples += offset;
3361 data.count -= offset;
3364 width * channels.count > data.count) {
3365 width = data.count / channels.count;
3368 RETVAL = i_psamp(im, x, r, y, data.samples, channels.channels, channels.count);
3373 i_psampf(im, x, y, channels, data, offset = 0, width = -1)
3377 i_channel_list channels
3386 i_push_error(0, "offset must be non-negative");
3390 if (offset > data.count) {
3391 i_push_error(0, "offset greater than number of samples supplied");
3394 data.samples += offset;
3395 data.count -= offset;
3398 width * channels.count > data.count) {
3399 width = data.count / channels.count;
3402 RETVAL = i_psampf(im, x, r, y, data.samples, channels.channels, channels.count);
3407 i_img_masked_new(targ, mask, x, y, w, h)
3417 if (!sv_isobject(ST(1))
3418 || !sv_derived_from(ST(1), "Imager::ImgRaw")) {
3419 croak("i_img_masked_new: parameter 2 must undef or an image");
3421 mask = INT2PTR(i_img *, SvIV((SV *)SvRV(ST(1))));
3425 RETVAL = i_img_masked_new(targ, mask, x, y, w, h);
3430 i_plin(im, l, y, ...)
3441 if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
3442 /* supplied as a byte string */
3443 work = (i_color *)SvPV(ST(3), len);
3444 count = len / sizeof(i_color);
3445 if (count * sizeof(i_color) != len) {
3446 croak("i_plin: length of scalar argument must be multiple of sizeof i_color");
3448 RETVAL = i_plin(im, l, l+count, y, work);
3451 work = mymalloc(sizeof(i_color) * (items-3));
3452 for (i=0; i < items-3; ++i) {
3453 if (sv_isobject(ST(i+3))
3454 && sv_derived_from(ST(i+3), "Imager::Color")) {
3455 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3456 work[i] = *INT2PTR(i_color *, tmp);
3460 croak("i_plin: pixels must be Imager::Color objects");
3463 RETVAL = i_plin(im, l, l+items-3, y, work);
3474 i_ppixf(im, x, y, cl)
3478 Imager::Color::Float cl
3481 i_gsampf(im, l, r, y, channels)
3486 i_channel_list channels
3492 data = mymalloc(sizeof(i_fsample_t) * (r-l) * channels.count);
3493 count = i_gsampf(im, l, r, y, data, channels.channels, channels.count);
3494 if (GIMME_V == G_ARRAY) {
3496 for (i = 0; i < count; ++i)
3497 PUSHs(sv_2mortal(newSVnv(data[i])));
3501 PUSHs(sv_2mortal(newSVpv((void *)data, count * sizeof(i_fsample_t))));
3506 if (GIMME_V != G_ARRAY) {
3508 PUSHs(&PL_sv_undef);
3513 i_plinf(im, l, y, ...)
3524 if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
3525 /* supplied as a byte string */
3526 work = (i_fcolor *)SvPV(ST(3), len);
3527 count = len / sizeof(i_fcolor);
3528 if (count * sizeof(i_fcolor) != len) {
3529 croak("i_plin: length of scalar argument must be multiple of sizeof i_fcolor");
3531 RETVAL = i_plinf(im, l, l+count, y, work);
3534 work = mymalloc(sizeof(i_fcolor) * (items-3));
3535 for (i=0; i < items-3; ++i) {
3536 if (sv_isobject(ST(i+3))
3537 && sv_derived_from(ST(i+3), "Imager::Color::Float")) {
3538 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3539 work[i] = *INT2PTR(i_fcolor *, tmp);
3543 croak("i_plinf: pixels must be Imager::Color::Float objects");
3547 RETVAL = i_plinf(im, l, l+items-3, y, work);
3565 color = (i_fcolor *)mymalloc(sizeof(i_fcolor));
3566 if (i_gpixf(im, x, y, color) == 0) {
3567 RETVAL = NEWSV(0,0);
3568 sv_setref_pv(RETVAL, "Imager::Color::Float", (void *)color);
3572 RETVAL = &PL_sv_undef;
3588 vals = mymalloc((r-l) * sizeof(i_color));
3589 memset(vals, 0, (r-l) * sizeof(i_color));
3590 count = i_glin(im, l, r, y, vals);
3591 if (GIMME_V == G_ARRAY) {
3593 for (i = 0; i < count; ++i) {
3594 SV *sv = make_i_color_sv(aTHX_ vals+i);
3600 PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_color))));
3606 i_glinf(im, l, r, y)
3616 for (i = 0; i < MAXCHANNELS; ++i)
3617 zero.channel[i] = 0;
3619 vals = mymalloc((r-l) * sizeof(i_fcolor));
3620 for (i = 0; i < r-l; ++i)
3622 count = i_glinf(im, l, r, y, vals);
3623 if (GIMME_V == G_ARRAY) {
3625 for (i = 0; i < count; ++i) {
3627 i_fcolor *col = mymalloc(sizeof(i_fcolor));
3629 sv = sv_newmortal();
3630 sv_setref_pv(sv, "Imager::Color::Float", (void *)col);
3636 PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_fcolor))));
3642 i_img_16_new(x, y, ch)
3652 i_img_double_new(x, y, ch)
3662 i_tags_addn(im, name, code, idata)
3671 name = SvPV(ST(1), len);
3674 RETVAL = i_tags_addn(&im->tags, name, code, idata);
3679 i_tags_add(im, name, code, data, idata)
3689 name = SvPV(ST(1), len);
3693 data = SvPV(ST(3), len);
3698 RETVAL = i_tags_add(&im->tags, name, code, data, len, idata);
3703 i_tags_find(im, name, start)
3710 if (i_tags_find(&im->tags, name, start, &entry)) {
3712 RETVAL = newSVpv("0 but true", 0);
3714 RETVAL = newSViv(entry);
3716 RETVAL = &PL_sv_undef;
3722 i_tags_findn(im, code, start)
3729 if (i_tags_findn(&im->tags, code, start, &entry)) {
3731 RETVAL = newSVpv("0 but true", 0);
3733 RETVAL = newSViv(entry);
3736 RETVAL = &PL_sv_undef;
3742 i_tags_delete(im, entry)
3746 RETVAL = i_tags_delete(&im->tags, entry);
3751 i_tags_delbyname(im, name)
3755 RETVAL = i_tags_delbyname(&im->tags, name);
3760 i_tags_delbycode(im, code)
3764 RETVAL = i_tags_delbycode(&im->tags, code);
3769 i_tags_get(im, index)
3773 if (index >= 0 && index < im->tags.count) {
3774 i_img_tag *entry = im->tags.tags + index;
3778 PUSHs(sv_2mortal(newSVpv(entry->name, 0)));
3781 PUSHs(sv_2mortal(newSViv(entry->code)));
3784 PUSHs(sv_2mortal(newSVpvn(entry->data, entry->size)));
3787 PUSHs(sv_2mortal(newSViv(entry->idata)));
3792 i_tags_get_string(im, what_sv)
3796 char const *name = NULL;
3800 if (SvIOK(what_sv)) {
3801 code = SvIV(what_sv);
3805 name = SvPV_nolen(what_sv);
3808 if (i_tags_get_string(&im->tags, name, code, buffer, sizeof(buffer))) {
3810 PUSHs(sv_2mortal(newSVpv(buffer, 0)));
3817 RETVAL = im->tags.count;
3823 MODULE = Imager PACKAGE = Imager::FillHandle PREFIX=IFILL_
3827 Imager::FillHandle fill
3830 IFILL_CLONE_SKIP(...)
3832 (void)items; /* avoid unused warning for XS variable */
3837 MODULE = Imager PACKAGE = Imager
3840 i_new_fill_solid(cl, combine)
3845 i_new_fill_solidf(cl, combine)
3846 Imager::Color::Float cl
3850 i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy)
3858 unsigned char *cust_hatch;
3862 cust_hatch = (unsigned char *)SvPV(ST(4), len);
3866 RETVAL = i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy);
3871 i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy)
3872 Imager::Color::Float fg
3873 Imager::Color::Float bg
3879 unsigned char *cust_hatch;
3883 cust_hatch = (unsigned char *)SvPV(ST(4), len);
3887 RETVAL = i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy);
3892 i_new_fill_image(src, matrix, xoff, yoff, combine)
3909 if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
3910 croak("i_new_fill_image: parameter must be an arrayref");
3911 av=(AV*)SvRV(ST(1));
3915 for (i = 0; i < len; ++i) {
3916 sv1=(*(av_fetch(av,i,0)));
3917 matrix[i] = SvNV(sv1);
3923 RETVAL = i_new_fill_image(src, matrixp, xoff, yoff, combine);
3927 MODULE = Imager PACKAGE = Imager::Internal::Hlines PREFIX=i_int_hlines_
3929 # this class is only exposed for testing
3932 i_int_hlines_testing()
3934 #if i_int_hlines_testing()
3936 Imager::Internal::Hlines
3937 i_int_hlines_new(start_y, count_y, start_x, count_x)
3943 Imager::Internal::Hlines
3944 i_int_hlines_new_img(im)
3948 i_int_hlines_add(hlines, y, minx, width)
3949 Imager::Internal::Hlines hlines
3955 i_int_hlines_DESTROY(hlines)
3956 Imager::Internal::Hlines hlines
3959 i_int_hlines_dump(hlines)
3960 Imager::Internal::Hlines hlines
3963 i_int_hlines_CLONE_SKIP(cls)
3968 PERL_SET_GLOBAL_CALLBACKS;
3969 PERL_PL_SET_GLOBAL_CALLBACKS;