#include "XSUB.h"
#include "ppport.h"
#ifdef __cplusplus
-
+}
#endif
-#include "image.h"
+#define i_int_hlines_testing() 1
+
+#include "imager.h"
#include "feat.h"
#include "dynaload.h"
#include "regmach.h"
+#include "imextdef.h"
typedef io_glue* Imager__IO;
-typedef i_color* Imager__Color;
-typedef i_fcolor* Imager__Color__Float;
-typedef i_img* Imager__ImgRaw;
-typedef int undef_neg_int;
-#ifdef HAVE_LIBTT
-typedef TT_Fonthandle* Imager__Font__TT;
+#if i_int_hlines_testing()
+#include "imageri.h"
#endif
-#ifdef HAVE_FT2
-typedef FT2_Fonthandle* Imager__Font__FT2;
-#endif
+#include "imperl.h"
/* These functions are all shared - then comes platform dependant code */
static int getstr(void *hv_t,char *key,char **store) {
static void
-log_entry(char *string, int level) {
+i_log_entry(char *string, int level) {
mm_log((level, string));
}
#define ICLF_new_internal(r, g, b, a) i_fcolor_new((r), (g), (b), (a))
#define ICLF_DESTROY(cl) i_fcolor_destroy(cl)
-/* for the fill objects
- Since a fill object may later have dependent images, (or fills!)
- we need perl wrappers - oh well
-*/
-#define IFILL_DESTROY(fill) i_fill_destroy(fill);
-typedef i_fill_t* Imager__FillHandle;
/* the m_init_log() function was called init_log(), renamed to reduce
potential naming conflicts */
#define init_log m_init_log
+#if i_int_hlines_testing()
+
+typedef i_int_hlines *Imager__Internal__Hlines;
+
+static i_int_hlines *
+i_int_hlines_new(int start_y, int count_y, int start_x, int count_x) {
+ i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
+ i_int_init_hlines(result, start_y, count_y, start_x, count_x);
+
+ return result;
+}
+
+static i_int_hlines *
+i_int_hlines_new_img(i_img *im) {
+ i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
+ i_int_init_hlines_img(result, im);
+
+ return result;
+}
+
+static void
+i_int_hlines_DESTROY(i_int_hlines *hlines) {
+ i_int_hlines_destroy(hlines);
+ myfree(hlines);
+}
+
+static int seg_compare(const void *vleft, const void *vright) {
+ const i_int_hline_seg *left = vleft;
+ const i_int_hline_seg *right = vright;
+
+ return left->minx - right->minx;
+}
+
+static SV *
+i_int_hlines_dump(i_int_hlines *hlines) {
+ SV *dump = newSVpvf("start_y: %d limit_y: %d start_x: %d limit_x: %d\n",
+ hlines->start_y, hlines->limit_y, hlines->start_x, hlines->limit_x);
+ int y;
+
+ for (y = hlines->start_y; y < hlines->limit_y; ++y) {
+ i_int_hline_entry *entry = hlines->entries[y-hlines->start_y];
+ if (entry) {
+ int i;
+ /* sort the segments, if any */
+ if (entry->count)
+ qsort(entry->segs, entry->count, sizeof(i_int_hline_seg), seg_compare);
+
+ sv_catpvf(dump, " %d (%d):", y, entry->count);
+ for (i = 0; i < entry->count; ++i) {
+ sv_catpvf(dump, " [%d, %d)", entry->segs[i].minx,
+ entry->segs[i].x_limit);
+ }
+ sv_catpv(dump, "\n");
+ }
+ }
+
+ return dump;
+}
+
+#endif
+
+#ifdef IMEXIF_ENABLE
+#define i_exif_enabled() 1
+#else
+#define i_exif_enabled() 0
+#endif
+
+/* trying to use more C style names, map them here */
+#define io_glue_DESTROY(ig) io_glue_destroy(ig)
+
MODULE = Imager PACKAGE = Imager::Color PREFIX = ICL_
Imager::Color
i_rgb_to_hsvf(RETVAL);
OUTPUT:
RETVAL
-
MODULE = Imager PACKAGE = Imager::ImgRaw PREFIX = IIM_
myfree(data);
+undef_int
+i_set_image_file_limits(width, height, bytes)
+ int width
+ int height
+ int bytes
+
+void
+i_get_image_file_limits()
+ PREINIT:
+ int width, height, bytes;
+ PPCODE:
+ if (i_get_image_file_limits(&width, &height, &bytes)) {
+ EXTEND(SP, 3);
+ PUSHs(sv_2mortal(newSViv(width)));
+ PUSHs(sv_2mortal(newSViv(height)));
+ PUSHs(sv_2mortal(newSViv(bytes)));
+ }
+
MODULE = Imager PACKAGE = Imager::IO PREFIX = io_glue_
void
int channels
void
-m_init_log(name,level)
+i_init_log(name,level)
char* name
int level
void
-log_entry(string,level)
+i_log_entry(string,level)
char* string
int level
float d2
Imager::Color val
+void
+i_arc_aa(im,x,y,rad,d1,d2,val)
+ Imager::ImgRaw im
+ double x
+ double y
+ double rad
+ double d1
+ double d2
+ Imager::Color val
+
void
i_arc_cfill(im,x,y,rad,d1,d2,fill)
Imager::ImgRaw im
float d2
Imager::FillHandle fill
+void
+i_arc_aa_cfill(im,x,y,rad,d1,d2,fill)
+ Imager::ImgRaw im
+ double x
+ double y
+ double rad
+ double d1
+ double d2
+ Imager::FillHandle fill
void
int ty
Imager::Color trans
-void
-i_copy(im,src)
- Imager::ImgRaw im
+Imager::ImgRaw
+i_copy(src)
Imager::ImgRaw src
char const *text;
STRLEN work_len;
int len;
- int outsize;
char name[255];
PPCODE:
#ifdef SvUTF8
--len;
}
EXTEND(SP, 1);
- if (outsize = i_t1_glyph_name(handle, ch, name, sizeof(name))) {
+ if (i_t1_glyph_name(handle, ch, name, sizeof(name))) {
PUSHs(sv_2mortal(newSVpv(name, 0)));
}
else {
Imager::Color cl
float points
SV * str_sv
- int len_ignored
int smooth
int utf8
int align
int channel
float points
SV * str_sv
- int len_ignored
int smooth
int utf8
int align
Imager::Font::TT handle
float point
SV* str_sv
- int len_ignored
int utf8
PREINIT:
int cords[BOUNDING_BOX_COUNT],rc;
--len;
}
EXTEND(SP, 1);
- if (outsize = i_tt_glyph_name(handle, ch, name, sizeof(name))) {
+ if ((outsize = i_tt_glyph_name(handle, ch, name, sizeof(name))) != 0) {
PUSHs(sv_2mortal(newSVpv(name, 0)));
}
else {
myfree(iptc_itext);
}
+int
+i_exif_enabled()
#endif
#ifdef HAVE_LIBTIFF
Imager::ImgRaw
-i_readtiff_wiol(ig, length)
+i_readtiff_wiol(ig, length, page=0)
Imager::IO ig
int length
+ int page
void
i_readtiff_multi_wiol(ig, length)
PUSHs(newRV_noinc((SV*)ct));
}
+Imager::ImgRaw
+i_readgif_single_wiol(ig, page=0)
+ Imager::IO ig
+ int page
+
void
i_readgif_scalar(...)
PROTOTYPE: $
Imager::ImgRaw im2
int mindist
-void
+undef_int
i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
Imager::ImgRaw im
double xa
asegs = (AV *)SvRV(ST(10));
segs = load_fount_segs(asegs, &count);
- i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample,
- ssample_param, count, segs);
+ RETVAL = i_fountain(im, xa, ya, xb, yb, type, repeat, combine,
+ super_sample, ssample_param, count, segs);
myfree(segs);
+ OUTPUT:
+ RETVAL
Imager::FillHandle
i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
++i;
}
-void
+undef_int
i_nearest_color(im, ...)
Imager::ImgRaw im
PREINIT:
}
ival[i] = *INT2PTR(i_color *, SvIV((SV *)SvRV(sv)));
}
- i_nearest_color(im, num, xo, yo, ival, dmeasure);
-
-
-
+ RETVAL = i_nearest_color(im, num, xo, yo, ival, dmeasure);
+ OUTPUT:
+ RETVAL
void
malloc_state()
-void
-hashinfo(hv)
- PREINIT:
- HV* hv;
- int stuff;
- PPCODE:
- if (!SvROK(ST(0))) croak("Imager: Parameter 0 must be a reference to a hash\n");
- hv=(HV*)SvRV(ST(0));
- if (SvTYPE(hv)!=SVt_PVHV) croak("Imager: Parameter 0 must be a reference to a hash\n");
- if (getint(hv,"stuff",&stuff)) printf("ok: %d\n",stuff); else printf("key doesn't exist\n");
- if (getint(hv,"stuff2",&stuff)) printf("ok: %d\n",stuff); else printf("key doesn't exist\n");
-
void
DSO_open(filename)
char* filename
}
else {
myfree(colors);
- croak("i_plin: pixels must be Imager::Color objects");
+ croak("i_addcolor: pixels must be Imager::Color objects");
}
}
index = i_addcolors(im, colors, items-1);
PREINIT:
i_color *work;
int i;
+ STRLEN len;
+ int count;
CODE:
if (items > 3) {
- work = mymalloc(sizeof(i_color) * (items-3));
- for (i=0; i < items-3; ++i) {
- if (sv_isobject(ST(i+3))
- && sv_derived_from(ST(i+3), "Imager::Color")) {
- IV tmp = SvIV((SV *)SvRV(ST(i+3)));
- work[i] = *INT2PTR(i_color *, tmp);
+ if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
+ /* supplied as a byte string */
+ work = (i_color *)SvPV(ST(3), len);
+ count = len / sizeof(i_color);
+ if (count * sizeof(i_color) != len) {
+ croak("i_plin: length of scalar argument must be multiple of sizeof i_color");
}
- else {
- myfree(work);
- croak("i_plin: pixels must be Imager::Color objects");
+ RETVAL = i_plin(im, l, l+count, y, work);
+ }
+ else {
+ work = mymalloc(sizeof(i_color) * (items-3));
+ for (i=0; i < items-3; ++i) {
+ if (sv_isobject(ST(i+3))
+ && sv_derived_from(ST(i+3), "Imager::Color")) {
+ IV tmp = SvIV((SV *)SvRV(ST(i+3)));
+ work[i] = *INT2PTR(i_color *, tmp);
+ }
+ else {
+ myfree(work);
+ croak("i_plin: pixels must be Imager::Color objects");
+ }
}
+ RETVAL = i_plin(im, l, l+items-3, y, work);
+ myfree(work);
}
- /**(char *)0 = 1;*/
- RETVAL = i_plin(im, l, l+items-3, y, work);
- myfree(work);
}
else {
RETVAL = 0;
chans[i] = SvIV(ST(i+4));
data = mymalloc(sizeof(i_fsample_t) * (r-l) * chan_count);
count = i_gsampf(im, l, r, y, data, chans, chan_count);
+ myfree(chans);
if (GIMME_V == G_ARRAY) {
EXTEND(SP, count);
for (i = 0; i < count; ++i)
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv((void *)data, count * sizeof(i_fsample_t))));
}
+ myfree(data);
}
else {
if (GIMME_V != G_ARRAY) {
PREINIT:
i_fcolor *work;
int i;
+ STRLEN len;
+ int count;
CODE:
if (items > 3) {
- work = mymalloc(sizeof(i_fcolor) * (items-3));
- for (i=0; i < items-3; ++i) {
- if (sv_isobject(ST(i+3))
- && sv_derived_from(ST(i+3), "Imager::Color::Float")) {
- IV tmp = SvIV((SV *)SvRV(ST(i+3)));
- work[i] = *INT2PTR(i_fcolor *, tmp);
+ if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
+ /* supplied as a byte string */
+ work = (i_fcolor *)SvPV(ST(3), len);
+ count = len / sizeof(i_fcolor);
+ if (count * sizeof(i_fcolor) != len) {
+ croak("i_plin: length of scalar argument must be multiple of sizeof i_fcolor");
}
- else {
- myfree(work);
- croak("i_plin: pixels must be Imager::Color::Float objects");
+ RETVAL = i_plinf(im, l, l+count, y, work);
+ }
+ else {
+ work = mymalloc(sizeof(i_fcolor) * (items-3));
+ for (i=0; i < items-3; ++i) {
+ if (sv_isobject(ST(i+3))
+ && sv_derived_from(ST(i+3), "Imager::Color::Float")) {
+ IV tmp = SvIV((SV *)SvRV(ST(i+3)));
+ work[i] = *INT2PTR(i_fcolor *, tmp);
+ }
+ else {
+ myfree(work);
+ croak("i_plinf: pixels must be Imager::Color::Float objects");
+ }
}
+ /**(char *)0 = 1;*/
+ RETVAL = i_plinf(im, l, l+items-3, y, work);
+ myfree(work);
}
- /**(char *)0 = 1;*/
- RETVAL = i_plinf(im, l, l+items-3, y, work);
- myfree(work);
}
else {
RETVAL = 0;
if (l < r) {
vals = mymalloc((r-l) * sizeof(i_color));
count = i_glin(im, l, r, y, vals);
- EXTEND(SP, count);
- for (i = 0; i < count; ++i) {
- SV *sv;
- i_color *col = mymalloc(sizeof(i_color));
- *col = vals[i];
- sv = sv_newmortal();
- sv_setref_pv(sv, "Imager::Color", (void *)col);
- PUSHs(sv);
+ if (GIMME_V == G_ARRAY) {
+ EXTEND(SP, count);
+ for (i = 0; i < count; ++i) {
+ SV *sv;
+ i_color *col = mymalloc(sizeof(i_color));
+ *col = vals[i];
+ sv = sv_newmortal();
+ sv_setref_pv(sv, "Imager::Color", (void *)col);
+ PUSHs(sv);
+ }
+ }
+ else if (count) {
+ EXTEND(SP, 1);
+ PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_color))));
}
myfree(vals);
}
if (l < r) {
vals = mymalloc((r-l) * sizeof(i_fcolor));
count = i_glinf(im, l, r, y, vals);
- EXTEND(SP, count);
- for (i = 0; i < count; ++i) {
- SV *sv;
- i_fcolor *col = mymalloc(sizeof(i_fcolor));
- *col = vals[i];
- sv = sv_newmortal();
- sv_setref_pv(sv, "Imager::Color::Float", (void *)col);
- PUSHs(sv);
+ if (GIMME_V == G_ARRAY) {
+ EXTEND(SP, count);
+ for (i = 0; i < count; ++i) {
+ SV *sv;
+ i_fcolor *col = mymalloc(sizeof(i_fcolor));
+ *col = vals[i];
+ sv = sv_newmortal();
+ sv_setref_pv(sv, "Imager::Color::Float", (void *)col);
+ PUSHs(sv);
+ }
+ }
+ else if (count) {
+ EXTEND(SP, 1);
+ PUSHs(sv_2mortal(newSVpv((void *)vals, count * sizeof(i_fcolor))));
}
myfree(vals);
}
char const *text;
STRLEN work_len;
int len;
- int outsize;
char name[255];
PPCODE:
#ifdef SvUTF8
--len;
}
EXTEND(SP, 1);
- if (outsize = i_ft2_glyph_name(handle, ch, name, sizeof(name),
+ if (i_ft2_glyph_name(handle, ch, name, sizeof(name),
reliable_only)) {
PUSHs(sv_2mortal(newSVpv(name, 0)));
}
OUTPUT:
RETVAL
+MODULE = Imager PACKAGE = Imager::Internal::Hlines PREFIX=i_int_hlines_
+
+# this class is only exposed for testing
+
+int
+i_int_hlines_testing()
+
+#if i_int_hlines_testing()
+
+Imager::Internal::Hlines
+i_int_hlines_new(start_y, count_y, start_x, count_x)
+ int start_y
+ int count_y
+ int start_x
+ int count_x
+
+Imager::Internal::Hlines
+i_int_hlines_new_img(im)
+ Imager::ImgRaw im
+
+void
+i_int_hlines_add(hlines, y, minx, width)
+ Imager::Internal::Hlines hlines
+ int y
+ int minx
+ int width
+
+void
+i_int_hlines_DESTROY(hlines)
+ Imager::Internal::Hlines hlines
+
+SV *
+i_int_hlines_dump(hlines)
+ Imager::Internal::Hlines hlines
+
+#endif
+
+BOOT:
+ PERL_SET_GLOBAL_CALLBACKS;