17 typedef io_glue* Imager__IO;
18 typedef i_color* Imager__Color;
19 typedef i_fcolor* Imager__Color__Float;
20 typedef i_img* Imager__ImgRaw;
24 typedef TT_Fonthandle* Imager__Font__TT;
28 typedef FT2_Fonthandle* Imager__Font__FT2;
32 void my_SvREFCNT_dec(void *p) {
38 log_entry(char *string, int level) {
39 mm_log((level, string));
43 typedef struct i_reader_data_tag
45 /* presumably a CODE ref or name of a sub */
49 /* used by functions that want callbacks */
50 static int read_callback(char *userdata, char *buffer, int need, int want) {
51 i_reader_data *rd = (i_reader_data *)userdata;
55 dSP; dTARG = sv_newmortal();
56 /* thanks to Simon Cozens for help with the dTARG above */
66 count = perl_call_sv(rd->sv, G_SCALAR);
71 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
77 char *ptr = SvPV(data, len);
79 croak("Too much data returned in reader callback");
81 memcpy(buffer, ptr, len);
97 SV *sv; /* a coderef or sub name */
100 /* used by functions that want callbacks */
101 static int write_callback(char *userdata, char const *data, int size) {
102 i_writer_data *wd = (i_writer_data *)userdata;
112 XPUSHs(sv_2mortal(newSVpv((char *)data, size)));
115 count = perl_call_sv(wd->sv, G_SCALAR);
120 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
123 success = SvTRUE(sv);
133 #define CBDATA_BUFSIZE 8192
136 /* the SVs we use to call back to Perl */
142 /* we need to remember whether the buffer contains write data or
148 /* how far we've read into the buffer (not used for writing) */
151 /* the amount of space used/data available in the buffer */
154 /* the maximum amount to fill the buffer before flushing
155 If any write is larger than this then the buffer is flushed and
156 the full write is performed. The write is _not_ split into
161 char buffer[CBDATA_BUFSIZE];
166 call_writer(cbd, buf, size)
168 Low-level function to call the perl writer callback.
172 static ssize_t call_writer(struct cbdata *cbd, void const *buf, size_t size) {
178 if (!SvOK(cbd->writecb))
185 PUSHs(sv_2mortal(newSVpv((char *)buf, size)));
188 count = perl_call_sv(cbd->writecb, G_SCALAR);
192 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
195 success = SvTRUE(sv);
202 return success ? size : 0;
205 static ssize_t call_reader(struct cbdata *cbd, void *buf, size_t size,
212 if (!SvOK(cbd->readcb))
219 PUSHs(sv_2mortal(newSViv(size)));
220 PUSHs(sv_2mortal(newSViv(maxread)));
223 count = perl_call_sv(cbd->readcb, G_SCALAR);
228 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
234 char *ptr = SvPV(data, len);
236 croak("Too much data returned in reader callback");
238 memcpy(buf, ptr, len);
252 static ssize_t write_flush(struct cbdata *cbd) {
255 result = call_writer(cbd, cbd->buffer, cbd->used);
260 static off_t io_seeker(void *p, off_t offset, int whence) {
261 struct cbdata *cbd = p;
266 if (!SvOK(cbd->seekcb))
270 if (cbd->used && write_flush(cbd) <= 0)
274 if (whence == SEEK_CUR && cbd->reading && cbd->where != cbd->used) {
275 offset -= cbd->where - cbd->used;
278 cbd->where = cbd->used = 0;
284 PUSHs(sv_2mortal(newSViv(offset)));
285 PUSHs(sv_2mortal(newSViv(whence)));
288 count = perl_call_sv(cbd->seekcb, G_SCALAR);
293 croak("Result of perl_call_sv(..., G_SCALAR) != 1");
304 static ssize_t io_writer(void *p, void const *data, size_t size) {
305 struct cbdata *cbd = p;
307 /*printf("io_writer(%p, %p, %u)\n", p, data, size);*/
309 if (cbd->reading && cbd->where < cbd->used) {
310 /* we read past the place where the caller expected us to be
311 so adjust our position a bit */
313 if (io_seeker(p, cbd->where - cbd->used, SEEK_CUR) < 0) {
318 cbd->where = cbd->used = 0;
321 if (cbd->used && cbd->used + size > cbd->maxlength) {
322 if (write_flush(cbd) <= 0) {
327 if (cbd->used+size <= cbd->maxlength) {
328 memcpy(cbd->buffer + cbd->used, data, size);
332 /* it doesn't fit - just pass it up */
333 return call_writer(cbd, data, size);
336 static ssize_t io_reader(void *p, void *data, size_t size) {
337 struct cbdata *cbd = p;
339 char *out = data; /* so we can do pointer arithmetic */
343 if (write_flush(cbd) <= 0)
349 if (size <= cbd->used - cbd->where) {
351 memcpy(data, cbd->buffer+cbd->where, size);
356 memcpy(out, cbd->buffer + cbd->where, cbd->used - cbd->where);
357 total += cbd->used - cbd->where;
358 size -= cbd->used - cbd->where;
359 out += cbd->used - cbd->where;
360 if (size < sizeof(cbd->buffer)) {
364 && (did_read = call_reader(cbd, cbd->buffer, size,
365 sizeof(cbd->buffer))) > 0) {
367 cbd->used = did_read;
369 copy_size = min(size, cbd->used);
370 memcpy(out, cbd->buffer, copy_size);
371 cbd->where += copy_size;
378 /* just read the rest - too big for our buffer*/
380 while ((did_read = call_reader(cbd, out, size, size)) > 0) {
390 static void io_closer(void *p) {
391 struct cbdata *cbd = p;
393 if (cbd->writing && cbd->used > 0) {
398 if (SvOK(cbd->closecb)) {
406 perl_call_sv(cbd->closecb, G_VOID);
415 static void io_destroyer(void *p) {
416 struct cbdata *cbd = p;
418 SvREFCNT_dec(cbd->writecb);
419 SvREFCNT_dec(cbd->readcb);
420 SvREFCNT_dec(cbd->seekcb);
421 SvREFCNT_dec(cbd->closecb);
428 static int lookup_name(struct value_name *names, int count, char *name, int def_value)
431 for (i = 0; i < count; ++i)
432 if (strEQ(names[i].name, name))
433 return names[i].value;
437 static struct value_name transp_names[] =
440 { "threshold", tr_threshold },
441 { "errdiff", tr_errdiff },
442 { "ordered", tr_ordered, },
445 static struct value_name make_color_names[] =
447 { "none", mc_none, },
448 { "webmap", mc_web_map, },
449 { "addi", mc_addi, },
450 { "mediancut", mc_median_cut, },
453 static struct value_name translate_names[] =
456 { "giflib", pt_giflib, },
458 { "closest", pt_closest, },
459 { "perturb", pt_perturb, },
460 { "errdiff", pt_errdiff, },
463 static struct value_name errdiff_names[] =
465 { "floyd", ed_floyd, },
466 { "jarvis", ed_jarvis, },
467 { "stucki", ed_stucki, },
468 { "custom", ed_custom, },
471 static struct value_name orddith_names[] =
473 { "random", od_random, },
474 { "dot8", od_dot8, },
475 { "dot4", od_dot4, },
476 { "hline", od_hline, },
477 { "vline", od_vline, },
478 { "/line", od_slashline, },
479 { "slashline", od_slashline, },
480 { "\\line", od_backline, },
481 { "backline", od_backline, },
482 { "tiny", od_tiny, },
483 { "custom", od_custom, },
487 hv_fetch_bool(HV *hv, char *name, int def) {
490 sv = hv_fetch(hv, name, strlen(name), 0);
499 hv_fetch_int(HV *hv, char *name, int def) {
502 sv = hv_fetch(hv, name, strlen(name), 0);
510 /* look through the hash for quantization options */
511 static void handle_quant_opts(i_quantize *quant, HV *hv)
513 /*** POSSIBLY BROKEN: do I need to unref the SV from hv_fetch ***/
519 quant->mc_colors = mymalloc(quant->mc_size * sizeof(i_color));
521 sv = hv_fetch(hv, "transp", 6, 0);
522 if (sv && *sv && (str = SvPV(*sv, len))) {
524 lookup_name(transp_names, sizeof(transp_names)/sizeof(*transp_names),
526 if (quant->transp != tr_none) {
527 quant->tr_threshold = 127;
528 sv = hv_fetch(hv, "tr_threshold", 12, 0);
530 quant->tr_threshold = SvIV(*sv);
532 if (quant->transp == tr_errdiff) {
533 sv = hv_fetch(hv, "tr_errdiff", 10, 0);
534 if (sv && *sv && (str = SvPV(*sv, len)))
535 quant->tr_errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
537 if (quant->transp == tr_ordered) {
538 quant->tr_orddith = od_tiny;
539 sv = hv_fetch(hv, "tr_orddith", 10, 0);
540 if (sv && *sv && (str = SvPV(*sv, len)))
541 quant->tr_orddith = lookup_name(orddith_names, sizeof(orddith_names)/sizeof(*orddith_names), str, od_random);
543 if (quant->tr_orddith == od_custom) {
544 sv = hv_fetch(hv, "tr_map", 6, 0);
545 if (sv && *sv && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
546 AV *av = (AV*)SvRV(*sv);
547 len = av_len(av) + 1;
548 if (len > sizeof(quant->tr_custom))
549 len = sizeof(quant->tr_custom);
550 for (i = 0; i < len; ++i) {
551 SV **sv2 = av_fetch(av, i, 0);
553 quant->tr_custom[i] = SvIV(*sv2);
556 while (i < sizeof(quant->tr_custom))
557 quant->tr_custom[i++] = 0;
562 quant->make_colors = mc_addi;
563 sv = hv_fetch(hv, "make_colors", 11, 0);
564 if (sv && *sv && (str = SvPV(*sv, len))) {
566 lookup_name(make_color_names, sizeof(make_color_names)/sizeof(*make_color_names), str, mc_addi);
568 sv = hv_fetch(hv, "colors", 6, 0);
569 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
570 /* needs to be an array of Imager::Color
571 note that the caller allocates the mc_color array and sets mc_size
573 AV *av = (AV *)SvRV(*sv);
574 quant->mc_count = av_len(av)+1;
575 if (quant->mc_count > quant->mc_size)
576 quant->mc_count = quant->mc_size;
577 for (i = 0; i < quant->mc_count; ++i) {
578 SV **sv1 = av_fetch(av, i, 0);
579 if (sv1 && *sv1 && SvROK(*sv1) && sv_derived_from(*sv1, "Imager::Color")) {
580 i_color *col = (i_color *)SvIV((SV*)SvRV(*sv1));
581 quant->mc_colors[i] = *col;
585 sv = hv_fetch(hv, "max_colors", 10, 0);
588 if (i <= quant->mc_size && i >= quant->mc_count)
592 quant->translate = pt_closest;
593 sv = hv_fetch(hv, "translate", 9, 0);
594 if (sv && *sv && (str = SvPV(*sv, len))) {
595 quant->translate = lookup_name(translate_names, sizeof(translate_names)/sizeof(*translate_names), str, pt_closest);
597 sv = hv_fetch(hv, "errdiff", 7, 0);
598 if (sv && *sv && (str = SvPV(*sv, len))) {
599 quant->errdiff = lookup_name(errdiff_names, sizeof(errdiff_names)/sizeof(*errdiff_names), str, ed_floyd);
601 if (quant->translate == pt_errdiff && quant->errdiff == ed_custom) {
602 /* get the error diffusion map */
603 sv = hv_fetch(hv, "errdiff_width", 13, 0);
605 quant->ed_width = SvIV(*sv);
606 sv = hv_fetch(hv, "errdiff_height", 14, 0);
608 quant->ed_height = SvIV(*sv);
609 sv = hv_fetch(hv, "errdiff_orig", 12, 0);
611 quant->ed_orig = SvIV(*sv);
612 if (quant->ed_width > 0 && quant->ed_height > 0) {
614 quant->ed_map = mymalloc(sizeof(int)*quant->ed_width*quant->ed_height);
615 sv = hv_fetch(hv, "errdiff_map", 11, 0);
616 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
617 AV *av = (AV*)SvRV(*sv);
618 len = av_len(av) + 1;
619 if (len > quant->ed_width * quant->ed_height)
620 len = quant->ed_width * quant->ed_height;
621 for (i = 0; i < len; ++i) {
622 SV **sv2 = av_fetch(av, i, 0);
624 quant->ed_map[i] = SvIV(*sv2);
625 sum += quant->ed_map[i];
631 myfree(quant->ed_map);
633 quant->errdiff = ed_floyd;
637 sv = hv_fetch(hv, "perturb", 7, 0);
639 quant->perturb = SvIV(*sv);
642 static void cleanup_quant_opts(i_quantize *quant) {
643 myfree(quant->mc_colors);
645 myfree(quant->ed_map);
649 /* look through the hash for options to add to opts */
650 static void handle_gif_opts(i_gif_opts *opts, HV *hv)
654 /**((char *)0) = '\0';*/
655 opts->each_palette = hv_fetch_bool(hv, "gif_each_palette", 0);
656 opts->interlace = hv_fetch_bool(hv, "interlace", 0);
658 sv = hv_fetch(hv, "gif_delays", 10, 0);
659 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
660 AV *av = (AV*)SvRV(*sv);
661 opts->delay_count = av_len(av)+1;
662 opts->delays = mymalloc(sizeof(int) * opts->delay_count);
663 for (i = 0; i < opts->delay_count; ++i) {
664 SV *sv1 = *av_fetch(av, i, 0);
665 opts->delays[i] = SvIV(sv1);
668 sv = hv_fetch(hv, "gif_user_input", 14, 0);
669 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
670 AV *av = (AV*)SvRV(*sv);
671 opts->user_input_count = av_len(av)+1;
672 opts->user_input_flags = mymalloc(opts->user_input_count);
673 for (i = 0; i < opts->user_input_count; ++i) {
674 SV *sv1 = *av_fetch(av, i, 0);
675 opts->user_input_flags[i] = SvIV(sv1) != 0;
678 sv = hv_fetch(hv, "gif_disposal", 12, 0);
679 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
680 AV *av = (AV*)SvRV(*sv);
681 opts->disposal_count = av_len(av)+1;
682 opts->disposal = mymalloc(opts->disposal_count);
683 for (i = 0; i < opts->disposal_count; ++i) {
684 SV *sv1 = *av_fetch(av, i, 0);
685 opts->disposal[i] = SvIV(sv1);
688 sv = hv_fetch(hv, "gif_tran_color", 14, 0);
689 if (sv && *sv && SvROK(*sv) && sv_derived_from(*sv, "Imager::Color")) {
690 i_color *col = (i_color *)SvIV((SV *)SvRV(*sv));
691 opts->tran_color = *col;
693 sv = hv_fetch(hv, "gif_positions", 13, 0);
694 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
695 AV *av = (AV *)SvRV(*sv);
696 opts->position_count = av_len(av) + 1;
697 opts->positions = mymalloc(sizeof(i_gif_pos) * opts->position_count);
698 for (i = 0; i < opts->position_count; ++i) {
699 SV **sv2 = av_fetch(av, i, 0);
700 opts->positions[i].x = opts->positions[i].y = 0;
701 if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
702 AV *av2 = (AV*)SvRV(*sv2);
704 sv3 = av_fetch(av2, 0, 0);
706 opts->positions[i].x = SvIV(*sv3);
707 sv3 = av_fetch(av2, 1, 0);
709 opts->positions[i].y = SvIV(*sv3);
713 /* Netscape2.0 loop count extension */
714 opts->loop_count = hv_fetch_int(hv, "gif_loop_count", 0);
716 opts->eliminate_unused = hv_fetch_bool(hv, "gif_eliminate_unused", 1);
719 static void cleanup_gif_opts(i_gif_opts *opts) {
721 myfree(opts->delays);
722 if (opts->user_input_flags)
723 myfree(opts->user_input_flags);
725 myfree(opts->disposal);
727 myfree(opts->positions);
732 /* copies the color map from the hv into the colors member of the HV */
733 static void copy_colors_back(HV *hv, i_quantize *quant) {
739 sv = hv_fetch(hv, "colors", 6, 0);
740 if (!sv || !*sv || !SvROK(*sv) || SvTYPE(SvRV(*sv)) != SVt_PVAV) {
743 ref = newRV_inc((SV*) av);
744 sv = hv_store(hv, "colors", 6, ref, 0);
747 av = (AV *)SvRV(*sv);
749 av_extend(av, quant->mc_count+1);
750 for (i = 0; i < quant->mc_count; ++i) {
751 i_color *in = quant->mc_colors+i;
752 Imager__Color c = ICL_new_internal(in->rgb.r, in->rgb.g, in->rgb.b, 255);
753 work = sv_newmortal();
754 sv_setref_pv(work, "Imager::Color", (void *)c);
756 if (!av_store(av, i, work)) {
762 /* loads the segments of a fountain fill into an array */
763 i_fountain_seg *load_fount_segs(AV *asegs, int *count) {
764 /* Each element of segs must contain:
765 [ start, middle, end, c0, c1, segtype, colortrans ]
766 start, middle, end are doubles from 0 to 1
767 c0, c1 are Imager::Color::Float or Imager::Color objects
768 segtype, colortrans are ints
773 i_fountain_seg *segs;
777 *count = av_len(asegs)+1;
779 croak("i_fountain must have at least one segment");
780 segs = mymalloc(sizeof(i_fountain_seg) * *count);
781 for(i = 0; i < *count; i++) {
782 SV **sv1 = av_fetch(asegs, i, 0);
783 if (!sv1 || !*sv1 || !SvROK(*sv1)
784 || SvTYPE(SvRV(*sv1)) != SVt_PVAV) {
786 croak("i_fountain: segs must be an arrayref of arrayrefs");
788 aseg = (AV *)SvRV(*sv1);
789 if (av_len(aseg) != 7-1) {
791 croak("i_fountain: a segment must have 7 members");
793 for (j = 0; j < 3; ++j) {
794 SV **sv2 = av_fetch(aseg, j, 0);
797 croak("i_fountain: XS error");
799 work[j] = SvNV(*sv2);
801 segs[i].start = work[0];
802 segs[i].middle = work[1];
803 segs[i].end = work[2];
804 for (j = 0; j < 2; ++j) {
805 SV **sv3 = av_fetch(aseg, 3+j, 0);
806 if (!sv3 || !*sv3 || !SvROK(*sv3) ||
807 (!sv_derived_from(*sv3, "Imager::Color")
808 && !sv_derived_from(*sv3, "Imager::Color::Float"))) {
810 croak("i_fountain: segs must contain colors in elements 3 and 4");
812 if (sv_derived_from(*sv3, "Imager::Color::Float")) {
813 segs[i].c[j] = *(i_fcolor *)SvIV((SV *)SvRV(*sv3));
816 i_color c = *(i_color *)SvIV((SV *)SvRV(*sv3));
818 for (ch = 0; ch < MAXCHANNELS; ++ch) {
819 segs[i].c[j].channel[ch] = c.channel[ch] / 255.0;
823 for (j = 0; j < 2; ++j) {
824 SV **sv2 = av_fetch(aseg, j+5, 0);
827 croak("i_fountain: XS error");
829 worki[j] = SvIV(*sv2);
831 segs[i].type = worki[0];
832 segs[i].color = worki[1];
838 /* I don't think ICLF_* names belong at the C interface
839 this makes the XS code think we have them, to let us avoid
840 putting function bodies in the XS code
842 #define ICLF_new_internal(r, g, b, a) i_fcolor_new((r), (g), (b), (a))
843 #define ICLF_DESTROY(cl) i_fcolor_destroy(cl)
845 /* for the fill objects
846 Since a fill object may later have dependent images, (or fills!)
847 we need perl wrappers - oh well
849 #define IFILL_DESTROY(fill) i_fill_destroy(fill);
850 typedef i_fill_t* Imager__FillHandle;
852 MODULE = Imager PACKAGE = Imager::Color PREFIX = ICL_
855 ICL_new_internal(r,g,b,a)
867 ICL_set_internal(cl,r,g,b,a)
874 ICL_set_internal(cl, r, g, b, a);
888 PUSHs(sv_2mortal(newSVnv(cl->rgba.r)));
889 PUSHs(sv_2mortal(newSVnv(cl->rgba.g)));
890 PUSHs(sv_2mortal(newSVnv(cl->rgba.b)));
891 PUSHs(sv_2mortal(newSVnv(cl->rgba.a)));
897 RETVAL = mymalloc(sizeof(i_color));
899 i_hsv_to_rgb(RETVAL);
907 RETVAL = mymalloc(sizeof(i_color));
909 i_rgb_to_hsv(RETVAL);
915 MODULE = Imager PACKAGE = Imager::Color::Float PREFIX=ICLF_
918 ICLF_new_internal(r, g, b, a)
926 Imager::Color::Float cl
930 Imager::Color::Float cl
934 EXTEND(SP, MAXCHANNELS);
935 for (ch = 0; ch < MAXCHANNELS; ++ch) {
936 /* printf("%d: %g\n", ch, cl->channel[ch]); */
937 PUSHs(sv_2mortal(newSVnv(cl->channel[ch])));
941 ICLF_set_internal(cl,r,g,b,a)
942 Imager::Color::Float cl
957 Imager::Color::Float c
959 RETVAL = mymalloc(sizeof(i_fcolor));
961 i_hsv_to_rgbf(RETVAL);
967 Imager::Color::Float c
969 RETVAL = mymalloc(sizeof(i_fcolor));
971 i_rgb_to_hsvf(RETVAL);
976 MODULE = Imager PACKAGE = Imager::ImgRaw PREFIX = IIM_
990 MODULE = Imager PACKAGE = Imager
1010 SvPV(ST(0), length);
1011 SvREFCNT_inc(ST(0));
1012 RETVAL = io_new_buffer(data, length, my_SvREFCNT_dec, ST(0));
1017 io_new_cb(writecb, readcb, seekcb, closecb, maxwrite = CBDATA_BUFSIZE)
1026 cbd = mymalloc(sizeof(struct cbdata));
1027 SvREFCNT_inc(writecb);
1028 cbd->writecb = writecb;
1029 SvREFCNT_inc(readcb);
1030 cbd->readcb = readcb;
1031 SvREFCNT_inc(seekcb);
1032 cbd->seekcb = seekcb;
1033 SvREFCNT_inc(closecb);
1034 cbd->closecb = closecb;
1035 cbd->reading = cbd->writing = cbd->where = cbd->used = 0;
1036 if (maxwrite > CBDATA_BUFSIZE)
1037 maxwrite = CBDATA_BUFSIZE;
1038 cbd->maxlength = maxwrite;
1039 RETVAL = io_new_cb(cbd, io_reader, io_writer, io_seeker, io_closer,
1048 unsigned char* data;
1052 tlength = io_slurp(ig, &data);
1054 PUSHs(sv_2mortal(newSVpv(data,tlength)));
1058 MODULE = Imager PACKAGE = Imager::IO PREFIX = io_glue_
1065 MODULE = Imager PACKAGE = Imager
1078 while( (item=i_format_list[i++]) != NULL ) {
1080 PUSHs(sv_2mortal(newSVpv(item,0)));
1097 i_img_empty_ch(im,x,y,ch)
1104 init_log(name,level)
1109 log_entry(string,level)
1128 i_img_info(im,info);
1130 PUSHs(sv_2mortal(newSViv(info[0])));
1131 PUSHs(sv_2mortal(newSViv(info[1])));
1132 PUSHs(sv_2mortal(newSViv(info[2])));
1133 PUSHs(sv_2mortal(newSViv(info[3])));
1139 i_img_setmask(im,ch_mask)
1148 i_img_getchannels(im)
1156 PUSHs(im->idata ? sv_2mortal(newSVpv(im->idata, im->bytes))
1161 i_draw(im,x1,y1,x2,y2,val)
1170 i_line_aa(im,x1,y1,x2,y2,val)
1179 i_box(im,x1,y1,x2,y2,val)
1188 i_box_filled(im,x1,y1,x2,y2,val)
1197 i_box_cfill(im,x1,y1,x2,y2,fill)
1203 Imager::FillHandle fill
1206 i_arc(im,x,y,rad,d1,d2,val)
1216 i_arc_cfill(im,x,y,rad,d1,d2,fill)
1223 Imager::FillHandle fill
1228 i_circle_aa(im,x,y,rad,val)
1238 i_bezier_multi(im,xc,yc,val)
1251 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_bezier_multi must be a reference to an array\n");
1252 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_bezier_multi must be a reference to an array\n");
1253 if (!SvROK(ST(2))) croak("Imager: Parameter 2 to i_bezier_multi must be a reference to an array\n");
1254 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 to i_bezier_multi must be a reference to an array\n");
1255 av1=(AV*)SvRV(ST(1));
1256 av2=(AV*)SvRV(ST(2));
1257 if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_bezier_multi must be equal length\n");
1259 x=mymalloc( len*sizeof(double) );
1260 y=mymalloc( len*sizeof(double) );
1261 for(i=0;i<len;i++) {
1262 sv1=(*(av_fetch(av1,i,0)));
1263 sv2=(*(av_fetch(av2,i,0)));
1264 x[i]=(double)SvNV(sv1);
1265 y[i]=(double)SvNV(sv2);
1267 i_bezier_multi(im,len,x,y,val);
1273 i_poly_aa(im,xc,yc,val)
1286 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1287 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1288 if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1289 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
1290 av1=(AV*)SvRV(ST(1));
1291 av2=(AV*)SvRV(ST(2));
1292 if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_poly_aa must be equal length\n");
1294 x=mymalloc( len*sizeof(double) );
1295 y=mymalloc( len*sizeof(double) );
1296 for(i=0;i<len;i++) {
1297 sv1=(*(av_fetch(av1,i,0)));
1298 sv2=(*(av_fetch(av2,i,0)));
1299 x[i]=(double)SvNV(sv1);
1300 y[i]=(double)SvNV(sv2);
1302 i_poly_aa(im,len,x,y,val);
1307 i_poly_aa_cfill(im,xc,yc,fill)
1309 Imager::FillHandle fill
1319 if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1320 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1321 if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1322 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
1323 av1=(AV*)SvRV(ST(1));
1324 av2=(AV*)SvRV(ST(2));
1325 if (av_len(av1) != av_len(av2)) croak("Imager: x and y arrays to i_poly_aa_cfill must be equal length\n");
1327 x=mymalloc( len*sizeof(double) );
1328 y=mymalloc( len*sizeof(double) );
1329 for(i=0;i<len;i++) {
1330 sv1=(*(av_fetch(av1,i,0)));
1331 sv2=(*(av_fetch(av2,i,0)));
1332 x[i]=(double)SvNV(sv1);
1333 y[i]=(double)SvNV(sv2);
1335 i_poly_aa_cfill(im,len,x,y,fill);
1342 i_flood_fill(im,seedx,seedy,dcol)
1349 i_flood_cfill(im,seedx,seedy,fill)
1353 Imager::FillHandle fill
1357 i_copyto(im,src,x1,y1,x2,y2,tx,ty)
1369 i_copyto_trans(im,src,x1,y1,x2,y2,tx,ty,trans)
1387 i_rubthru(im,src,tx,ty)
1394 i_flipxy(im, direction)
1399 i_rotate90(im, degrees)
1404 i_rotate_exact(im, amount)
1409 i_matrix_transform(im, xsize, ysize, matrix)
1420 if (!SvROK(ST(3)) || SvTYPE(SvRV(ST(3))) != SVt_PVAV)
1421 croak("i_matrix_transform: parameter 4 must be an array ref\n");
1422 av=(AV*)SvRV(ST(3));
1426 for (i = 0; i < len; ++i) {
1427 sv1=(*(av_fetch(av,i,0)));
1428 matrix[i] = SvNV(sv1);
1432 RETVAL = i_matrix_transform(im, xsize, ysize, matrix);
1437 i_gaussian(im,stdev)
1442 i_unsharp_mask(im,stdev,scale)
1457 if (!SvROK(ST(1))) croak("Imager: Parameter 1 must be a reference to an array\n");
1458 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 must be a reference to an array\n");
1459 av=(AV*)SvRV(ST(1));
1461 coeff=mymalloc( len*sizeof(float) );
1462 for(i=0;i<len;i++) {
1463 sv1=(*(av_fetch(av,i,0)));
1464 coeff[i]=(float)SvNV(sv1);
1466 i_conv(im,coeff,len);
1470 i_convert(im, src, coeff)
1484 if (!SvROK(ST(2)) || SvTYPE(SvRV(ST(2))) != SVt_PVAV)
1485 croak("i_convert: parameter 3 must be an arrayref\n");
1486 avmain = (AV*)SvRV(ST(2));
1487 outchan = av_len(avmain)+1;
1488 /* find the biggest */
1490 for (j=0; j < outchan; ++j) {
1491 temp = av_fetch(avmain, j, 0);
1492 if (temp && SvROK(*temp) && SvTYPE(SvRV(*temp)) == SVt_PVAV) {
1493 avsub = (AV*)SvRV(*temp);
1494 len = av_len(avsub)+1;
1499 coeff = mymalloc(sizeof(float) * outchan * inchan);
1500 for (j = 0; j < outchan; ++j) {
1501 avsub = (AV*)SvRV(*av_fetch(avmain, j, 0));
1502 len = av_len(avsub)+1;
1503 for (i = 0; i < len; ++i) {
1504 temp = av_fetch(avsub, i, 0);
1506 coeff[i+j*inchan] = SvNV(*temp);
1508 coeff[i+j*inchan] = 0;
1511 coeff[i++ + j*inchan] = 0;
1513 RETVAL = i_convert(im, src, coeff, outchan, inchan);
1523 unsigned int mask = 0;
1529 unsigned char (*maps)[256];
1531 if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
1532 croak("i_map: parameter 2 must be an arrayref\n");
1533 avmain = (AV*)SvRV(ST(1));
1534 len = av_len(avmain)+1;
1535 if (im->channels < len) len = im->channels;
1537 maps = mymalloc( len * sizeof(unsigned char [256]) );
1539 for (j=0; j<len ; j++) {
1540 temp = av_fetch(avmain, j, 0);
1541 if (temp && SvROK(*temp) && (SvTYPE(SvRV(*temp)) == SVt_PVAV) ) {
1542 avsub = (AV*)SvRV(*temp);
1543 if(av_len(avsub) != 255) continue;
1545 for (i=0; i<256 ; i++) {
1547 temp = av_fetch(avsub, i, 0);
1548 val = temp ? SvIV(*temp) : 0;
1550 if (val>255) val = 255;
1555 i_map(im, maps, mask);
1568 i_init_fonts(t1log=0)
1583 i_t1_destroy(font_id)
1588 i_t1_cp(im,xb,yb,channel,fontnum,points,str,len,align)
1600 i_t1_bbox(fontnum,point,str,len)
1608 i_t1_bbox(fontnum,point,str,len,cords);
1610 PUSHs(sv_2mortal(newSViv(cords[0])));
1611 PUSHs(sv_2mortal(newSViv(cords[1])));
1612 PUSHs(sv_2mortal(newSViv(cords[2])));
1613 PUSHs(sv_2mortal(newSViv(cords[3])));
1614 PUSHs(sv_2mortal(newSViv(cords[4])));
1615 PUSHs(sv_2mortal(newSViv(cords[5])));
1620 i_t1_text(im,xb,yb,cl,fontnum,points,str,len,align)
1641 MODULE = Imager PACKAGE = Imager::Font::TT PREFIX=TT_
1643 #define TT_DESTROY(handle) i_tt_destroy(handle)
1647 Imager::Font::TT handle
1650 MODULE = Imager PACKAGE = Imager
1654 i_tt_text(handle,im,xb,yb,cl,points,str,len,smooth)
1655 Imager::Font::TT handle
1667 i_tt_cp(handle,im,xb,yb,channel,points,str,len,smooth)
1668 Imager::Font::TT handle
1681 i_tt_bbox(handle,point,str,len)
1682 Imager::Font::TT handle
1689 if ((rc=i_tt_bbox(handle,point,str,len,cords))) {
1691 PUSHs(sv_2mortal(newSViv(cords[0])));
1692 PUSHs(sv_2mortal(newSViv(cords[1])));
1693 PUSHs(sv_2mortal(newSViv(cords[2])));
1694 PUSHs(sv_2mortal(newSViv(cords[3])));
1695 PUSHs(sv_2mortal(newSViv(cords[4])));
1696 PUSHs(sv_2mortal(newSViv(cords[5])));
1707 i_writejpeg_wiol(im, ig, qfactor)
1723 rimg = i_readjpeg_wiol(ig,-1,&iptc_itext,&tlength);
1724 if (iptc_itext == NULL) {
1727 sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
1732 sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
1734 PUSHs(sv_2mortal(newSVpv(iptc_itext,tlength)));
1747 i_readtiff_wiol(ig, length)
1752 i_readtiff_multi_wiol(ig, length)
1760 imgs = i_readtiff_multi_wiol(ig, length, &count);
1763 for (i = 0; i < count; ++i) {
1764 SV *sv = sv_newmortal();
1765 sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
1773 i_writetiff_wiol(im, ig)
1778 i_writetiff_multi_wiol(ig, ...)
1786 croak("Usage: i_writetiff_multi_wiol(ig, images...)");
1787 img_count = items - 1;
1789 if (img_count < 1) {
1792 i_push_error(0, "You need to specify images to save");
1795 imgs = mymalloc(sizeof(i_img *) * img_count);
1796 for (i = 0; i < img_count; ++i) {
1799 if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
1800 imgs[i] = (i_img *)SvIV((SV*)SvRV(sv));
1804 i_push_error(0, "Only images can be saved");
1811 RETVAL = i_writetiff_multi_wiol(ig, imgs, img_count);
1819 i_writetiff_wiol_faxable(im, ig, fine)
1825 i_writetiff_multi_wiol_faxable(ig, fine, ...)
1834 croak("Usage: i_writetiff_multi_wiol_faxable(ig, fine, images...)");
1835 img_count = items - 2;
1837 if (img_count < 1) {
1840 i_push_error(0, "You need to specify images to save");
1843 imgs = mymalloc(sizeof(i_img *) * img_count);
1844 for (i = 0; i < img_count; ++i) {
1847 if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
1848 imgs[i] = (i_img *)SvIV((SV*)SvRV(sv));
1852 i_push_error(0, "Only images can be saved");
1859 RETVAL = i_writetiff_multi_wiol_faxable(ig, imgs, img_count, fine);
1867 #endif /* HAVE_LIBTIFF */
1873 i_readpng_wiol(ig, length)
1879 i_writepng_wiol(im, ig)
1892 PUSHs(sv_2mortal(newSVnv(IM_GIFMAJOR+IM_GIFMINOR*0.1)));
1895 i_writegif(im,fd,colors,pixdev,fixed)
1902 Imager__Color fixed;
1909 if (!SvROK(ST(4))) croak("Imager: Parameter 4 must be a reference to an array\n");
1910 if (SvTYPE(SvRV(ST(4))) != SVt_PVAV) croak("Imager: Parameter 4 must be a reference to an array\n");
1911 av=(AV*)SvRV(ST(4));
1912 fixedlen=av_len(av)+1;
1913 fixed=mymalloc( fixedlen*sizeof(i_color) );
1914 for(i=0;i<fixedlen;i++) {
1915 sv1=(*(av_fetch(av,i,0)));
1916 if (sv_derived_from(sv1, "Imager::Color")) {
1917 Itmp = SvIV((SV*)SvRV(sv1));
1918 tmp = (i_color*) Itmp;
1919 } else croak("Imager: one of the elements of array ref is not of Imager::Color type\n");
1922 RETVAL=i_writegif(im,fd,colors,pixdev,fixedlen,fixed);
1924 ST(0) = sv_newmortal();
1925 if (RETVAL == 0) ST(0)=&PL_sv_undef;
1926 else sv_setiv(ST(0), (IV)RETVAL);
1932 i_writegifmc(im,fd,colors)
1939 i_writegif_gen(fd, ...)
1944 i_img **imgs = NULL;
1950 croak("Usage: i_writegif_gen(fd,hashref, images...)");
1951 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
1952 croak("i_writegif_gen: Second argument must be a hash ref");
1953 hv = (HV *)SvRV(ST(1));
1954 memset(&quant, 0, sizeof(quant));
1955 quant.mc_size = 256;
1956 handle_quant_opts(&quant, hv);
1957 img_count = items - 2;
1959 if (img_count < 1) {
1962 i_push_error(0, "You need to specify images to save");
1965 imgs = mymalloc(sizeof(i_img *) * img_count);
1966 for (i = 0; i < img_count; ++i) {
1969 if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
1970 imgs[i] = (i_img *)SvIV((SV*)SvRV(sv));
1974 i_push_error(0, "Only images can be saved");
1980 RETVAL = i_writegif_gen(&quant, fd, imgs, img_count);
1984 copy_colors_back(hv, &quant);
1987 ST(0) = sv_newmortal();
1988 if (RETVAL == 0) ST(0)=&PL_sv_undef;
1989 else sv_setiv(ST(0), (IV)RETVAL);
1990 cleanup_quant_opts(&quant);
1994 i_writegif_callback(cb, maxbuffer,...)
1998 i_img **imgs = NULL;
2005 croak("Usage: i_writegif_callback(\\&callback,maxbuffer,hashref, images...)");
2006 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
2007 croak("i_writegif_callback: Second argument must be a hash ref");
2008 hv = (HV *)SvRV(ST(2));
2009 memset(&quant, 0, sizeof(quant));
2010 quant.mc_size = 256;
2011 handle_quant_opts(&quant, hv);
2012 img_count = items - 3;
2014 if (img_count < 1) {
2018 imgs = mymalloc(sizeof(i_img *) * img_count);
2019 for (i = 0; i < img_count; ++i) {
2022 if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
2023 imgs[i] = (i_img *)SvIV((SV*)SvRV(sv));
2032 RETVAL = i_writegif_callback(&quant, write_callback, (char *)&wd, maxbuffer, imgs, img_count);
2036 copy_colors_back(hv, &quant);
2039 ST(0) = sv_newmortal();
2040 if (RETVAL == 0) ST(0)=&PL_sv_undef;
2041 else sv_setiv(ST(0), (IV)RETVAL);
2042 cleanup_quant_opts(&quant);
2045 i_writegif_wiol(ig, opts,...)
2049 i_img **imgs = NULL;
2055 croak("Usage: i_writegif_wiol(IO,hashref, images...)");
2056 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2057 croak("i_writegif_callback: Second argument must be a hash ref");
2058 hv = (HV *)SvRV(ST(1));
2059 memset(&quant, 0, sizeof(quant));
2060 quant.mc_size = 256;
2061 handle_quant_opts(&quant, hv);
2062 img_count = items - 2;
2064 if (img_count < 1) {
2068 imgs = mymalloc(sizeof(i_img *) * img_count);
2069 for (i = 0; i < img_count; ++i) {
2072 if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
2073 imgs[i] = (i_img *)SvIV((SV*)SvRV(sv));
2081 RETVAL = i_writegif_wiol(ig, &quant, imgs, img_count);
2085 copy_colors_back(hv, &quant);
2088 ST(0) = sv_newmortal();
2089 if (RETVAL == 0) ST(0)=&PL_sv_undef;
2090 else sv_setiv(ST(0), (IV)RETVAL);
2091 cleanup_quant_opts(&quant);
2104 colour_table = NULL;
2107 if(GIMME_V == G_ARRAY) {
2108 rimg = i_readgif(fd,&colour_table,&colours);
2110 /* don't waste time with colours if they aren't wanted */
2111 rimg = i_readgif(fd,NULL,NULL);
2114 if (colour_table == NULL) {
2117 sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
2120 /* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
2121 /* I don't know if I have the reference counts right or not :( */
2122 /* Neither do I :-) */
2123 /* No Idea here either */
2126 av_extend(ct, colours);
2127 for(q=0; q<colours; q++) {
2129 temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
2130 av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
2132 myfree(colour_table);
2136 sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
2138 PUSHs(newRV_noinc((SV*)ct));
2152 colour_table = NULL;
2155 if(GIMME_V == G_ARRAY) {
2156 rimg = i_readgif_wiol(ig,&colour_table,&colours);
2158 /* don't waste time with colours if they aren't wanted */
2159 rimg = i_readgif_wiol(ig,NULL,NULL);
2162 if (colour_table == NULL) {
2165 sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
2168 /* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
2169 /* I don't know if I have the reference counts right or not :( */
2170 /* Neither do I :-) */
2171 /* No Idea here either */
2174 av_extend(ct, colours);
2175 for(q=0; q<colours; q++) {
2177 temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
2178 av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
2180 myfree(colour_table);
2184 sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
2186 PUSHs(newRV_noinc((SV*)ct));
2190 i_readgif_scalar(...)
2194 unsigned int length;
2202 data = (char *)SvPV(ST(0), length);
2206 if(GIMME_V == G_ARRAY) {
2207 rimg=i_readgif_scalar(data,length,&colour_table,&colours);
2209 /* don't waste time with colours if they aren't wanted */
2210 rimg=i_readgif_scalar(data,length,NULL,NULL);
2213 if (colour_table == NULL) {
2216 sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
2219 /* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
2220 /* I don't know if I have the reference counts right or not :( */
2221 /* Neither do I :-) */
2223 av_extend(ct, colours);
2224 for(q=0; q<colours; q++) {
2226 temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
2227 av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
2229 myfree(colour_table);
2233 sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
2235 PUSHs(newRV_noinc((SV*)ct));
2239 i_readgif_callback(...)
2256 if(GIMME_V == G_ARRAY) {
2257 rimg=i_readgif_callback(read_callback, (char *)&rd,&colour_table,&colours);
2259 /* don't waste time with colours if they aren't wanted */
2260 rimg=i_readgif_callback(read_callback, (char *)&rd,NULL,NULL);
2263 if (colour_table == NULL) {
2266 sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
2269 /* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
2270 /* I don't know if I have the reference counts right or not :( */
2271 /* Neither do I :-) */
2272 /* Neither do I - maybe I'll move this somewhere */
2274 av_extend(ct, colours);
2275 for(q=0; q<colours; q++) {
2277 temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
2278 av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
2280 myfree(colour_table);
2284 sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
2286 PUSHs(newRV_noinc((SV*)ct));
2297 imgs = i_readgif_multi(fd, &count);
2300 for (i = 0; i < count; ++i) {
2301 SV *sv = sv_newmortal();
2302 sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
2309 i_readgif_multi_scalar(data)
2314 unsigned int length;
2317 data = (char *)SvPV(ST(0), length);
2318 imgs = i_readgif_multi_scalar(data, length, &count);
2321 for (i = 0; i < count; ++i) {
2322 SV *sv = sv_newmortal();
2323 sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
2330 i_readgif_multi_callback(cb)
2338 imgs = i_readgif_multi_callback(read_callback, (char *)&rd, &count);
2341 for (i = 0; i < count; ++i) {
2342 SV *sv = sv_newmortal();
2343 sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
2350 i_readgif_multi_wiol(ig)
2357 imgs = i_readgif_multi_wiol(ig, &count);
2360 for (i = 0; i < count; ++i) {
2361 SV *sv = sv_newmortal();
2362 sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
2374 i_readpnm_wiol(ig, length)
2380 i_writeppm_wiol(im, ig)
2386 i_readraw_wiol(ig,x,y,datachannels,storechannels,intrl)
2395 i_writeraw_wiol(im,ig)
2400 i_writebmp_wiol(im,ig)
2410 i_writetga_wiol(im,ig, wierdpack, compress, idstring)
2421 idlen = SvCUR(ST(4));
2422 RETVAL = i_writetga_wiol(im, ig, wierdpack, compress, idstring, idlen);
2428 i_readtga_wiol(ig, length)
2434 i_writergb_wiol(im,ig, wierdpack, compress, idstring)
2445 idlen = SvCUR(ST(4));
2446 RETVAL = i_writergb_wiol(im, ig, wierdpack, compress, idstring, idlen);
2452 i_readrgb_wiol(ig, length)
2459 i_scaleaxis(im,Value,Axis)
2465 i_scale_nn(im,scx,scy)
2475 i_count_colors(im,maxc)
2481 i_transform(im,opx,opy,parm)
2494 if (!SvROK(ST(1))) croak("Imager: Parameter 1 must be a reference to an array\n");
2495 if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to an array\n");
2496 if (!SvROK(ST(3))) croak("Imager: Parameter 3 must be a reference to an array\n");
2497 if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 must be a reference to an array\n");
2498 if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 must be a reference to an array\n");
2499 if (SvTYPE(SvRV(ST(3))) != SVt_PVAV) croak("Imager: Parameter 3 must be a reference to an array\n");
2500 av=(AV*)SvRV(ST(1));
2502 opx=mymalloc( opxl*sizeof(int) );
2503 for(i=0;i<opxl;i++) {
2504 sv1=(*(av_fetch(av,i,0)));
2505 opx[i]=(int)SvIV(sv1);
2507 av=(AV*)SvRV(ST(2));
2509 opy=mymalloc( opyl*sizeof(int) );
2510 for(i=0;i<opyl;i++) {
2511 sv1=(*(av_fetch(av,i,0)));
2512 opy[i]=(int)SvIV(sv1);
2514 av=(AV*)SvRV(ST(3));
2515 parmlen=av_len(av)+1;
2516 parm=mymalloc( parmlen*sizeof(double) );
2517 for(i=0;i<parmlen;i++) { /* FIXME: Bug? */
2518 sv1=(*(av_fetch(av,i,0)));
2519 parm[i]=(double)SvNV(sv1);
2521 RETVAL=i_transform(im,opx,opxl,opy,opyl,parm,parmlen);
2525 ST(0) = sv_newmortal();
2526 if (RETVAL == 0) ST(0)=&PL_sv_undef;
2527 else sv_setref_pv(ST(0), "Imager::ImgRaw", (void*)RETVAL);
2530 i_transform2(width,height,ops,n_regs,c_regs,in_imgs)
2549 if (!SvROK(ST(3))) croak("Imager: Parameter 4 must be a reference to an array\n");
2550 if (!SvROK(ST(4))) croak("Imager: Parameter 5 must be a reference to an array\n");
2551 if (!SvROK(ST(5))) croak("Imager: Parameter 6 must be a reference to an array of images\n");
2552 if (SvTYPE(SvRV(ST(3))) != SVt_PVAV) croak("Imager: Parameter 4 must be a reference to an array\n");
2553 if (SvTYPE(SvRV(ST(4))) != SVt_PVAV) croak("Imager: Parameter 5 must be a reference to an array\n");
2555 /*if (SvTYPE(SvRV(ST(5))) != SVt_PVAV) croak("Imager: Parameter 6 must be a reference to an array\n");*/
2557 if (SvTYPE(SvRV(ST(5))) == SVt_PVAV) {
2558 av = (AV*)SvRV(ST(5));
2559 in_imgs_count = av_len(av)+1;
2560 for (i = 0; i < in_imgs_count; ++i) {
2561 sv1 = *av_fetch(av, i, 0);
2562 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2563 croak("Parameter 5 must contain only images");
2570 if (in_imgs_count > 0) {
2571 av = (AV*)SvRV(ST(5));
2572 in_imgs = mymalloc(in_imgs_count*sizeof(i_img*));
2573 for (i = 0; i < in_imgs_count; ++i) {
2574 sv1 = *av_fetch(av,i,0);
2575 if (!sv_derived_from(sv1, "Imager::ImgRaw")) {
2576 croak("Parameter 5 must contain only images");
2578 tmp = SvIV((SV*)SvRV(sv1));
2579 in_imgs[i] = (i_img*)tmp;
2583 /* no input images */
2586 /* default the output size from the first input if possible */
2588 width = SvIV(ST(0));
2589 else if (in_imgs_count)
2590 width = in_imgs[0]->xsize;
2592 croak("No output image width supplied");
2595 height = SvIV(ST(1));
2596 else if (in_imgs_count)
2597 height = in_imgs[0]->ysize;
2599 croak("No output image height supplied");
2601 ops = (struct rm_op *)SvPV(ST(2), ops_len);
2602 if (ops_len % sizeof(struct rm_op))
2603 croak("Imager: Parameter 3 must be a bitmap of regops\n");
2604 ops_count = ops_len / sizeof(struct rm_op);
2605 av = (AV*)SvRV(ST(3));
2606 n_regs_count = av_len(av)+1;
2607 n_regs = mymalloc(n_regs_count * sizeof(double));
2608 for (i = 0; i < n_regs_count; ++i) {
2609 sv1 = *av_fetch(av,i,0);
2611 n_regs[i] = SvNV(sv1);
2613 av = (AV*)SvRV(ST(4));
2614 c_regs_count = av_len(av)+1;
2615 c_regs = mymalloc(c_regs_count * sizeof(i_color));
2616 /* I don't bother initializing the colou?r registers */
2618 RETVAL=i_transform2(width, height, 3, ops, ops_count,
2619 n_regs, n_regs_count,
2620 c_regs, c_regs_count, in_imgs, in_imgs_count);
2625 ST(0) = sv_newmortal();
2626 if (RETVAL == 0) ST(0)=&PL_sv_undef;
2627 else sv_setref_pv(ST(0), "Imager::ImgRaw", (void*)RETVAL);
2631 i_contrast(im,intensity)
2640 i_noise(im,amount,type)
2646 i_bumpmap(im,bump,channel,light_x,light_y,strength)
2656 i_bumpmap_complex(im,bump,channel,tx,ty,Lx,Ly,Lz,cd,cs,n,Ia,Il,Is)
2675 i_postlevels(im,levels)
2685 i_watermark(im,wmark,tx,ty,pixdiff)
2687 Imager::ImgRaw wmark
2694 i_autolevels(im,lsat,usat,skew)
2701 i_radnoise(im,xo,yo,rscale,ascale)
2709 i_turbnoise(im, xo, yo, scale)
2732 croak("Usage: i_gradgen(im, xo, yo, ival, dmeasure)");
2733 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2734 croak("i_gradgen: Second argument must be an array ref");
2735 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
2736 croak("i_gradgen: Third argument must be an array ref");
2737 if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
2738 croak("i_gradgen: Fourth argument must be an array ref");
2739 axx = (AV *)SvRV(ST(1));
2740 ayy = (AV *)SvRV(ST(2));
2741 ac = (AV *)SvRV(ST(3));
2742 dmeasure = (int)SvIV(ST(4));
2744 num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
2745 num = num <= av_len(ac) ? num : av_len(ac);
2747 if (num < 2) croak("Usage: i_gradgen array refs must have more than 1 entry each");
2748 xo = mymalloc( sizeof(int) * num );
2749 yo = mymalloc( sizeof(int) * num );
2750 ival = mymalloc( sizeof(i_color) * num );
2751 for(i = 0; i<num; i++) {
2752 xo[i] = (int)SvIV(* av_fetch(axx, i, 0));
2753 yo[i] = (int)SvIV(* av_fetch(ayy, i, 0));
2754 sv = *av_fetch(ac, i, 0);
2755 if ( !sv_derived_from(sv, "Imager::Color") ) {
2756 free(axx); free(ayy); free(ac);
2757 croak("i_gradgen: Element of fourth argument is not derived from Imager::Color");
2759 ival[i] = *(i_color *)SvIV((SV *)SvRV(sv));
2761 i_gradgen(im, num, xo, yo, ival, dmeasure);
2768 i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2778 double ssample_param
2782 i_fountain_seg *segs;
2784 if (!SvROK(ST(10)) || ! SvTYPE(SvRV(ST(10))))
2785 croak("i_fountain: argument 11 must be an array ref");
2787 asegs = (AV *)SvRV(ST(10));
2788 segs = load_fount_segs(asegs, &count);
2789 i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample,
2790 ssample_param, count, segs);
2794 i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
2803 double ssample_param
2807 i_fountain_seg *segs;
2809 if (!SvROK(ST(9)) || ! SvTYPE(SvRV(ST(9))))
2810 croak("i_fountain: argument 11 must be an array ref");
2812 asegs = (AV *)SvRV(ST(9));
2813 segs = load_fount_segs(asegs, &count);
2814 RETVAL = i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine,
2815 super_sample, ssample_param, count, segs);
2829 errors = i_errors();
2831 while (errors[i].msg) {
2833 sv = newSVpv(errors[i].msg, strlen(errors[i].msg));
2834 if (!av_store(av, 0, sv)) {
2837 sv = newSViv(errors[i].code);
2838 if (!av_store(av, 1, sv)) {
2841 PUSHs(sv_2mortal(newRV_noinc((SV*)av)));
2846 i_nearest_color(im, ...)
2861 croak("Usage: i_nearest_color(im, xo, yo, ival, dmeasure)");
2862 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
2863 croak("i_nearest_color: Second argument must be an array ref");
2864 if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
2865 croak("i_nearest_color: Third argument must be an array ref");
2866 if (!SvROK(ST(3)) || ! SvTYPE(SvRV(ST(3))))
2867 croak("i_nearest_color: Fourth argument must be an array ref");
2868 axx = (AV *)SvRV(ST(1));
2869 ayy = (AV *)SvRV(ST(2));
2870 ac = (AV *)SvRV(ST(3));
2871 dmeasure = (int)SvIV(ST(4));
2873 num = av_len(axx) < av_len(ayy) ? av_len(axx) : av_len(ayy);
2874 num = num <= av_len(ac) ? num : av_len(ac);
2876 if (num < 2) croak("Usage: i_nearest_color array refs must have more than 1 entry each");
2877 xo = mymalloc( sizeof(int) * num );
2878 yo = mymalloc( sizeof(int) * num );
2879 ival = mymalloc( sizeof(i_color) * num );
2880 for(i = 0; i<num; i++) {
2881 xo[i] = (int)SvIV(* av_fetch(axx, i, 0));
2882 yo[i] = (int)SvIV(* av_fetch(ayy, i, 0));
2883 sv = *av_fetch(ac, i, 0);
2884 if ( !sv_derived_from(sv, "Imager::Color") ) {
2885 free(axx); free(ayy); free(ac);
2886 croak("i_nearest_color: Element of fourth argument is not derived from Imager::Color");
2888 ival[i] = *(i_color *)SvIV((SV *)SvRV(sv));
2890 i_nearest_color(im, num, xo, yo, ival, dmeasure);
2904 if (!SvROK(ST(0))) croak("Imager: Parameter 0 must be a reference to a hash\n");
2905 hv=(HV*)SvRV(ST(0));
2906 if (SvTYPE(hv)!=SVt_PVHV) croak("Imager: Parameter 0 must be a reference to a hash\n");
2907 if (getint(hv,"stuff",&stuff)) printf("ok: %d\n",stuff); else printf("key doesn't exist\n");
2908 if (getint(hv,"stuff2",&stuff)) printf("ok: %d\n",stuff); else printf("key doesn't exist\n");
2917 rc=DSO_open(filename,&evstr);
2921 PUSHs(sv_2mortal(newSViv((IV)rc)));
2922 PUSHs(sv_2mortal(newSVpvn(evstr, strlen(evstr))));
2925 PUSHs(sv_2mortal(newSViv((IV)rc)));
2931 DSO_close(dso_handle)
2935 DSO_funclist(dso_handle_v)
2939 DSO_handle *dso_handle;
2941 dso_handle=(DSO_handle*)dso_handle_v;
2943 while( dso_handle->function_list[i].name != NULL) {
2945 PUSHs(sv_2mortal(newSVpv(dso_handle->function_list[i].name,0)));
2947 PUSHs(sv_2mortal(newSVpv(dso_handle->function_list[i++].pcode,0)));
2952 DSO_call(handle,func_index,hv)
2958 if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to a hash\n");
2959 hv=(HV*)SvRV(ST(2));
2960 if (SvTYPE(hv)!=SVt_PVHV) croak("Imager: Parameter 2 must be a reference to a hash\n");
2961 DSO_call( (DSO_handle *)handle,func_index,hv);
2965 # this is mostly for testing...
2967 i_get_pixel(im, x, y)
2974 color = (i_color *)mymalloc(sizeof(i_color));
2975 if (i_gpix(im, x, y, color) == 0) {
2976 ST(0) = sv_newmortal();
2977 sv_setref_pv(ST(0), "Imager::Color", (void *)color);
2981 ST(0) = &PL_sv_undef;
2986 i_ppix(im, x, y, cl)
2993 i_img_pal_new(x, y, channels, maxpal)
3000 i_img_to_pal(src, quant)
3006 if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
3007 croak("i_img_to_pal: second argument must be a hash ref");
3008 hv = (HV *)SvRV(ST(1));
3009 memset(&quant, 0, sizeof(quant));
3010 quant.mc_size = 256;
3011 handle_quant_opts(&quant, hv);
3012 RETVAL = i_img_to_pal(src, &quant);
3014 copy_colors_back(hv, &quant);
3016 cleanup_quant_opts(&quant);
3035 work = mymalloc((r-l) * sizeof(i_palidx));
3036 count = i_gpal(im, l, r, y, work);
3037 if (GIMME_V == G_ARRAY) {
3039 for (i = 0; i < count; ++i) {
3040 PUSHs(sv_2mortal(newSViv(work[i])));
3045 PUSHs(sv_2mortal(newSVpv(work, count * sizeof(i_palidx))));
3050 if (GIMME_V != G_ARRAY) {
3052 PUSHs(&PL_sv_undef);
3057 i_ppal(im, l, y, ...)
3066 work = mymalloc(sizeof(i_palidx) * (items-3));
3067 for (i=0; i < items-3; ++i) {
3068 work[i] = SvIV(ST(i+3));
3070 RETVAL = i_ppal(im, l, l+items-3, y, work);
3080 i_addcolors(im, ...)
3088 croak("i_addcolors: no colors to add");
3089 colors = mymalloc((items-1) * sizeof(i_color));
3090 for (i=0; i < items-1; ++i) {
3091 if (sv_isobject(ST(i+1))
3092 && sv_derived_from(ST(i+1), "Imager::Color")) {
3093 IV tmp = SvIV((SV *)SvRV(ST(i+1)));
3094 colors[i] = *(i_color *)tmp;
3098 croak("i_plin: pixels must be Imager::Color objects");
3101 index = i_addcolors(im, colors, items-1);
3104 ST(0) = sv_2mortal(newSVpv("0 but true", 0));
3106 else if (index == -1) {
3107 ST(0) = &PL_sv_undef;
3110 ST(0) = sv_2mortal(newSViv(index));
3114 i_setcolors(im, index, ...)
3122 croak("i_setcolors: no colors to add");
3123 colors = mymalloc((items-2) * sizeof(i_color));
3124 for (i=0; i < items-2; ++i) {
3125 if (sv_isobject(ST(i+2))
3126 && sv_derived_from(ST(i+2), "Imager::Color")) {
3127 IV tmp = SvIV((SV *)SvRV(ST(i+2)));
3128 colors[i] = *(i_color *)tmp;
3132 croak("i_setcolors: pixels must be Imager::Color objects");
3135 RETVAL = i_setcolors(im, index, colors, items-2);
3139 i_getcolors(im, index, ...)
3148 croak("i_getcolors: too many arguments");
3150 count = SvIV(ST(2));
3152 croak("i_getcolors: count must be positive");
3153 colors = mymalloc(sizeof(i_color) * count);
3154 if (i_getcolors(im, index, colors, count)) {
3155 for (i = 0; i < count; ++i) {
3157 SV *sv = sv_newmortal();
3158 pv = mymalloc(sizeof(i_color));
3160 sv_setref_pv(sv, "Imager::Color", (void *)pv);
3173 count = i_colorcount(im);
3175 ST(0) = sv_2mortal(newSViv(count));
3178 ST(0) = &PL_sv_undef;
3187 count = i_maxcolors(im);
3189 ST(0) = sv_2mortal(newSViv(count));
3192 ST(0) = &PL_sv_undef;
3196 i_findcolor(im, color)
3202 if (i_findcolor(im, color, &index)) {
3203 ST(0) = sv_2mortal(newSViv(index));
3206 ST(0) = &PL_sv_undef;
3222 i_gsamp(im, l, r, y, ...)
3234 croak("No channel numbers supplied to g_samp()");
3236 chan_count = items - 4;
3237 chans = mymalloc(sizeof(int) * chan_count);
3238 for (i = 0; i < chan_count; ++i)
3239 chans[i] = SvIV(ST(i+4));
3240 data = mymalloc(sizeof(i_sample_t) * (r-l) * chan_count); /* XXX: memleak? */
3241 count = i_gsamp(im, l, r, y, data, chans, chan_count);
3243 if (GIMME_V == G_ARRAY) {
3245 for (i = 0; i < count; ++i)
3246 PUSHs(sv_2mortal(newSViv(data[i])));
3250 PUSHs(sv_2mortal(newSVpv(data, count * sizeof(i_sample_t))));
3255 if (GIMME_V != G_ARRAY) {
3257 PUSHs(&PL_sv_undef);
3263 i_img_masked_new(targ, mask, x, y, w, h)
3273 if (!sv_isobject(ST(1))
3274 || !sv_derived_from(ST(1), "Imager::ImgRaw")) {
3275 croak("i_img_masked_new: parameter 2 must undef or an image");
3277 mask = (i_img *)SvIV((SV *)SvRV(ST(1)));
3281 RETVAL = i_img_masked_new(targ, mask, x, y, w, h);
3286 i_plin(im, l, y, ...)
3295 work = mymalloc(sizeof(i_color) * (items-3));
3296 for (i=0; i < items-3; ++i) {
3297 if (sv_isobject(ST(i+3))
3298 && sv_derived_from(ST(i+3), "Imager::Color")) {
3299 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3300 work[i] = *(i_color *)tmp;
3304 croak("i_plin: pixels must be Imager::Color objects");
3308 RETVAL = i_plin(im, l, l+items-3, y, work);
3318 i_ppixf(im, x, y, cl)
3322 Imager::Color::Float cl
3325 i_gsampf(im, l, r, y, ...)
3337 croak("No channel numbers supplied to g_sampf()");
3339 chan_count = items - 4;
3340 chans = mymalloc(sizeof(int) * chan_count);
3341 for (i = 0; i < chan_count; ++i)
3342 chans[i] = SvIV(ST(i+4));
3343 data = mymalloc(sizeof(i_fsample_t) * (r-l) * chan_count);
3344 count = i_gsampf(im, l, r, y, data, chans, chan_count);
3345 if (GIMME_V == G_ARRAY) {
3347 for (i = 0; i < count; ++i)
3348 PUSHs(sv_2mortal(newSVnv(data[i])));
3352 PUSHs(sv_2mortal(newSVpv((void *)data, count * sizeof(i_fsample_t))));
3356 if (GIMME_V != G_ARRAY) {
3358 PUSHs(&PL_sv_undef);
3363 i_plinf(im, l, y, ...)
3372 work = mymalloc(sizeof(i_fcolor) * (items-3));
3373 for (i=0; i < items-3; ++i) {
3374 if (sv_isobject(ST(i+3))
3375 && sv_derived_from(ST(i+3), "Imager::Color::Float")) {
3376 IV tmp = SvIV((SV *)SvRV(ST(i+3)));
3377 work[i] = *(i_fcolor *)tmp;
3381 croak("i_plin: pixels must be Imager::Color::Float objects");
3385 RETVAL = i_plinf(im, l, l+items-3, y, work);
3402 color = (i_fcolor *)mymalloc(sizeof(i_fcolor));
3403 if (i_gpixf(im, x, y, color) == 0) {
3404 ST(0) = sv_newmortal();
3405 sv_setref_pv(ST(0), "Imager::Color::Float", (void *)color);
3409 ST(0) = &PL_sv_undef;
3423 vals = mymalloc((r-l) * sizeof(i_color));
3424 count = i_glin(im, l, r, y, vals);
3426 for (i = 0; i < count; ++i) {
3428 i_color *col = mymalloc(sizeof(i_color));
3429 sv = sv_newmortal();
3430 sv_setref_pv(sv, "Imager::Color", (void *)col);
3437 i_glinf(im, l, r, y)
3447 vals = mymalloc((r-l) * sizeof(i_fcolor));
3448 count = i_glinf(im, l, r, y, vals);
3450 for (i = 0; i < count; ++i) {
3452 i_fcolor *col = mymalloc(sizeof(i_fcolor));
3454 sv = sv_newmortal();
3455 sv_setref_pv(sv, "Imager::Color::Float", (void *)col);
3462 i_img_16_new(x, y, ch)
3468 i_img_double_new(x, y, ch)
3474 i_tags_addn(im, name, code, idata)
3483 name = SvPV(ST(1), len);
3486 RETVAL = i_tags_addn(&im->tags, name, code, idata);
3491 i_tags_add(im, name, code, data, idata)
3501 name = SvPV(ST(1), len);
3505 data = SvPV(ST(3), len);
3510 RETVAL = i_tags_add(&im->tags, name, code, data, len, idata);
3515 i_tags_find(im, name, start)
3522 if (i_tags_find(&im->tags, name, start, &entry)) {
3524 ST(0) = sv_2mortal(newSVpv("0 but true", 0));
3526 ST(0) = sv_2mortal(newSViv(entry));
3528 ST(0) = &PL_sv_undef;
3532 i_tags_findn(im, code, start)
3539 if (i_tags_findn(&im->tags, code, start, &entry)) {
3541 ST(0) = sv_2mortal(newSVpv("0 but true", 0));
3543 ST(0) = sv_2mortal(newSViv(entry));
3546 ST(0) = &PL_sv_undef;
3549 i_tags_delete(im, entry)
3553 RETVAL = i_tags_delete(&im->tags, entry);
3558 i_tags_delbyname(im, name)
3562 RETVAL = i_tags_delbyname(&im->tags, name);
3567 i_tags_delbycode(im, code)
3571 RETVAL = i_tags_delbycode(&im->tags, code);
3576 i_tags_get(im, index)
3580 if (index >= 0 && index < im->tags.count) {
3581 i_img_tag *entry = im->tags.tags + index;
3585 PUSHs(sv_2mortal(newSVpv(entry->name, 0)));
3588 PUSHs(sv_2mortal(newSViv(entry->code)));
3591 PUSHs(sv_2mortal(newSVpvn(entry->data, entry->size)));
3594 PUSHs(sv_2mortal(newSViv(entry->idata)));
3602 RETVAL = im->tags.count;
3609 i_wf_bbox(face, size, text)
3616 if (i_wf_bbox(face, size, text, strlen(text), cords)) {
3618 PUSHs(sv_2mortal(newSViv(cords[0])));
3619 PUSHs(sv_2mortal(newSViv(cords[1])));
3620 PUSHs(sv_2mortal(newSViv(cords[2])));
3621 PUSHs(sv_2mortal(newSViv(cords[3])));
3622 PUSHs(sv_2mortal(newSViv(cords[4])));
3623 PUSHs(sv_2mortal(newSViv(cords[5])));
3627 i_wf_text(face, im, tx, ty, cl, size, text, align, aa)
3638 RETVAL = i_wf_text(face, im, tx, ty, cl, size, text, strlen(text),
3644 i_wf_cp(face, im, tx, ty, channel, size, text, align, aa)
3655 RETVAL = i_wf_cp(face, im, tx, ty, channel, size, text, strlen(text),
3665 MODULE = Imager PACKAGE = Imager::Font::FT2 PREFIX=FT2_
3667 #define FT2_DESTROY(font) i_ft2_destroy(font)
3671 Imager::Font::FT2 font
3673 MODULE = Imager PACKAGE = Imager::Font::FreeType2
3676 i_ft2_new(name, index)
3681 i_ft2_setdpi(font, xdpi, ydpi)
3682 Imager::Font::FT2 font
3688 Imager::Font::FT2 font
3692 if (i_ft2_getdpi(font, &xdpi, &ydpi)) {
3694 PUSHs(sv_2mortal(newSViv(xdpi)));
3695 PUSHs(sv_2mortal(newSViv(ydpi)));
3699 i_ft2_sethinting(font, hinting)
3700 Imager::Font::FT2 font
3704 i_ft2_settransform(font, matrix)
3705 Imager::Font::FT2 font
3713 if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
3714 croak("i_ft2_settransform: parameter 2 must be an array ref\n");
3715 av=(AV*)SvRV(ST(1));
3719 for (i = 0; i < len; ++i) {
3720 sv1=(*(av_fetch(av,i,0)));
3721 matrix[i] = SvNV(sv1);
3725 RETVAL = i_ft2_settransform(font, matrix);
3730 i_ft2_bbox(font, cheight, cwidth, text, utf8)
3731 Imager::Font::FT2 font
3744 if (i_ft2_bbox(font, cheight, cwidth, text, strlen(text), bbox, utf8)) {
3746 for (i = 0; i < 6; ++i)
3747 PUSHs(sv_2mortal(newSViv(bbox[i])));
3751 i_ft2_bbox_r(font, cheight, cwidth, text, vlayout, utf8)
3752 Imager::Font::FT2 font
3766 if (i_ft2_bbox_r(font, cheight, cwidth, text, strlen(text), vlayout,
3769 for (i = 0; i < 8; ++i)
3770 PUSHs(sv_2mortal(newSViv(bbox[i])));
3774 i_ft2_text(font, im, tx, ty, cl, cheight, cwidth, text, align, aa, vlayout, utf8)
3775 Imager::Font::FT2 font
3791 if (SvUTF8(ST(7))) {
3795 text = SvPV(ST(7), len);
3796 RETVAL = i_ft2_text(font, im, tx, ty, cl, cheight, cwidth, text,
3797 len, align, aa, vlayout, utf8);
3802 i_ft2_cp(font, im, tx, ty, channel, cheight, cwidth, text, align, aa, vlayout, utf8)
3803 Imager::Font::FT2 font
3820 RETVAL = i_ft2_cp(font, im, tx, ty, channel, cheight, cwidth, text,
3821 strlen(text), align, aa, vlayout, 1);
3826 ft2_transform_box(font, x0, x1, x2, x3)
3827 Imager::Font::FT2 font
3835 box[0] = x0; box[1] = x1; box[2] = x2; box[3] = x3;
3836 ft2_transform_box(font, box);
3838 PUSHs(sv_2mortal(newSViv(box[0])));
3839 PUSHs(sv_2mortal(newSViv(box[1])));
3840 PUSHs(sv_2mortal(newSViv(box[2])));
3841 PUSHs(sv_2mortal(newSViv(box[3])));
3844 i_ft2_has_chars(handle, text, utf8)
3845 Imager::Font::FT2 handle
3858 text = SvPV(ST(1), len);
3859 work = mymalloc(len);
3860 count = i_ft2_has_chars(handle, text, len, utf8, work);
3861 if (GIMME_V == G_ARRAY) {
3863 for (i = 0; i < count; ++i) {
3864 PUSHs(sv_2mortal(newSViv(work[i])));
3869 PUSHs(sv_2mortal(newSVpv(work, count)));
3875 MODULE = Imager PACKAGE = Imager::FillHandle PREFIX=IFILL_
3879 Imager::FillHandle fill
3881 MODULE = Imager PACKAGE = Imager
3884 i_new_fill_solid(cl, combine)
3889 i_new_fill_solidf(cl, combine)
3890 Imager::Color::Float cl
3894 i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy)
3902 unsigned char *cust_hatch;
3906 cust_hatch = SvPV(ST(4), len);
3910 RETVAL = i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy);
3915 i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy)
3916 Imager::Color::Float fg
3917 Imager::Color::Float bg
3923 unsigned char *cust_hatch;
3927 cust_hatch = SvPV(ST(4), len);
3931 RETVAL = i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy);
3936 i_new_fill_image(src, matrix, xoff, yoff, combine)
3953 if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
3954 croak("i_new_fill_image: parameter must be an arrayref");
3955 av=(AV*)SvRV(ST(1));
3959 for (i = 0; i < len; ++i) {
3960 sv1=(*(av_fetch(av,i,0)));
3961 matrix[i] = SvNV(sv1);
3967 RETVAL = i_new_fill_image(src, matrixp, xoff, yoff, combine);