#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#define NEED_newRV_noinc
+#define NEED_sv_2pv_nolen
#include "ppport.h"
#ifdef __cplusplus
}
if (cbd->reading && cbd->where < cbd->used) {
/* we read past the place where the caller expected us to be
so adjust our position a bit */
- *(char *)0 = 0;
if (io_seeker(p, cbd->where - cbd->used, SEEK_CUR) < 0) {
return -1;
}
size -= cbd->used - cbd->where;
out += cbd->used - cbd->where;
if (size < sizeof(cbd->buffer)) {
- int did_read;
+ int did_read = 0;
int copy_size;
while (size
&& (did_read = call_reader(cbd, cbd->buffer, size,
{ "webmap", mc_web_map, },
{ "addi", mc_addi, },
{ "mediancut", mc_median_cut, },
+ { "mono", mc_mono, },
+ { "monochrome", mc_mono, },
};
static struct value_name translate_names[] =
return segs;
}
+/* validates the indexes supplied to i_ppal
+
+i_ppal() doesn't do that for speed, but I'm not comfortable doing that
+for calls from perl.
+
+*/
+static void
+validate_i_ppal(i_img *im, i_palidx const *indexes, int count) {
+ int color_count = i_colorcount(im);
+ int i;
+
+ if (color_count == -1)
+ croak("i_plin() called on direct color image");
+
+ for (i = 0; i < count; ++i) {
+ if (indexes[i] >= color_count) {
+ croak("i_plin() called with out of range color index %d (max %d)",
+ indexes[i], color_count-1);
+ }
+ }
+}
+
+
/* I don't think ICLF_* names belong at the C interface
this makes the XS code think we have them, to let us avoid
putting function bodies in the XS code
OUTPUT:
RETVAL
-void
+undef_int
i_gaussian(im,stdev)
Imager::ImgRaw im
- float stdev
+ double stdev
void
i_unsharp_mask(im,stdev,scale)
#ifdef HAVE_LIBTIFF
Imager::ImgRaw
-i_readtiff_wiol(ig, length, page=0)
+i_readtiff_wiol(ig, allow_incomplete, page=0)
Imager::IO ig
- int length
+ int allow_incomplete
int page
void
Imager::ImgRaw
-i_readpnm_wiol(ig, length)
+i_readpnm_wiol(ig, allow_incomplete)
Imager::IO ig
- int length
+ int allow_incomplete
undef_int
Imager::IO ig
Imager::ImgRaw
-i_readbmp_wiol(ig)
+i_readbmp_wiol(ig, allow_incomplete=0)
Imager::IO ig
+ int allow_incomplete
undef_int
float scx
float scy
+Imager::ImgRaw
+i_scale_mixing(im, width, height)
+ Imager::ImgRaw im
+ int width
+ int height
+
Imager::ImgRaw
i_haar(im)
Imager::ImgRaw im
i_diff_image(im, im2, mindist=0)
Imager::ImgRaw im
Imager::ImgRaw im2
- int mindist
+ double mindist
undef_int
i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
for (i=0; i < items-3; ++i) {
work[i] = SvIV(ST(i+3));
}
+ validate_i_ppal(im, work, items - 3);
RETVAL = i_ppal(im, l, l+items-3, y, work);
myfree(work);
}
OUTPUT:
RETVAL
+int
+i_ppal_p(im, l, y, data)
+ Imager::ImgRaw im
+ int l
+ int y
+ SV *data
+ PREINIT:
+ i_palidx const *work;
+ STRLEN len;
+ CODE:
+ work = (i_palidx const *)SvPV(data, len);
+ len /= sizeof(i_palidx);
+ if (len > 0) {
+ validate_i_ppal(im, work, len);
+ RETVAL = i_ppal(im, l, l+len, y, work);
+ }
+ else {
+ RETVAL = 0;
+ }
+ OUTPUT:
+ RETVAL
+
SV *
i_addcolors(im, ...)
Imager::ImgRaw im
int y
int ch
+Imager::ImgRaw
+i_img_to_rgb16(im)
+ Imager::ImgRaw im
+
Imager::ImgRaw
i_img_double_new(x, y, ch)
int x
#ifdef HAVE_WIN32
void
-i_wf_bbox(face, size, text)
+i_wf_bbox(face, size, text_sv, utf8=0)
char *face
int size
- char *text
+ SV *text_sv
+ int utf8
PREINIT:
int cords[BOUNDING_BOX_COUNT];
int rc, i;
+ char const *text;
+ STRLEN text_len;
PPCODE:
- if (rc = i_wf_bbox(face, size, text, strlen(text), cords)) {
+ text = SvPV(text_sv, text_len);
+#ifdef SvUTF8
+ if (SvUTF8(text_sv))
+ utf8 = 1;
+#endif
+ if (rc = i_wf_bbox(face, size, text, text_len, cords, utf8)) {
EXTEND(SP, rc);
for (i = 0; i < rc; ++i)
PUSHs(sv_2mortal(newSViv(cords[i])));
}
undef_int
-i_wf_text(face, im, tx, ty, cl, size, text, align, aa)
+i_wf_text(face, im, tx, ty, cl, size, text_sv, align, aa, utf8 = 0)
char *face
Imager::ImgRaw im
int tx
int ty
Imager::Color cl
int size
- char *text
+ SV *text_sv
int align
int aa
+ int utf8
+ PREINIT:
+ char const *text;
+ STRLEN text_len;
CODE:
- RETVAL = i_wf_text(face, im, tx, ty, cl, size, text, strlen(text),
- align, aa);
+ text = SvPV(text_sv, text_len);
+#ifdef SvUTF8
+ if (SvUTF8(text_sv))
+ utf8 = 1;
+#endif
+ RETVAL = i_wf_text(face, im, tx, ty, cl, size, text, text_len,
+ align, aa, utf8);
OUTPUT:
RETVAL
undef_int
-i_wf_cp(face, im, tx, ty, channel, size, text, align, aa)
+i_wf_cp(face, im, tx, ty, channel, size, text_sv, align, aa, utf8 = 0)
char *face
Imager::ImgRaw im
int tx
int ty
int channel
int size
- char *text
+ SV *text_sv
int align
int aa
+ int utf8
+ PREINIT:
+ char const *text;
+ STRLEN text_len;
CODE:
- RETVAL = i_wf_cp(face, im, tx, ty, channel, size, text, strlen(text),
- align, aa);
+ text = SvPV(text_sv, text_len);
+#ifdef SvUTF8
+ if (SvUTF8(text_sv))
+ utf8 = 1;
+#endif
+ RETVAL = i_wf_cp(face, im, tx, ty, channel, size, text, text_len,
+ align, aa, utf8);
OUTPUT:
RETVAL
RETVAL
undef_int
-i_ft2_cp(font, im, tx, ty, channel, cheight, cwidth, text, align, aa, vlayout, utf8)
+i_ft2_cp(font, im, tx, ty, channel, cheight, cwidth, text_sv, align, aa, vlayout, utf8)
Imager::Font::FT2 font
Imager::ImgRaw im
int tx
int channel
double cheight
double cwidth
- char *text
+ SV *text_sv
int align
int aa
int vlayout
int utf8
+ PREINIT:
+ char const *text;
+ STRLEN len;
CODE:
#ifdef SvUTF8
if (SvUTF8(ST(7)))
utf8 = 1;
#endif
+ text = SvPV(text_sv, len);
RETVAL = i_ft2_cp(font, im, tx, ty, channel, cheight, cwidth, text,
- strlen(text), align, aa, vlayout, 1);
+ len, align, aa, vlayout, 1);
OUTPUT:
RETVAL