#include "dynaload.h"
#include "regmach.h"
#include "imextdef.h"
+#include "imextpltypes.h"
+#include <float.h>
#if i_int_hlines_testing()
#include "imageri.h"
#include "imperl.h"
+/*
+
+Allocate memory that will be discarded when mortals are discarded.
+
+*/
+
+static void *
+malloc_temp(pTHX_ size_t size) {
+ SV *sv = sv_2mortal(newSV(size));
+
+ return SvPVX(sv);
+}
+
/* These functions are all shared - then comes platform dependant code */
static int getstr(void *hv_t,char *key,char **store) {
dTHX;
SV** svpp;
HV* hv=(HV*)hv_t;
- mm_log((1,"getstr(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
+ mm_log((1,"getstr(hv_t %p, key %s, store %p)\n",hv_t,key,store));
if ( !hv_exists(hv,key,strlen(key)) ) return 0;
SV** svpp;
HV* hv=(HV*)hv_t;
- mm_log((1,"getint(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
+ mm_log((1,"getint(hv_t %p, key %s, store %p)\n",hv_t,key,store));
if ( !hv_exists(hv,key,strlen(key)) ) return 0;
SV** svpp;
HV* hv=(HV*)hv_t;
- mm_log((1,"getdouble(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
+ mm_log((1,"getdouble(hv_t %p, key %s, store %p)\n",hv_t,key,store));
if ( !hv_exists(hv,key,strlen(key)) ) return 0;
svpp=hv_fetch(hv, key, strlen(key), 0);
- *store=(float)SvNV(*svpp);
+ *store=(double)SvNV(*svpp);
return 1;
}
SV** svpp;
HV* hv=(HV*)hv_t;
- mm_log((1,"getvoid(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
+ mm_log((1,"getvoid(hv_t %p, key %s, store %p)\n",hv_t,key,store));
if ( !hv_exists(hv,key,strlen(key)) ) return 0;
SV** svpp;
HV* hv=(HV*)hv_t;
- mm_log((1,"getobj(hv_t 0x%X, key %s,type %s, store 0x%X)\n",hv_t,key,type,store));
+ mm_log((1,"getobj(hv_t %p, key %s,type %s, store %p)\n",hv_t,key,type,store));
if ( !hv_exists(hv,key,strlen(key)) ) return 0;
}
-typedef struct i_reader_data_tag
-{
- /* presumably a CODE ref or name of a sub */
- SV *sv;
-} i_reader_data;
-
-/* used by functions that want callbacks */
-static int read_callback(char *userdata, char *buffer, int need, int want) {
- dTHX;
- i_reader_data *rd = (i_reader_data *)userdata;
- int count;
- int result;
- SV *data;
- dSP; dTARG = sv_newmortal();
- /* thanks to Simon Cozens for help with the dTARG above */
-
- ENTER;
- SAVETMPS;
- EXTEND(SP, 2);
- PUSHMARK(SP);
- PUSHi(want);
- PUSHi(need);
- PUTBACK;
-
- count = perl_call_sv(rd->sv, G_SCALAR);
-
- SPAGAIN;
-
- if (count != 1)
- croak("Result of perl_call_sv(..., G_SCALAR) != 1");
-
- data = POPs;
-
- if (SvOK(data)) {
- STRLEN len;
- char *ptr = SvPV(data, len);
- if (len > want)
- croak("Too much data returned in reader callback");
-
- memcpy(buffer, ptr, len);
- result = len;
- }
- else {
- result = -1;
- }
-
- PUTBACK;
- FREETMPS;
- LEAVE;
-
- return result;
-}
-
-typedef struct
-{
- SV *sv; /* a coderef or sub name */
-} i_writer_data;
-
-/* used by functions that want callbacks */
-static int write_callback(char *userdata, char const *data, int size) {
- dTHX;
- i_writer_data *wd = (i_writer_data *)userdata;
- int count;
- int success;
- SV *sv;
- dSP;
-
- ENTER;
- SAVETMPS;
- EXTEND(SP, 1);
- PUSHMARK(SP);
- XPUSHs(sv_2mortal(newSVpv((char *)data, size)));
- PUTBACK;
-
- count = perl_call_sv(wd->sv, G_SCALAR);
-
- SPAGAIN;
-
- if (count != 1)
- croak("Result of perl_call_sv(..., G_SCALAR) != 1");
-
- sv = POPs;
- success = SvTRUE(sv);
-
-
- PUTBACK;
- FREETMPS;
- LEAVE;
-
- return success;
-}
-
#define CBDATA_BUFSIZE 8192
struct cbdata {
SV *readcb;
SV *seekcb;
SV *closecb;
-
- /* we need to remember whether the buffer contains write data or
- read data
- */
- int reading;
- int writing;
-
- /* how far we've read into the buffer (not used for writing) */
- int where;
-
- /* the amount of space used/data available in the buffer */
- int used;
-
- /* the maximum amount to fill the buffer before flushing
- If any write is larger than this then the buffer is flushed and
- the full write is performed. The write is _not_ split into
- maxwrite sized calls
- */
- int maxlength;
-
- char buffer[CBDATA_BUFSIZE];
};
-/*
-
-call_writer(cbd, buf, size)
-
-Low-level function to call the perl writer callback.
-
-*/
-
-static ssize_t call_writer(struct cbdata *cbd, void const *buf, size_t size) {
- dTHX;
- int count;
- int success;
- SV *sv;
- dSP;
-
- if (!SvOK(cbd->writecb))
- return -1;
-
- ENTER;
- SAVETMPS;
- EXTEND(SP, 1);
- PUSHMARK(SP);
- PUSHs(sv_2mortal(newSVpv((char *)buf, size)));
- PUTBACK;
-
- count = perl_call_sv(cbd->writecb, G_SCALAR);
-
- SPAGAIN;
- if (count != 1)
- croak("Result of perl_call_sv(..., G_SCALAR) != 1");
-
- sv = POPs;
- success = SvTRUE(sv);
-
-
- PUTBACK;
- FREETMPS;
- LEAVE;
-
- return success ? size : -1;
-}
-
-static ssize_t call_reader(struct cbdata *cbd, void *buf, size_t size,
- size_t maxread) {
+static ssize_t
+call_reader(struct cbdata *cbd, void *buf, size_t size,
+ size_t maxread) {
dTHX;
int count;
int result;
STRLEN len;
char *ptr = SvPV(data, len);
if (len > maxread)
- croak("Too much data returned in reader callback");
+ croak("Too much data returned in reader callback (wanted %d, got %d, expected %d)",
+ (int)size, (int)len, (int)maxread);
memcpy(buf, ptr, len);
result = len;
return result;
}
-static ssize_t write_flush(struct cbdata *cbd) {
- dTHX;
- ssize_t result;
-
- if (cbd->used) {
- result = call_writer(cbd, cbd->buffer, cbd->used);
- cbd->used = 0;
- return result;
- }
- else {
- return 1; /* success of some sort */
- }
-}
-
-static off_t io_seeker(void *p, off_t offset, int whence) {
+static off_t
+io_seeker(void *p, off_t offset, int whence) {
dTHX;
struct cbdata *cbd = p;
int count;
if (!SvOK(cbd->seekcb))
return -1;
- if (cbd->writing) {
- if (cbd->used && write_flush(cbd) <= 0)
- return -1;
- cbd->writing = 0;
- }
- if (whence == SEEK_CUR && cbd->reading && cbd->where != cbd->used) {
- offset -= cbd->where - cbd->used;
- }
- cbd->reading = 0;
- cbd->where = cbd->used = 0;
-
ENTER;
SAVETMPS;
EXTEND(SP, 2);
return result;
}
-static ssize_t io_writer(void *p, void const *data, size_t size) {
+static ssize_t
+io_writer(void *p, void const *data, size_t size) {
dTHX;
struct cbdata *cbd = p;
+ I32 count;
+ SV *sv;
+ dSP;
+ bool success;
- /* printf("io_writer(%p, %p, %u)\n", p, data, size); */
- if (!cbd->writing) {
- 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 */
- if (io_seeker(p, cbd->where - cbd->used, SEEK_CUR) < 0) {
- return -1;
- }
- cbd->reading = 0;
- }
- cbd->where = cbd->used = 0;
- }
- cbd->writing = 1;
- if (cbd->used && cbd->used + size > cbd->maxlength) {
- int write_res = write_flush(cbd);
- if (write_res <= 0) {
- return write_res;
- }
- cbd->used = 0;
- }
- if (cbd->used+size <= cbd->maxlength) {
- memcpy(cbd->buffer + cbd->used, data, size);
- cbd->used += size;
- return size;
- }
- /* it doesn't fit - just pass it up */
- return call_writer(cbd, data, size);
+ if (!SvOK(cbd->writecb))
+ return -1;
+
+ ENTER;
+ SAVETMPS;
+ EXTEND(SP, 1);
+ PUSHMARK(SP);
+ PUSHs(sv_2mortal(newSVpv((char *)data, size)));
+ PUTBACK;
+
+ count = perl_call_sv(cbd->writecb, G_SCALAR);
+
+ SPAGAIN;
+ if (count != 1)
+ croak("Result of perl_call_sv(..., G_SCALAR) != 1");
+
+ sv = POPs;
+ success = SvTRUE(sv);
+
+
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
+
+ return success ? size : -1;
}
static ssize_t
io_reader(void *p, void *data, size_t size) {
+#if 0
dTHX;
struct cbdata *cbd = p;
- ssize_t total;
+ ssize_t total = 0;
char *out = data; /* so we can do pointer arithmetic */
- /* printf("io_reader(%p, %p, %d)\n", p, data, size); */
- if (cbd->writing) {
- if (write_flush(cbd) <= 0)
- return 0;
- cbd->writing = 0;
- }
-
- cbd->reading = 1;
- if (size <= cbd->used - cbd->where) {
- /* simplest case */
- memcpy(data, cbd->buffer+cbd->where, size);
- cbd->where += size;
- return size;
- }
- total = 0;
- memcpy(out, cbd->buffer + cbd->where, cbd->used - cbd->where);
- total += cbd->used - cbd->where;
- size -= cbd->used - cbd->where;
- out += cbd->used - cbd->where;
- if (size < sizeof(cbd->buffer)) {
- int did_read = 0;
- int copy_size;
- while (size
- && (did_read = call_reader(cbd, cbd->buffer, size,
- sizeof(cbd->buffer))) > 0) {
- cbd->where = 0;
- cbd->used = did_read;
-
- copy_size = i_min(size, cbd->used);
- memcpy(out, cbd->buffer, copy_size);
- cbd->where += copy_size;
- out += copy_size;
- total += copy_size;
- size -= copy_size;
- }
- if (did_read < 0)
- return -1;
- }
- else {
- /* just read the rest - too big for our buffer*/
- int did_read;
- while ((did_read = call_reader(cbd, out, size, size)) > 0) {
- size -= did_read;
- total += did_read;
- out += did_read;
- }
- if (did_read < 0)
- return -1;
+ int did_read;
+ while (size > 0 && (did_read = call_reader(cbd, out, size, size)) > 0) {
+ size -= did_read;
+ total += did_read;
+ out += did_read;
}
+ if (total == 0 && did_read < 0)
+ return -1;
return total;
+#else
+ struct cbdata *cbd = p;
+
+ return call_reader(cbd, data, size, size);
+#endif
}
static int io_closer(void *p) {
dTHX;
struct cbdata *cbd = p;
-
- if (cbd->writing && cbd->used > 0) {
- if (write_flush(cbd) < 0)
- return -1;
- cbd->writing = 0;
- }
+ int success = 1;
if (SvOK(cbd->closecb)) {
dSP;
+ I32 count;
+ SV *sv;
ENTER;
SAVETMPS;
PUSHMARK(SP);
PUTBACK;
- perl_call_sv(cbd->closecb, G_VOID);
+ count = perl_call_sv(cbd->closecb, G_SCALAR);
SPAGAIN;
+
+ sv = POPs;
+ success = SvTRUE(sv);
+
PUTBACK;
FREETMPS;
LEAVE;
}
- return 0;
+ return success ? 0 : -1;
}
static void io_destroyer(void *p) {
static struct value_name translate_names[] =
{
-#ifdef HAVE_LIBGIF
{ "giflib", pt_giflib, },
-#endif
{ "closest", pt_closest, },
{ "perturb", pt_perturb, },
{ "errdiff", pt_errdiff, },
};
/* look through the hash for quantization options */
-static void handle_quant_opts(pTHX_ i_quantize *quant, HV *hv)
+static void
+ip_handle_quant_opts(pTHX_ i_quantize *quant, HV *hv)
{
/*** POSSIBLY BROKEN: do I need to unref the SV from hv_fetch ***/
SV **sv;
}
}
}
- quant->make_colors = mc_addi;
+ quant->make_colors = mc_median_cut;
sv = hv_fetch(hv, "make_colors", 11, 0);
if (sv && *sv && (str = SvPV(*sv, len))) {
quant->make_colors =
- lookup_name(make_color_names, sizeof(make_color_names)/sizeof(*make_color_names), str, mc_addi);
+ lookup_name(make_color_names, sizeof(make_color_names)/sizeof(*make_color_names), str, mc_median_cut);
}
sv = hv_fetch(hv, "colors", 6, 0);
if (sv && *sv && SvROK(*sv) && SvTYPE(SvRV(*sv)) == SVt_PVAV) {
quant->perturb = SvIV(*sv);
}
-static void cleanup_quant_opts(i_quantize *quant) {
+static void
+ip_cleanup_quant_opts(pTHX_ i_quantize *quant) {
myfree(quant->mc_colors);
if (quant->ed_map)
myfree(quant->ed_map);
}
/* copies the color map from the hv into the colors member of the HV */
-static void copy_colors_back(pTHX_ HV *hv, i_quantize *quant) {
+static void
+ip_copy_colors_back(pTHX_ HV *hv, i_quantize *quant) {
SV **sv;
AV *av;
int i;
#define ICLF_new_internal(r, g, b, a) i_fcolor_new((r), (g), (b), (a))
#define ICLF_DESTROY(cl) i_fcolor_destroy(cl)
-
-/* the m_init_log() function was called init_log(), renamed to reduce
- potential naming conflicts */
-#define init_log m_init_log
+#ifdef IMAGER_LOG
+#define i_log_enabled() 1
+#else
+#define i_log_enabled() 0
+#endif
#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_new(i_img_dim start_y, i_img_dim count_y, i_img_dim start_x, i_img_dim count_x) {
i_int_hlines *result = mymalloc(sizeof(i_int_hlines));
i_int_init_hlines(result, start_y, count_y, start_x, count_x);
static SV *
i_int_hlines_dump(i_int_hlines *hlines) {
dTHX;
- 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;
+ SV *dump = newSVpvf("start_y: %" i_DF " limit_y: %" i_DF " start_x: %" i_DF " limit_x: %" i_DF"\n",
+ i_DFc(hlines->start_y), i_DFc(hlines->limit_y), i_DFc(hlines->start_x), i_DFc(hlines->limit_x));
+ i_img_dim y;
for (y = hlines->start_y; y < hlines->limit_y; ++y) {
i_int_hline_entry *entry = hlines->entries[y-hlines->start_y];
if (entry->count)
qsort(entry->segs, entry->count, sizeof(i_int_hline_seg), seg_compare);
- sv_catpvf(dump, " %d (%d):", y, entry->count);
+ sv_catpvf(dump, " %" i_DF " (%" i_DF "):", i_DFc(y), i_DFc(entry->count));
for (i = 0; i < entry->count; ++i) {
- sv_catpvf(dump, " [%d, %d)", entry->segs[i].minx,
- entry->segs[i].x_limit);
+ sv_catpvf(dump, " [%" i_DF ", %" i_DF ")", i_DFc(entry->segs[i].minx),
+ i_DFc(entry->segs[i].x_limit));
}
sv_catpv(dump, "\n");
}
#endif
+static off_t
+i_sv_off_t(pTHX_ SV *sv) {
+#if LSEEKSIZE > IVSIZE
+ return (off_t)SvNV(sv);
+#else
+ return (off_t)SvIV(sv);
+#endif
+}
+
+static SV *
+i_new_sv_off_t(pTHX_ off_t off) {
+#if LSEEKSIZE > IVSIZE
+ return newSVnv(off);
+#else
+ return newSViv(off);
+#endif
+}
+
+static im_pl_ext_funcs im_perl_funcs =
+{
+ IMAGER_PL_API_VERSION,
+ IMAGER_PL_API_LEVEL,
+ ip_handle_quant_opts,
+ ip_cleanup_quant_opts,
+ ip_copy_colors_back
+};
+
+#define PERL_PL_SET_GLOBAL_CALLBACKS \
+ sv_setiv(get_sv(PERL_PL_FUNCTION_TABLE_NAME, 1), PTR2IV(&im_perl_funcs));
+
#ifdef IMEXIF_ENABLE
#define i_exif_enabled() 1
#else
/* trying to use more C style names, map them here */
#define i_io_DESTROY(ig) io_glue_destroy(ig)
+#define i_img_get_width(im) ((im)->xsize)
+#define i_img_get_height(im) ((im)->ysize)
+
+#define i_img_epsilonf() (DBL_EPSILON * 4)
+
MODULE = Imager PACKAGE = Imager::Color PREFIX = ICL_
Imager::Color
Imager::ImgRaw
IIM_new(x,y,ch)
- int x
- int y
+ i_img_dim x
+ i_img_dim y
int ch
void
cbd->seekcb = seekcb;
SvREFCNT_inc(closecb);
cbd->closecb = closecb;
- cbd->reading = cbd->writing = cbd->where = cbd->used = 0;
- if (maxwrite > CBDATA_BUFSIZE)
- maxwrite = CBDATA_BUFSIZE;
- cbd->maxlength = maxwrite;
RETVAL = io_new_cb(cbd, io_reader, io_writer, io_seeker, io_closer,
io_destroyer);
OUTPUT:
undef_int
i_set_image_file_limits(width, height, bytes)
- int width
- int height
- int bytes
+ i_img_dim width
+ i_img_dim height
+ size_t bytes
void
i_get_image_file_limits()
PREINIT:
- int width, height, bytes;
+ i_img_dim width, height;
+ size_t 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)));
+ PUSHs(sv_2mortal(newSVuv(bytes)));
}
MODULE = Imager PACKAGE = Imager::IO PREFIX = i_io_
int
-i_io_write(ig, data_sv)
+i_io_raw_write(ig, data_sv)
Imager::IO ig
SV *data_sv
PREINIT:
}
#endif
data = SvPV(data_sv, size);
- RETVAL = i_io_write(ig, data, size);
+ RETVAL = i_io_raw_write(ig, data, size);
OUTPUT:
RETVAL
void
-i_io_read(ig, buffer_sv, size)
+i_io_raw_read(ig, buffer_sv, size)
Imager::IO ig
SV *buffer_sv
- int size
+ IV size
PREINIT:
void *buffer;
- int result;
+ ssize_t result;
PPCODE:
if (size <= 0)
- croak("size negative in call to i_io_read()");
+ croak("size negative in call to i_io_raw_read()");
/* prevent an undefined value warning if they supplied an
undef buffer.
Orginally conditional on !SvOK(), but this will prevent the
sv_utf8_downgrade(buffer_sv, FALSE);
#endif
buffer = SvGROW(buffer_sv, size+1);
- result = i_io_read(ig, buffer, size);
+ result = i_io_raw_read(ig, buffer, size);
if (result >= 0) {
SvCUR_set(buffer_sv, result);
*SvEND(buffer_sv) = '\0';
SvSETMAGIC(ST(1));
void
-i_io_read2(ig, size)
+i_io_raw_read2(ig, size)
Imager::IO ig
- int size
+ IV size
PREINIT:
SV *buffer_sv;
void *buffer;
- int result;
+ ssize_t result;
PPCODE:
if (size <= 0)
croak("size negative in call to i_io_read2()");
buffer_sv = newSV(size);
buffer = SvGROW(buffer_sv, size+1);
- result = i_io_read(ig, buffer, size);
+ result = i_io_raw_read(ig, buffer, size);
if (result >= 0) {
SvCUR_set(buffer_sv, result);
*SvEND(buffer_sv) = '\0';
SvREFCNT_dec(buffer_sv);
}
-int
-i_io_seek(ig, position, whence)
+off_t
+i_io_raw_seek(ig, position, whence)
Imager::IO ig
- long position
+ off_t position
int whence
int
-i_io_close(ig)
+i_io_raw_close(ig)
Imager::IO ig
void
int
i_io_CLONE_SKIP(...)
CODE:
+ (void)items; /* avoid unused warning for XS variable */
RETVAL = 1;
OUTPUT:
RETVAL
-MODULE = Imager PACKAGE = Imager
-
-PROTOTYPES: ENABLE
-
-void
-i_list_formats()
- PREINIT:
- char* item;
- int i;
- PPCODE:
- i=0;
- while( (item=i_format_list[i++]) != NULL ) {
- EXTEND(SP, 1);
- PUSHs(sv_2mortal(newSVpv(item,0)));
- }
-
-undef_int
-i_has_format(frmt)
- char* frmt
+int
+i_io_getc(ig)
+ Imager::IO ig
-Imager::ImgRaw
-i_img_new()
+int
+i_io_putc(ig, c)
+ Imager::IO ig
+ int c
-Imager::ImgRaw
-i_img_empty(im,x,y)
- Imager::ImgRaw im
- int x
- int y
+int
+i_io_close(ig)
+ Imager::IO ig
-Imager::ImgRaw
-i_img_empty_ch(im,x,y,ch)
- Imager::ImgRaw im
- int x
- int y
- int ch
+int
+i_io_flush(ig)
+ Imager::IO ig
-Imager::ImgRaw
-i_sametype(im, x, y)
- Imager::ImgRaw im
- int x
- int y
+int
+i_io_peekc(ig)
+ Imager::IO ig
-Imager::ImgRaw
-i_sametype_chans(im, x, y, channels)
- Imager::ImgRaw im
- int x
- int y
- int channels
+int
+i_io_seek(ig, off, whence)
+ Imager::IO ig
+ off_t off
+ int whence
void
-i_init_log(name_sv,level)
- SV* name_sv
- int level
- PREINIT:
+i_io_peekn(ig, size)
+ Imager::IO ig
+ STRLEN size
+ PREINIT:
+ SV *buffer_sv;
+ void *buffer;
+ ssize_t result;
+ PPCODE:
+ if (size == 0)
+ croak("size zero in call to peekn()");
+ buffer_sv = newSV(size);
+ buffer = SvGROW(buffer_sv, size+1);
+ result = i_io_peekn(ig, buffer, size);
+ if (result > 0) {
+ SvCUR_set(buffer_sv, result);
+ *SvEND(buffer_sv) = '\0';
+ SvPOK_only(buffer_sv);
+ EXTEND(SP, 1);
+ PUSHs(sv_2mortal(buffer_sv));
+ }
+ else {
+ /* discard it */
+ SvREFCNT_dec(buffer_sv);
+ }
+
+void
+i_io_read(ig, buffer_sv, size)
+ Imager::IO ig
+ SV *buffer_sv
+ IV size
+ PREINIT:
+ void *buffer;
+ ssize_t result;
+ PPCODE:
+ if (size <= 0)
+ croak("size negative in call to i_io_read()");
+ /* prevent an undefined value warning if they supplied an
+ undef buffer.
+ Orginally conditional on !SvOK(), but this will prevent the
+ downgrade from croaking */
+ sv_setpvn(buffer_sv, "", 0);
+#ifdef SvUTF8
+ if (SvUTF8(buffer_sv))
+ sv_utf8_downgrade(buffer_sv, FALSE);
+#endif
+ buffer = SvGROW(buffer_sv, size+1);
+ result = i_io_read(ig, buffer, size);
+ if (result >= 0) {
+ SvCUR_set(buffer_sv, result);
+ *SvEND(buffer_sv) = '\0';
+ SvPOK_only(buffer_sv);
+ EXTEND(SP, 1);
+ PUSHs(sv_2mortal(newSViv(result)));
+ }
+ ST(1) = buffer_sv;
+ SvSETMAGIC(ST(1));
+
+void
+i_io_read2(ig, size)
+ Imager::IO ig
+ STRLEN size
+ PREINIT:
+ SV *buffer_sv;
+ void *buffer;
+ ssize_t result;
+ PPCODE:
+ if (size == 0)
+ croak("size zero in call to bread()");
+ buffer_sv = newSV(size);
+ buffer = SvGROW(buffer_sv, size+1);
+ result = i_io_read(ig, buffer, size);
+ if (result > 0) {
+ SvCUR_set(buffer_sv, result);
+ *SvEND(buffer_sv) = '\0';
+ SvPOK_only(buffer_sv);
+ EXTEND(SP, 1);
+ PUSHs(sv_2mortal(buffer_sv));
+ }
+ else {
+ /* discard it */
+ SvREFCNT_dec(buffer_sv);
+ }
+
+size_t
+i_io_write(ig, data_sv)
+ Imager::IO ig
+ SV *data_sv
+ PREINIT:
+ void *data;
+ STRLEN size;
+ CODE:
+#ifdef SvUTF8
+ if (SvUTF8(data_sv)) {
+ data_sv = sv_2mortal(newSVsv(data_sv));
+ /* yes, we want this to croak() if the SV can't be downgraded */
+ sv_utf8_downgrade(data_sv, FALSE);
+ }
+#endif
+ data = SvPV(data_sv, size);
+ RETVAL = i_io_write(ig, data, size);
+ OUTPUT:
+ RETVAL
+
+void
+i_io_dump(ig, flags = I_IO_DUMP_DEFAULT)
+ Imager::IO ig
+ int flags
+
+void
+i_io_set_buffered(ig, flag = 1)
+ Imager::IO ig
+ int flag
+
+MODULE = Imager PACKAGE = Imager
+
+PROTOTYPES: ENABLE
+
+void
+i_list_formats()
+ PREINIT:
+ char* item;
+ int i;
+ PPCODE:
+ i=0;
+ while( (item=i_format_list[i++]) != NULL ) {
+ EXTEND(SP, 1);
+ PUSHs(sv_2mortal(newSVpv(item,0)));
+ }
+
+Imager::ImgRaw
+i_img_new()
+
+Imager::ImgRaw
+i_img_empty(im,x,y)
+ Imager::ImgRaw im
+ i_img_dim x
+ i_img_dim y
+
+Imager::ImgRaw
+i_img_empty_ch(im,x,y,ch)
+ Imager::ImgRaw im
+ i_img_dim x
+ i_img_dim y
+ int ch
+
+Imager::ImgRaw
+i_sametype(im, x, y)
+ Imager::ImgRaw im
+ i_img_dim x
+ i_img_dim y
+
+Imager::ImgRaw
+i_sametype_chans(im, x, y, channels)
+ Imager::ImgRaw im
+ i_img_dim x
+ i_img_dim y
+ int channels
+
+int
+i_init_log(name_sv,level)
+ SV* name_sv
+ int level
+ PREINIT:
const char *name = SvOK(name_sv) ? SvPV_nolen(name_sv) : NULL;
CODE:
- i_init_log(name, level);
+ RETVAL = i_init_log(name, level);
+ OUTPUT:
+ RETVAL
void
i_log_entry(string,level)
char* string
int level
+int
+i_log_enabled()
void
i_img_exorcise(im)
i_img_info(im)
Imager::ImgRaw im
PREINIT:
- int info[4];
+ i_img_dim info[4];
PPCODE:
i_img_info(im,info);
EXTEND(SP, 4);
sv_2mortal(newSVpv((char *)im->idata, im->bytes))
: &PL_sv_undef);
+IV
+i_img_get_width(im)
+ Imager::ImgRaw im
+
+IV
+i_img_get_height(im)
+ Imager::ImgRaw im
+
+
void
i_img_is_monochrome(im)
Imager::ImgRaw im
void
i_line(im,x1,y1,x2,y2,val,endp)
Imager::ImgRaw im
- int x1
- int y1
- int x2
- int y2
+ i_img_dim x1
+ i_img_dim y1
+ i_img_dim x2
+ i_img_dim y2
Imager::Color val
int endp
void
i_line_aa(im,x1,y1,x2,y2,val,endp)
Imager::ImgRaw im
- int x1
- int y1
- int x2
- int y2
+ i_img_dim x1
+ i_img_dim y1
+ i_img_dim x2
+ i_img_dim y2
Imager::Color val
int endp
void
i_box(im,x1,y1,x2,y2,val)
Imager::ImgRaw im
- int x1
- int y1
- int x2
- int y2
+ i_img_dim x1
+ i_img_dim y1
+ i_img_dim x2
+ i_img_dim y2
Imager::Color val
void
i_box_filled(im,x1,y1,x2,y2,val)
Imager::ImgRaw im
- int x1
- int y1
- int x2
- int y2
+ i_img_dim x1
+ i_img_dim y1
+ i_img_dim x2
+ i_img_dim y2
Imager::Color val
+int
+i_box_filledf(im,x1,y1,x2,y2,val)
+ Imager::ImgRaw im
+ i_img_dim x1
+ i_img_dim y1
+ i_img_dim x2
+ i_img_dim y2
+ Imager::Color::Float val
+
void
i_box_cfill(im,x1,y1,x2,y2,fill)
Imager::ImgRaw im
- int x1
- int y1
- int x2
- int y2
+ i_img_dim x1
+ i_img_dim y1
+ i_img_dim x2
+ i_img_dim y2
Imager::FillHandle fill
void
i_arc(im,x,y,rad,d1,d2,val)
Imager::ImgRaw im
- int x
- int y
- float rad
- float d1
- float d2
+ i_img_dim x
+ i_img_dim y
+ double rad
+ double d1
+ double d2
Imager::Color val
void
void
i_arc_cfill(im,x,y,rad,d1,d2,fill)
Imager::ImgRaw im
- int x
- int y
- float rad
- float d1
- float d2
+ i_img_dim x
+ i_img_dim y
+ double rad
+ double d1
+ double d2
Imager::FillHandle fill
void
void
i_circle_aa(im,x,y,rad,val)
Imager::ImgRaw im
- float x
- float y
- float rad
+ double x
+ double y
+ double rad
Imager::Color val
int
i_img_dim x
i_img_dim y
i_img_dim rad
- float d1
- float d2
+ double d1
+ double d2
Imager::Color val
int
i_img_dim x
i_img_dim y
i_img_dim rad
- float d1
- float d2
+ double d1
+ double d2
Imager::Color val
undef_int
i_flood_fill(im,seedx,seedy,dcol)
Imager::ImgRaw im
- int seedx
- int seedy
+ i_img_dim seedx
+ i_img_dim seedy
Imager::Color dcol
undef_int
i_flood_cfill(im,seedx,seedy,fill)
Imager::ImgRaw im
- int seedx
- int seedy
+ i_img_dim seedx
+ i_img_dim seedy
Imager::FillHandle fill
undef_int
i_flood_fill_border(im,seedx,seedy,dcol, border)
Imager::ImgRaw im
- int seedx
- int seedy
+ i_img_dim seedx
+ i_img_dim seedy
Imager::Color dcol
Imager::Color border
undef_int
i_flood_cfill_border(im,seedx,seedy,fill, border)
Imager::ImgRaw im
- int seedx
- int seedy
+ i_img_dim seedx
+ i_img_dim seedy
Imager::FillHandle fill
Imager::Color border
i_copyto(im,src,x1,y1,x2,y2,tx,ty)
Imager::ImgRaw im
Imager::ImgRaw src
- int x1
- int y1
- int x2
- int y2
- int tx
- int ty
+ i_img_dim x1
+ i_img_dim y1
+ i_img_dim x2
+ i_img_dim y2
+ i_img_dim tx
+ i_img_dim ty
void
i_copyto_trans(im,src,x1,y1,x2,y2,tx,ty,trans)
Imager::ImgRaw im
Imager::ImgRaw src
- int x1
- int y1
- int x2
- int y2
- int tx
- int ty
+ i_img_dim x1
+ i_img_dim y1
+ i_img_dim x2
+ i_img_dim y2
+ i_img_dim tx
+ i_img_dim ty
Imager::Color trans
Imager::ImgRaw
i_rubthru(im,src,tx,ty,src_minx,src_miny,src_maxx,src_maxy)
Imager::ImgRaw im
Imager::ImgRaw src
- int tx
- int ty
- int src_minx
- int src_miny
- int src_maxx
- int src_maxy
+ i_img_dim tx
+ i_img_dim ty
+ i_img_dim src_minx
+ i_img_dim src_miny
+ i_img_dim src_maxx
+ i_img_dim src_maxy
undef_int
i_compose(out, src, out_left, out_top, src_left, src_top, width, height, combine = ic_normal, opacity = 0.0)
Imager::ImgRaw out
Imager::ImgRaw src
- int out_left
- int out_top
- int src_left
- int src_top
- int width
- int height
+ i_img_dim out_left
+ i_img_dim out_top
+ i_img_dim src_left
+ i_img_dim src_top
+ i_img_dim width
+ i_img_dim height
int combine
double opacity
Imager::ImgRaw out
Imager::ImgRaw src
Imager::ImgRaw mask
- int out_left
- int out_top
- int src_left
- int src_top
- int mask_left
- int mask_top
- int width
- int height
+ i_img_dim out_left
+ i_img_dim out_top
+ i_img_dim src_left
+ i_img_dim src_top
+ i_img_dim mask_left
+ i_img_dim mask_top
+ i_img_dim width
+ i_img_dim height
int combine
double opacity
+Imager::ImgRaw
+i_combine(src_av, channels_av = NULL)
+ AV *src_av
+ AV *channels_av
+ PREINIT:
+ i_img **imgs = NULL;
+ STRLEN in_count;
+ int *channels = NULL;
+ int i;
+ SV **psv;
+ IV tmp;
+ CODE:
+ in_count = av_len(src_av) + 1;
+ if (in_count > 0) {
+ imgs = mymalloc(sizeof(i_img*) * in_count);
+ channels = mymalloc(sizeof(int) * in_count);
+ for (i = 0; i < in_count; ++i) {
+ psv = av_fetch(src_av, i, 0);
+ if (!psv || !*psv || !sv_derived_from(*psv, "Imager::ImgRaw")) {
+ myfree(imgs);
+ myfree(channels);
+ croak("imgs must contain only images");
+ }
+ tmp = SvIV((SV*)SvRV(*psv));
+ imgs[i] = INT2PTR(i_img*, tmp);
+ if (channels_av &&
+ (psv = av_fetch(channels_av, i, 0)) != NULL &&
+ *psv) {
+ channels[i] = SvIV(*psv);
+ }
+ else {
+ channels[i] = 0;
+ }
+ }
+ }
+ RETVAL = i_combine(imgs, channels, in_count);
+ myfree(imgs);
+ myfree(channels);
+ OUTPUT:
+ RETVAL
+
undef_int
i_flipxy(im, direction)
Imager::ImgRaw im
Imager::ImgRaw
i_matrix_transform(im, xsize, ysize, matrix, ...)
Imager::ImgRaw im
- int xsize
- int ysize
+ i_img_dim xsize
+ i_img_dim ysize
PREINIT:
double matrix[9];
AV *av;
void
i_unsharp_mask(im,stdev,scale)
Imager::ImgRaw im
- float stdev
+ double stdev
double scale
int
Imager::ImgRaw src
AV *avmain
PREINIT:
- float *coeff;
+ double *coeff;
int outchan;
int inchan;
SV **temp;
inchan = len;
}
}
- coeff = mymalloc(sizeof(float) * outchan * inchan);
+ coeff = mymalloc(sizeof(double) * outchan * inchan);
for (j = 0; j < outchan; ++j) {
avsub = (AV*)SvRV(*av_fetch(avmain, j, 0));
len = av_len(avsub)+1;
Imager::ImgRaw im1
Imager::ImgRaw im2
-undef_int
-i_init_fonts(t1log=0)
- int t1log
+int
+i_img_samef(im1, im2, epsilon = i_img_epsilonf(), what=NULL)
+ Imager::ImgRaw im1
+ Imager::ImgRaw im2
+ double epsilon
+ const char *what
+
+double
+i_img_epsilonf()
+
+bool
+_is_color_object(sv)
+ SV* sv
+ CODE:
+ SvGETMAGIC(sv);
+ RETVAL = SvOK(sv) && SvROK(sv) &&
+ (sv_derived_from(sv, "Imager::Color")
+ || sv_derived_from(sv, "Imager::Color::Float"));
+ OUTPUT:
+ RETVAL
+
+#ifdef HAVE_LIBTT
+
+
+Imager::Font::TT
+i_tt_new(fontname)
+ char* fontname
+
-#ifdef HAVE_LIBT1
+MODULE = Imager PACKAGE = Imager::Font::TT PREFIX=TT_
+
+#define TT_DESTROY(handle) i_tt_destroy(handle)
void
-i_t1_set_aa(st)
- int st
+TT_DESTROY(handle)
+ Imager::Font::TT handle
int
-i_t1_new(pfb,afm)
- char* pfb
- char* afm
+TT_CLONE_SKIP(...)
+ CODE:
+ (void)items; /* avoid unused warning */
+ RETVAL = 1;
+ OUTPUT:
+ RETVAL
-int
-i_t1_destroy(font_id)
- int font_id
+
+MODULE = Imager PACKAGE = Imager
undef_int
-i_t1_cp(im,xb,yb,channel,fontnum,points,str_sv,len_ignored,align,utf8=0,flags="")
+i_tt_text(handle,im,xb,yb,cl,points,str_sv,len_ignored,smooth,utf8,align=1)
+ Imager::Font::TT handle
Imager::ImgRaw im
- int xb
- int yb
- int channel
- int fontnum
- float points
- SV* str_sv
- int align
+ i_img_dim xb
+ i_img_dim yb
+ Imager::Color cl
+ double points
+ SV * str_sv
+ int smooth
int utf8
- char* flags
+ int align
PREINIT:
char *str;
STRLEN len;
utf8 = 1;
#endif
str = SvPV(str_sv, len);
- RETVAL = i_t1_cp(im, xb,yb,channel,fontnum,points,str,len,align,
- utf8,flags);
- OUTPUT:
- RETVAL
+ RETVAL = i_tt_text(handle, im, xb, yb, cl, points, str,
+ len, smooth, utf8, align);
+ OUTPUT:
+ RETVAL
-void
-i_t1_bbox(fontnum,point,str_sv,len_ignored,utf8=0,flags="")
- int fontnum
- float point
- SV* str_sv
+undef_int
+i_tt_cp(handle,im,xb,yb,channel,points,str_sv,len_ignored,smooth,utf8,align=1)
+ Imager::Font::TT handle
+ Imager::ImgRaw im
+ i_img_dim xb
+ i_img_dim yb
+ int channel
+ double points
+ SV * str_sv
+ int smooth
int utf8
- char* flags
- PREINIT:
+ int align
+ PREINIT:
char *str;
STRLEN len;
- int cords[BOUNDING_BOX_COUNT];
- int i;
- int rc;
- PPCODE:
+ CODE:
#ifdef SvUTF8
if (SvUTF8(str_sv))
utf8 = 1;
#endif
str = SvPV(str_sv, len);
- rc = i_t1_bbox(fontnum,point,str,len,cords,utf8,flags);
- if (rc > 0) {
- EXTEND(SP, rc);
- for (i = 0; i < rc; ++i)
- PUSHs(sv_2mortal(newSViv(cords[i])));
- }
-
+ RETVAL = i_tt_cp(handle, im, xb, yb, channel, points, str, len,
+ smooth, utf8, align);
+ OUTPUT:
+ RETVAL
-undef_int
-i_t1_text(im,xb,yb,cl,fontnum,points,str_sv,len_ignored,align,utf8=0,flags="")
- Imager::ImgRaw im
- int xb
- int yb
- Imager::Color cl
- int fontnum
- float points
- SV* str_sv
- int align
+void
+i_tt_bbox(handle,point,str_sv,len_ignored, utf8)
+ Imager::Font::TT handle
+ double point
+ SV* str_sv
int utf8
- char* flags
- PREINIT:
- char *str;
+ PREINIT:
+ i_img_dim cords[BOUNDING_BOX_COUNT];
+ int rc;
+ char * str;
STRLEN len;
- CODE:
+ int i;
+ PPCODE:
#ifdef SvUTF8
- if (SvUTF8(str_sv))
+ if (SvUTF8(ST(2)))
utf8 = 1;
#endif
str = SvPV(str_sv, len);
- RETVAL = i_t1_text(im, xb,yb,cl,fontnum,points,str,len,align,
- utf8,flags);
- OUTPUT:
- RETVAL
+ if ((rc=i_tt_bbox(handle,point,str,len,cords, utf8))) {
+ EXTEND(SP, rc);
+ for (i = 0; i < rc; ++i) {
+ PUSHs(sv_2mortal(newSViv(cords[i])));
+ }
+ }
void
-i_t1_has_chars(handle, text_sv, utf8 = 0)
- int handle
+i_tt_has_chars(handle, text_sv, utf8)
+ Imager::Font::TT handle
SV *text_sv
int utf8
PREINIT:
char const *text;
STRLEN len;
char *work;
- int count;
- int i;
+ size_t count;
+ size_t i;
PPCODE:
#ifdef SvUTF8
if (SvUTF8(text_sv))
#endif
text = SvPV(text_sv, len);
work = mymalloc(len);
- count = i_t1_has_chars(handle, text, len, utf8, work);
+ count = i_tt_has_chars(handle, text, len, utf8, work);
if (GIMME_V == G_ARRAY) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
myfree(work);
void
-i_t1_face_name(handle)
- int handle
+i_tt_dump_names(handle)
+ Imager::Font::TT handle
+
+void
+i_tt_face_name(handle)
+ Imager::Font::TT handle
PREINIT:
char name[255];
- int len;
+ size_t len;
PPCODE:
- len = i_t1_face_name(handle, name, sizeof(name));
+ len = i_tt_face_name(handle, name, sizeof(name));
if (len) {
EXTEND(SP, 1);
- PUSHs(sv_2mortal(newSVpv(name, strlen(name))));
+ PUSHs(sv_2mortal(newSVpv(name, len-1)));
}
void
-i_t1_glyph_name(handle, text_sv, utf8 = 0)
- int handle
+i_tt_glyph_name(handle, text_sv, utf8 = 0)
+ Imager::Font::TT handle
SV *text_sv
int utf8
PREINIT:
char const *text;
STRLEN work_len;
- int len;
+ size_t len;
+ size_t outsize;
char name[255];
PPCODE:
#ifdef SvUTF8
if (ch == ~0UL) {
i_push_error(0, "invalid UTF8 character");
break;
- }
- }
- else {
- ch = *text++;
- --len;
- }
- EXTEND(SP, 1);
- if (i_t1_glyph_name(handle, ch, name, sizeof(name))) {
- PUSHs(sv_2mortal(newSVpv(name, 0)));
- }
- else {
- PUSHs(&PL_sv_undef);
- }
- }
-
-#endif
-
-#ifdef HAVE_LIBTT
-
-
-Imager::Font::TT
-i_tt_new(fontname)
- char* fontname
-
-
-MODULE = Imager PACKAGE = Imager::Font::TT PREFIX=TT_
-
-#define TT_DESTROY(handle) i_tt_destroy(handle)
-
-void
-TT_DESTROY(handle)
- Imager::Font::TT handle
-
-int
-TT_CLONE_SKIP(...)
- CODE:
- RETVAL = 1;
- OUTPUT:
- RETVAL
-
-
-MODULE = Imager PACKAGE = Imager
-
-
-undef_int
-i_tt_text(handle,im,xb,yb,cl,points,str_sv,len_ignored,smooth,utf8,align=1)
- Imager::Font::TT handle
- Imager::ImgRaw im
- int xb
- int yb
- Imager::Color cl
- float points
- SV * str_sv
- int smooth
- int utf8
- int align
- PREINIT:
- char *str;
- STRLEN len;
- CODE:
-#ifdef SvUTF8
- if (SvUTF8(str_sv))
- utf8 = 1;
-#endif
- str = SvPV(str_sv, len);
- RETVAL = i_tt_text(handle, im, xb, yb, cl, points, str,
- len, smooth, utf8, align);
- OUTPUT:
- RETVAL
-
-
-undef_int
-i_tt_cp(handle,im,xb,yb,channel,points,str_sv,len_ignored,smooth,utf8,align=1)
- Imager::Font::TT handle
- Imager::ImgRaw im
- int xb
- int yb
- int channel
- float points
- SV * str_sv
- int smooth
- int utf8
- int align
- PREINIT:
- char *str;
- STRLEN len;
- CODE:
-#ifdef SvUTF8
- if (SvUTF8(str_sv))
- utf8 = 1;
-#endif
- str = SvPV(str_sv, len);
- RETVAL = i_tt_cp(handle, im, xb, yb, channel, points, str, len,
- smooth, utf8, align);
- OUTPUT:
- RETVAL
-
-
-void
-i_tt_bbox(handle,point,str_sv,len_ignored, utf8)
- Imager::Font::TT handle
- float point
- SV* str_sv
- int utf8
- PREINIT:
- int cords[BOUNDING_BOX_COUNT],rc;
- char * str;
- STRLEN len;
- int i;
- PPCODE:
-#ifdef SvUTF8
- if (SvUTF8(ST(2)))
- utf8 = 1;
-#endif
- str = SvPV(str_sv, len);
- if ((rc=i_tt_bbox(handle,point,str,len,cords, utf8))) {
- EXTEND(SP, rc);
- for (i = 0; i < rc; ++i) {
- PUSHs(sv_2mortal(newSViv(cords[i])));
- }
- }
-
-void
-i_tt_has_chars(handle, text_sv, utf8)
- Imager::Font::TT handle
- SV *text_sv
- int utf8
- PREINIT:
- char const *text;
- STRLEN len;
- char *work;
- int count;
- int i;
- PPCODE:
-#ifdef SvUTF8
- if (SvUTF8(text_sv))
- utf8 = 1;
-#endif
- text = SvPV(text_sv, len);
- work = mymalloc(len);
- count = i_tt_has_chars(handle, text, len, utf8, work);
- if (GIMME_V == G_ARRAY) {
- EXTEND(SP, count);
- for (i = 0; i < count; ++i) {
- PUSHs(sv_2mortal(newSViv(work[i])));
- }
- }
- else {
- EXTEND(SP, 1);
- PUSHs(sv_2mortal(newSVpv(work, count)));
- }
- myfree(work);
-
-void
-i_tt_dump_names(handle)
- Imager::Font::TT handle
-
-void
-i_tt_face_name(handle)
- Imager::Font::TT handle
- PREINIT:
- char name[255];
- int len;
- PPCODE:
- len = i_tt_face_name(handle, name, sizeof(name));
- if (len) {
- EXTEND(SP, 1);
- PUSHs(sv_2mortal(newSVpv(name, strlen(name))));
- }
-
-void
-i_tt_glyph_name(handle, text_sv, utf8 = 0)
- Imager::Font::TT handle
- SV *text_sv
- int utf8
- PREINIT:
- char const *text;
- STRLEN work_len;
- int len;
- int outsize;
- char name[255];
- PPCODE:
-#ifdef SvUTF8
- if (SvUTF8(text_sv))
- utf8 = 1;
-#endif
- text = SvPV(text_sv, work_len);
- len = work_len;
- while (len) {
- unsigned long ch;
- if (utf8) {
- ch = i_utf8_advance(&text, &len);
- if (ch == ~0UL) {
- i_push_error(0, "invalid UTF8 character");
- break;
- }
- }
- else {
- ch = *text++;
- --len;
- }
- EXTEND(SP, 1);
- if ((outsize = i_tt_glyph_name(handle, ch, name, sizeof(name))) != 0) {
- PUSHs(sv_2mortal(newSVpv(name, 0)));
- }
- else {
- PUSHs(&PL_sv_undef);
- }
- }
-
-#endif
-
-
-#ifdef HAVE_LIBJPEG
-undef_int
-i_writejpeg_wiol(im, ig, qfactor)
- Imager::ImgRaw im
- Imager::IO ig
- int qfactor
-
-
-void
-i_readjpeg_wiol(ig)
- Imager::IO ig
- PREINIT:
- char* iptc_itext;
- int tlength;
- i_img* rimg;
- SV* r;
- PPCODE:
- iptc_itext = NULL;
- rimg = i_readjpeg_wiol(ig,-1,&iptc_itext,&tlength);
- if (iptc_itext == NULL) {
- r = sv_newmortal();
- EXTEND(SP,1);
- sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
- PUSHs(r);
- } else {
- r = sv_newmortal();
- EXTEND(SP,2);
- sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
- PUSHs(r);
- PUSHs(sv_2mortal(newSVpv(iptc_itext,tlength)));
- myfree(iptc_itext);
- }
-
-int
-i_exif_enabled()
-
-#endif
-
-
-const char *
-i_test_format_probe(ig, length)
- Imager::IO ig
- int length
-
-
-
-#ifdef HAVE_LIBTIFF
-
-Imager::ImgRaw
-i_readtiff_wiol(ig, allow_incomplete, page=0)
- Imager::IO ig
- int allow_incomplete
- int page
-
-void
-i_readtiff_multi_wiol(ig, length)
- Imager::IO ig
- int length
- PREINIT:
- i_img **imgs;
- int count;
- int i;
- PPCODE:
- imgs = i_readtiff_multi_wiol(ig, length, &count);
- if (imgs) {
- EXTEND(SP, count);
- for (i = 0; i < count; ++i) {
- SV *sv = sv_newmortal();
- sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
- PUSHs(sv);
- }
- myfree(imgs);
- }
-
-
-undef_int
-i_writetiff_wiol(im, ig)
- Imager::ImgRaw im
- Imager::IO ig
-
-undef_int
-i_writetiff_multi_wiol(ig, ...)
- Imager::IO ig
- PREINIT:
- int i;
- int img_count;
- i_img **imgs;
- CODE:
- if (items < 2)
- croak("Usage: i_writetiff_multi_wiol(ig, images...)");
- img_count = items - 1;
- RETVAL = 1;
- if (img_count < 1) {
- RETVAL = 0;
- i_clear_error();
- i_push_error(0, "You need to specify images to save");
- }
- else {
- imgs = mymalloc(sizeof(i_img *) * img_count);
- for (i = 0; i < img_count; ++i) {
- SV *sv = ST(1+i);
- imgs[i] = NULL;
- if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
- imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
- }
- else {
- i_clear_error();
- i_push_error(0, "Only images can be saved");
- myfree(imgs);
- RETVAL = 0;
- break;
- }
- }
- if (RETVAL) {
- RETVAL = i_writetiff_multi_wiol(ig, imgs, img_count);
- }
- myfree(imgs);
- }
- OUTPUT:
- RETVAL
-
-undef_int
-i_writetiff_wiol_faxable(im, ig, fine)
- Imager::ImgRaw im
- Imager::IO ig
- int fine
-
-undef_int
-i_writetiff_multi_wiol_faxable(ig, fine, ...)
- Imager::IO ig
- int fine
- PREINIT:
- int i;
- int img_count;
- i_img **imgs;
- CODE:
- if (items < 3)
- croak("Usage: i_writetiff_multi_wiol_faxable(ig, fine, images...)");
- img_count = items - 2;
- RETVAL = 1;
- if (img_count < 1) {
- RETVAL = 0;
- i_clear_error();
- i_push_error(0, "You need to specify images to save");
- }
- else {
- imgs = mymalloc(sizeof(i_img *) * img_count);
- for (i = 0; i < img_count; ++i) {
- SV *sv = ST(2+i);
- imgs[i] = NULL;
- if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
- imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
- }
- else {
- i_clear_error();
- i_push_error(0, "Only images can be saved");
- myfree(imgs);
- RETVAL = 0;
- break;
- }
- }
- if (RETVAL) {
- RETVAL = i_writetiff_multi_wiol_faxable(ig, imgs, img_count, fine);
- }
- myfree(imgs);
- }
- OUTPUT:
- RETVAL
-
-const char *
-i_tiff_libversion()
-
-bool
-i_tiff_has_compression(name)
- const char *name
-
-#endif /* HAVE_LIBTIFF */
-
-
-#ifdef HAVE_LIBPNG
-
-#endif
-
-
-#ifdef HAVE_LIBGIF
-
-void
-i_giflib_version()
- PPCODE:
- PUSHs(sv_2mortal(newSVnv(IM_GIFMAJOR+IM_GIFMINOR*0.1)));
-
-undef_int
-i_writegif(im,fd,colors,pixdev,fixed)
- Imager::ImgRaw im
- int fd
- int colors
- int pixdev
- PREINIT:
- int fixedlen;
- Imager__Color fixed;
- Imager__Color tmp;
- AV* av;
- SV* sv1;
- IV Itmp;
- int i;
- CODE:
- if (!SvROK(ST(4))) croak("Imager: Parameter 4 must be a reference to an array\n");
- if (SvTYPE(SvRV(ST(4))) != SVt_PVAV) croak("Imager: Parameter 4 must be a reference to an array\n");
- av=(AV*)SvRV(ST(4));
- fixedlen=av_len(av)+1;
- fixed=mymalloc( fixedlen*sizeof(i_color) );
- for(i=0;i<fixedlen;i++) {
- sv1=(*(av_fetch(av,i,0)));
- if (sv_derived_from(sv1, "Imager::Color")) {
- Itmp = SvIV((SV*)SvRV(sv1));
- tmp = INT2PTR(i_color*, Itmp);
- } else croak("Imager: one of the elements of array ref is not of Imager::Color type\n");
- fixed[i]=*tmp;
- }
- RETVAL=i_writegif(im,fd,colors,pixdev,fixedlen,fixed);
- myfree(fixed);
- ST(0) = sv_newmortal();
- if (RETVAL == 0) ST(0)=&PL_sv_undef;
- else sv_setiv(ST(0), (IV)RETVAL);
-
-
-
-
-undef_int
-i_writegifmc(im,fd,colors)
- Imager::ImgRaw im
- int fd
- int colors
-
-
-undef_int
-i_writegif_gen(fd, ...)
- int fd
- PROTOTYPE: $$@
- PREINIT:
- i_quantize quant;
- i_img **imgs = NULL;
- int img_count;
- int i;
- HV *hv;
- CODE:
- if (items < 3)
- croak("Usage: i_writegif_gen(fd,hashref, images...)");
- if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
- croak("i_writegif_gen: Second argument must be a hash ref");
- hv = (HV *)SvRV(ST(1));
- memset(&quant, 0, sizeof(quant));
- quant.mc_size = 256;
- quant.transp = tr_threshold;
- quant.tr_threshold = 127;
- handle_quant_opts(aTHX_ &quant, hv);
- img_count = items - 2;
- RETVAL = 1;
- if (img_count < 1) {
- RETVAL = 0;
- i_clear_error();
- i_push_error(0, "You need to specify images to save");
- }
- else {
- imgs = mymalloc(sizeof(i_img *) * img_count);
- for (i = 0; i < img_count; ++i) {
- SV *sv = ST(2+i);
- imgs[i] = NULL;
- if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
- imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
- }
- else {
- i_clear_error();
- i_push_error(0, "Only images can be saved");
- RETVAL = 0;
- break;
- }
- }
- if (RETVAL) {
- RETVAL = i_writegif_gen(&quant, fd, imgs, img_count);
- }
- myfree(imgs);
- if (RETVAL) {
- copy_colors_back(aTHX_ hv, &quant);
- }
- }
- ST(0) = sv_newmortal();
- if (RETVAL == 0) ST(0)=&PL_sv_undef;
- else sv_setiv(ST(0), (IV)RETVAL);
- cleanup_quant_opts(&quant);
-
-
-undef_int
-i_writegif_callback(cb, maxbuffer,...)
- int maxbuffer;
- PREINIT:
- i_quantize quant;
- i_img **imgs = NULL;
- int img_count;
- int i;
- HV *hv;
- i_writer_data wd;
- CODE:
- if (items < 4)
- croak("Usage: i_writegif_callback(\\&callback,maxbuffer,hashref, images...)");
- if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
- croak("i_writegif_callback: Second argument must be a hash ref");
- hv = (HV *)SvRV(ST(2));
- memset(&quant, 0, sizeof(quant));
- quant.mc_size = 256;
- quant.transp = tr_threshold;
- quant.tr_threshold = 127;
- handle_quant_opts(aTHX_ &quant, hv);
- img_count = items - 3;
- RETVAL = 1;
- if (img_count < 1) {
- RETVAL = 0;
- }
- else {
- imgs = mymalloc(sizeof(i_img *) * img_count);
- for (i = 0; i < img_count; ++i) {
- SV *sv = ST(3+i);
- imgs[i] = NULL;
- if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
- imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
- }
- else {
- RETVAL = 0;
- break;
- }
- }
- if (RETVAL) {
- wd.sv = ST(0);
- RETVAL = i_writegif_callback(&quant, write_callback, (char *)&wd, maxbuffer, imgs, img_count);
- }
- myfree(imgs);
- if (RETVAL) {
- copy_colors_back(aTHX_ hv, &quant);
- }
- }
- ST(0) = sv_newmortal();
- if (RETVAL == 0) ST(0)=&PL_sv_undef;
- else sv_setiv(ST(0), (IV)RETVAL);
- cleanup_quant_opts(&quant);
-
-undef_int
-i_writegif_wiol(ig, opts,...)
- Imager::IO ig
- PREINIT:
- i_quantize quant;
- i_img **imgs = NULL;
- int img_count;
- int i;
- HV *hv;
- CODE:
- if (items < 3)
- croak("Usage: i_writegif_wiol(IO,hashref, images...)");
- if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
- croak("i_writegif_callback: Second argument must be a hash ref");
- hv = (HV *)SvRV(ST(1));
- memset(&quant, 0, sizeof(quant));
- quant.mc_size = 256;
- quant.transp = tr_threshold;
- quant.tr_threshold = 127;
- handle_quant_opts(aTHX_ &quant, hv);
- img_count = items - 2;
- RETVAL = 1;
- if (img_count < 1) {
- RETVAL = 0;
- }
- else {
- imgs = mymalloc(sizeof(i_img *) * img_count);
- for (i = 0; i < img_count; ++i) {
- SV *sv = ST(2+i);
- imgs[i] = NULL;
- if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
- imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
- }
- else {
- RETVAL = 0;
- break;
- }
- }
- if (RETVAL) {
- RETVAL = i_writegif_wiol(ig, &quant, imgs, img_count);
- }
- myfree(imgs);
- if (RETVAL) {
- copy_colors_back(aTHX_ hv, &quant);
- }
- }
- ST(0) = sv_newmortal();
- if (RETVAL == 0) ST(0)=&PL_sv_undef;
- else sv_setiv(ST(0), (IV)RETVAL);
- cleanup_quant_opts(&quant);
-
-void
-i_readgif(fd)
- int fd
- PREINIT:
- int* colour_table;
- int colours, q, w;
- i_img* rimg;
- SV* temp[3];
- AV* ct;
- SV* r;
- PPCODE:
- colour_table = NULL;
- colours = 0;
-
- if(GIMME_V == G_ARRAY) {
- rimg = i_readgif(fd,&colour_table,&colours);
- } else {
- /* don't waste time with colours if they aren't wanted */
- rimg = i_readgif(fd,NULL,NULL);
- }
-
- if (colour_table == NULL) {
- EXTEND(SP,1);
- r=sv_newmortal();
- sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
- PUSHs(r);
- } else {
- /* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
- /* I don't know if I have the reference counts right or not :( */
- /* Neither do I :-) */
- /* No Idea here either */
-
- ct=newAV();
- av_extend(ct, colours);
- for(q=0; q<colours; q++) {
- for(w=0; w<3; w++)
- temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
- av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
- }
- myfree(colour_table);
-
- EXTEND(SP,2);
- r = sv_newmortal();
- sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
- PUSHs(r);
- PUSHs(newRV_noinc((SV*)ct));
- }
-
-void
-i_readgif_wiol(ig)
- Imager::IO ig
- PREINIT:
- int* colour_table;
- int colours, q, w;
- i_img* rimg;
- SV* temp[3];
- AV* ct;
- SV* r;
- PPCODE:
- colour_table = NULL;
- colours = 0;
-
- if(GIMME_V == G_ARRAY) {
- rimg = i_readgif_wiol(ig,&colour_table,&colours);
- } else {
- /* don't waste time with colours if they aren't wanted */
- rimg = i_readgif_wiol(ig,NULL,NULL);
- }
-
- if (colour_table == NULL) {
- EXTEND(SP,1);
- r=sv_newmortal();
- sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
- PUSHs(r);
- } else {
- /* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
- /* I don't know if I have the reference counts right or not :( */
- /* Neither do I :-) */
- /* No Idea here either */
-
- ct=newAV();
- av_extend(ct, colours);
- for(q=0; q<colours; q++) {
- for(w=0; w<3; w++)
- temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
- av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
- }
- myfree(colour_table);
-
- EXTEND(SP,2);
- r = sv_newmortal();
- sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
- PUSHs(r);
- PUSHs(newRV_noinc((SV*)ct));
- }
-
-Imager::ImgRaw
-i_readgif_single_wiol(ig, page=0)
- Imager::IO ig
- int page
-
-void
-i_readgif_scalar(...)
- PROTOTYPE: $
- PREINIT:
- char* data;
- STRLEN length;
- int* colour_table;
- int colours, q, w;
- i_img* rimg;
- SV* temp[3];
- AV* ct;
- SV* r;
- PPCODE:
- data = (char *)SvPV(ST(0), length);
- colour_table=NULL;
- colours=0;
-
- if(GIMME_V == G_ARRAY) {
- rimg=i_readgif_scalar(data,length,&colour_table,&colours);
- } else {
- /* don't waste time with colours if they aren't wanted */
- rimg=i_readgif_scalar(data,length,NULL,NULL);
- }
-
- if (colour_table == NULL) {
- EXTEND(SP,1);
- r=sv_newmortal();
- sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
- PUSHs(r);
- } else {
- /* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
- /* I don't know if I have the reference counts right or not :( */
- /* Neither do I :-) */
- ct=newAV();
- av_extend(ct, colours);
- for(q=0; q<colours; q++) {
- for(w=0; w<3; w++)
- temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
- av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
- }
- myfree(colour_table);
-
- EXTEND(SP,2);
- r=sv_newmortal();
- sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
- PUSHs(r);
- PUSHs(newRV_noinc((SV*)ct));
- }
-
-void
-i_readgif_callback(...)
- PROTOTYPE: &
- PREINIT:
- int* colour_table;
- int colours, q, w;
- i_img* rimg;
- SV* temp[3];
- AV* ct;
- SV* r;
- i_reader_data rd;
- PPCODE:
- rd.sv = ST(0);
- colour_table=NULL;
- colours=0;
-
- if(GIMME_V == G_ARRAY) {
- rimg=i_readgif_callback(read_callback, (char *)&rd,&colour_table,&colours);
- } else {
- /* don't waste time with colours if they aren't wanted */
- rimg=i_readgif_callback(read_callback, (char *)&rd,NULL,NULL);
- }
-
- if (colour_table == NULL) {
- EXTEND(SP,1);
- r=sv_newmortal();
- sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
- PUSHs(r);
- } else {
- /* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
- /* I don't know if I have the reference counts right or not :( */
- /* Neither do I :-) */
- /* Neither do I - maybe I'll move this somewhere */
- ct=newAV();
- av_extend(ct, colours);
- for(q=0; q<colours; q++) {
- for(w=0; w<3; w++)
- temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
- av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
- }
- myfree(colour_table);
-
- EXTEND(SP,2);
- r=sv_newmortal();
- sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
- PUSHs(r);
- PUSHs(newRV_noinc((SV*)ct));
- }
-
-void
-i_readgif_multi(fd)
- int fd
- PREINIT:
- i_img **imgs;
- int count;
- int i;
- PPCODE:
- imgs = i_readgif_multi(fd, &count);
- if (imgs) {
- EXTEND(SP, count);
- for (i = 0; i < count; ++i) {
- SV *sv = sv_newmortal();
- sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
- PUSHs(sv);
- }
- myfree(imgs);
- }
-
-void
-i_readgif_multi_scalar(data)
- PREINIT:
- i_img **imgs;
- int count;
- char *data;
- STRLEN length;
- int i;
- PPCODE:
- data = (char *)SvPV(ST(0), length);
- imgs = i_readgif_multi_scalar(data, length, &count);
- if (imgs) {
- EXTEND(SP, count);
- for (i = 0; i < count; ++i) {
- SV *sv = sv_newmortal();
- sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
- PUSHs(sv);
- }
- myfree(imgs);
- }
-
-void
-i_readgif_multi_callback(cb)
- PREINIT:
- i_reader_data rd;
- i_img **imgs;
- int count;
- int i;
- PPCODE:
- rd.sv = ST(0);
- imgs = i_readgif_multi_callback(read_callback, (char *)&rd, &count);
- if (imgs) {
- EXTEND(SP, count);
- for (i = 0; i < count; ++i) {
- SV *sv = sv_newmortal();
- sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
- PUSHs(sv);
- }
- myfree(imgs);
- }
-
-void
-i_readgif_multi_wiol(ig)
- Imager::IO ig
- PREINIT:
- i_img **imgs;
- int count;
- int i;
- PPCODE:
- imgs = i_readgif_multi_wiol(ig, &count);
- if (imgs) {
- EXTEND(SP, count);
- for (i = 0; i < count; ++i) {
- SV *sv = sv_newmortal();
- sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
- PUSHs(sv);
+ }
}
- myfree(imgs);
+ else {
+ ch = *text++;
+ --len;
+ }
+ EXTEND(SP, 1);
+ if ((outsize = i_tt_glyph_name(handle, ch, name, sizeof(name))) != 0) {
+ PUSHs(sv_2mortal(newSVpv(name, 0)));
+ }
+ else {
+ PUSHs(&PL_sv_undef);
+ }
}
+#endif
-#endif
-
-
+const char *
+i_test_format_probe(ig, length)
+ Imager::IO ig
+ int length
Imager::ImgRaw
i_readpnm_wiol(ig, allow_incomplete)
Imager::ImgRaw
i_readraw_wiol(ig,x,y,datachannels,storechannels,intrl)
Imager::IO ig
- int x
- int y
+ i_img_dim x
+ i_img_dim y
int datachannels
int storechannels
int intrl
Imager::ImgRaw
i_scaleaxis(im,Value,Axis)
Imager::ImgRaw im
- float Value
+ double Value
int Axis
Imager::ImgRaw
i_scale_nn(im,scx,scy)
Imager::ImgRaw im
- float scx
- float scy
+ double scx
+ double scy
Imager::ImgRaw
i_scale_mixing(im, width, height)
Imager::ImgRaw im
- int width
- int height
+ i_img_dim width
+ i_img_dim height
Imager::ImgRaw
i_haar(im)
Imager::ImgRaw im
PREINIT:
double* parm;
- int* opx;
- int* opy;
+ int *opx;
+ int *opy;
int opxl;
int opyl;
int parmlen;
AV *av_in_imgs
int channels
PREINIT:
- int width;
- int height;
+ i_img_dim width;
+ i_img_dim height;
struct rm_op *ops;
STRLEN ops_len;
int ops_count;
Imager::ImgRaw im
Imager::ImgRaw bump
int channel
- int light_x
- int light_y
- int strength
+ i_img_dim light_x
+ i_img_dim light_y
+ i_img_dim strength
void
Imager::ImgRaw im
Imager::ImgRaw bump
int channel
- int tx
- int ty
- float Lx
- float Ly
- float Lz
+ i_img_dim tx
+ i_img_dim ty
+ double Lx
+ double Ly
+ double Lz
float cd
float cs
float n
void
i_mosaic(im,size)
Imager::ImgRaw im
- int size
+ i_img_dim size
void
i_watermark(im,wmark,tx,ty,pixdiff)
Imager::ImgRaw im
Imager::ImgRaw wmark
- int tx
- int ty
+ i_img_dim tx
+ i_img_dim ty
int pixdiff
Imager::ImgRaw im
PREINIT:
int num;
- int *xo;
- int *yo;
+ i_img_dim *xo;
+ i_img_dim *yo;
i_color *ival;
int dmeasure;
int i;
num = num <= av_len(ac) ? num : av_len(ac);
num++;
if (num < 2) croak("Usage: i_gradgen array refs must have more than 1 entry each");
- xo = mymalloc( sizeof(int) * num );
- yo = mymalloc( sizeof(int) * num );
+ xo = mymalloc( sizeof(i_img_dim) * num );
+ yo = mymalloc( sizeof(i_img_dim) * num );
ival = mymalloc( sizeof(i_color) * num );
for(i = 0; i<num; i++) {
- xo[i] = (int)SvIV(* av_fetch(axx, i, 0));
- yo[i] = (int)SvIV(* av_fetch(ayy, i, 0));
+ xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0));
+ yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0));
sv = *av_fetch(ac, i, 0);
if ( !sv_derived_from(sv, "Imager::Color") ) {
free(axx); free(ayy); free(ac);
Imager::ImgRaw im
PREINIT:
int num;
- int *xo;
- int *yo;
+ i_img_dim *xo;
+ i_img_dim *yo;
i_color *ival;
int dmeasure;
int i;
num = num <= av_len(ac) ? num : av_len(ac);
num++;
if (num < 2) croak("Usage: i_nearest_color array refs must have more than 1 entry each");
- xo = mymalloc( sizeof(int) * num );
- yo = mymalloc( sizeof(int) * num );
+ xo = mymalloc( sizeof(i_img_dim) * num );
+ yo = mymalloc( sizeof(i_img_dim) * num );
ival = mymalloc( sizeof(i_color) * num );
for(i = 0; i<num; i++) {
- xo[i] = (int)SvIV(* av_fetch(axx, i, 0));
- yo[i] = (int)SvIV(* av_fetch(ayy, i, 0));
+ xo[i] = (i_img_dim)SvIV(* av_fetch(axx, i, 0));
+ yo[i] = (i_img_dim)SvIV(* av_fetch(ayy, i, 0));
sv = *av_fetch(ac, i, 0);
if ( !sv_derived_from(sv, "Imager::Color") ) {
free(axx); free(ayy); free(ac);
SV *
i_get_pixel(im, x, y)
Imager::ImgRaw im
- int x
- int y;
+ i_img_dim x
+ i_img_dim y;
PREINIT:
i_color *color;
CODE:
int
i_ppix(im, x, y, cl)
Imager::ImgRaw im
- int x
- int y
+ i_img_dim x
+ i_img_dim y
Imager::Color cl
Imager::ImgRaw
i_img_pal_new(x, y, channels, maxpal)
- int x
- int y
+ i_img_dim x
+ i_img_dim y
int channels
int maxpal
croak("i_img_to_pal: second argument must be a hash ref");
hv = (HV *)SvRV(ST(1));
memset(&quant, 0, sizeof(quant));
+ quant.version = 1;
quant.mc_size = 256;
- handle_quant_opts(aTHX_ &quant, hv);
+ ip_handle_quant_opts(aTHX_ &quant, hv);
RETVAL = i_img_to_pal(src, &quant);
if (RETVAL) {
- copy_colors_back(aTHX_ hv, &quant);
+ ip_copy_colors_back(aTHX_ hv, &quant);
}
- cleanup_quant_opts(&quant);
+ ip_cleanup_quant_opts(aTHX_ &quant);
OUTPUT:
RETVAL
void
i_gpal(im, l, r, y)
Imager::ImgRaw im
- int l
- int r
- int y
+ i_img_dim l
+ i_img_dim r
+ i_img_dim y
PREINIT:
i_palidx *work;
int count, i;
int
i_ppal(im, l, y, ...)
Imager::ImgRaw im
- int l
- int y
+ i_img_dim l
+ i_img_dim y
PREINIT:
i_palidx *work;
- int i;
+ i_img_dim i;
CODE:
if (items > 3) {
- work = mymalloc(sizeof(i_palidx) * (items-3));
+ work = malloc_temp(aTHX_ sizeof(i_palidx) * (items-3));
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);
}
else {
RETVAL = 0;
int
i_ppal_p(im, l, y, data)
Imager::ImgRaw im
- int l
- int y
+ i_img_dim l
+ i_img_dim y
SV *data
PREINIT:
i_palidx const *work;
void
i_gsamp(im, l, r, y, ...)
Imager::ImgRaw im
- int l
- int r
- int y
+ i_img_dim l
+ i_img_dim r
+ i_img_dim y
PREINIT:
int *chans;
int chan_count;
i_sample_t *data;
- int count, i;
+ i_img_dim count, i;
PPCODE:
if (items < 5)
croak("No channel numbers supplied to g_samp()");
undef_neg_int
i_gsamp_bits(im, l, r, y, bits, target, offset, ...)
Imager::ImgRaw im
- int l
- int r
- int y
+ i_img_dim l
+ i_img_dim r
+ i_img_dim y
int bits
AV *target
- int offset
+ STRLEN offset
PREINIT:
int *chans;
int chan_count;
unsigned *data;
- int count, i;
+ i_img_dim count, i;
CODE:
i_clear_error();
if (items < 8)
undef_neg_int
i_psamp_bits(im, l, y, bits, channels_sv, data_av, data_offset = 0, pixel_count = -1)
Imager::ImgRaw im
- int l
- int y
+ i_img_dim l
+ i_img_dim y
int bits
SV *channels_sv
AV *data_av
PREINIT:
int chan_count;
int *channels;
- int data_count;
- int data_used;
+ STRLEN data_count;
+ size_t data_used;
unsigned *data;
- int i;
+ ptrdiff_t i;
CODE:
i_clear_error();
if (SvOK(channels_sv)) {
Imager::ImgRaw
i_img_masked_new(targ, mask, x, y, w, h)
Imager::ImgRaw targ
- int x
- int y
- int w
- int h
+ i_img_dim x
+ i_img_dim y
+ i_img_dim w
+ i_img_dim h
PREINIT:
i_img *mask;
CODE:
int
i_plin(im, l, y, ...)
Imager::ImgRaw im
- int l
- int y
+ i_img_dim l
+ i_img_dim y
PREINIT:
i_color *work;
- int i;
+ STRLEN i;
STRLEN len;
- int count;
+ size_t count;
CODE:
if (items > 3) {
if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
int
i_ppixf(im, x, y, cl)
Imager::ImgRaw im
- int x
- int y
+ i_img_dim x
+ i_img_dim y
Imager::Color::Float cl
void
i_gsampf(im, l, r, y, ...)
Imager::ImgRaw im
- int l
- int r
- int y
+ i_img_dim l
+ i_img_dim r
+ i_img_dim y
PREINIT:
int *chans;
int chan_count;
i_fsample_t *data;
- int count, i;
+ i_img_dim count, i;
PPCODE:
if (items < 5)
croak("No channel numbers supplied to g_sampf()");
int
i_plinf(im, l, y, ...)
Imager::ImgRaw im
- int l
- int y
+ i_img_dim l
+ i_img_dim y
PREINIT:
i_fcolor *work;
- int i;
+ i_img_dim i;
STRLEN len;
- int count;
+ size_t count;
CODE:
if (items > 3) {
if (items == 4 && SvOK(ST(3)) && !SvROK(ST(3))) {
SV *
i_gpixf(im, x, y)
Imager::ImgRaw im
- int x
- int y;
+ i_img_dim x
+ i_img_dim y;
PREINIT:
i_fcolor *color;
CODE:
void
i_glin(im, l, r, y)
Imager::ImgRaw im
- int l
- int r
- int y
+ i_img_dim l
+ i_img_dim r
+ i_img_dim y
PREINIT:
i_color *vals;
- int count, i;
+ i_img_dim count, i;
PPCODE:
if (l < r) {
vals = mymalloc((r-l) * sizeof(i_color));
void
i_glinf(im, l, r, y)
Imager::ImgRaw im
- int l
- int r
- int y
+ i_img_dim l
+ i_img_dim r
+ i_img_dim y
PREINIT:
i_fcolor *vals;
- int count, i;
+ i_img_dim count, i;
i_fcolor zero;
PPCODE:
for (i = 0; i < MAXCHANNELS; ++i)
Imager::ImgRaw
i_img_16_new(x, y, ch)
- int x
- int y
+ i_img_dim x
+ i_img_dim y
int ch
Imager::ImgRaw
Imager::ImgRaw
i_img_double_new(x, y, ch)
- int x
- int y
+ i_img_dim x
+ i_img_dim y
int ch
+Imager::ImgRaw
+i_img_to_drgb(im)
+ Imager::ImgRaw im
+
undef_int
i_tags_addn(im, name, code, idata)
Imager::ImgRaw im
OUTPUT:
RETVAL
-#ifdef HAVE_WIN32
-
-void
-i_wf_bbox(face, size, text_sv, utf8=0)
- char *face
- int size
- SV *text_sv
- int utf8
- PREINIT:
- int cords[BOUNDING_BOX_COUNT];
- int rc, i;
- char const *text;
- STRLEN text_len;
- PPCODE:
- 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_sv, align, aa, utf8 = 0)
- char *face
- Imager::ImgRaw im
- int tx
- int ty
- Imager::Color cl
- int size
- SV *text_sv
- int align
- int aa
- int utf8
- PREINIT:
- char const *text;
- STRLEN text_len;
- CODE:
- 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_sv, align, aa, utf8 = 0)
- char *face
- Imager::ImgRaw im
- int tx
- int ty
- int channel
- int size
- SV *text_sv
- int align
- int aa
- int utf8
- PREINIT:
- char const *text;
- STRLEN text_len;
- CODE:
- 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
-
-undef_int
-i_wf_addfont(font)
- char *font
-
-undef_int
-i_wf_delfont(font)
- char *font
-
-#endif
-
-#ifdef HAVE_FT2
-
-MODULE = Imager PACKAGE = Imager::Font::FT2 PREFIX=FT2_
-
-#define FT2_DESTROY(font) i_ft2_destroy(font)
-
-void
-FT2_DESTROY(font)
- Imager::Font::FT2 font
-
-int
-FT2_CLONE_SKIP(...)
- CODE:
- RETVAL = 1;
- OUTPUT:
- RETVAL
-
-MODULE = Imager PACKAGE = Imager::Font::FreeType2
-
-Imager::Font::FT2
-i_ft2_new(name, index)
- char *name
- int index
-
-undef_int
-i_ft2_setdpi(font, xdpi, ydpi)
- Imager::Font::FT2 font
- int xdpi
- int ydpi
-
-void
-i_ft2_getdpi(font)
- Imager::Font::FT2 font
- PREINIT:
- int xdpi, ydpi;
- CODE:
- if (i_ft2_getdpi(font, &xdpi, &ydpi)) {
- EXTEND(SP, 2);
- PUSHs(sv_2mortal(newSViv(xdpi)));
- PUSHs(sv_2mortal(newSViv(ydpi)));
- }
-
-undef_int
-i_ft2_sethinting(font, hinting)
- Imager::Font::FT2 font
- int hinting
-
-undef_int
-i_ft2_settransform(font, matrix)
- Imager::Font::FT2 font
- PREINIT:
- double matrix[6];
- int len;
- AV *av;
- SV *sv1;
- int i;
- CODE:
- if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
- croak("i_ft2_settransform: parameter 2 must be an array ref\n");
- av=(AV*)SvRV(ST(1));
- len=av_len(av)+1;
- if (len > 6)
- len = 6;
- for (i = 0; i < len; ++i) {
- sv1=(*(av_fetch(av,i,0)));
- matrix[i] = SvNV(sv1);
- }
- for (; i < 6; ++i)
- matrix[i] = 0;
- RETVAL = i_ft2_settransform(font, matrix);
- OUTPUT:
- RETVAL
-
-void
-i_ft2_bbox(font, cheight, cwidth, text_sv, utf8)
- Imager::Font::FT2 font
- double cheight
- double cwidth
- SV *text_sv
- int utf8
- PREINIT:
- int bbox[BOUNDING_BOX_COUNT];
- int i;
- char *text;
- STRLEN text_len;
- int rc;
- PPCODE:
- text = SvPV(text_sv, text_len);
-#ifdef SvUTF8
- if (SvUTF8(text_sv))
- utf8 = 1;
-#endif
- rc = i_ft2_bbox(font, cheight, cwidth, text, text_len, bbox, utf8);
- if (rc) {
- EXTEND(SP, rc);
- for (i = 0; i < rc; ++i)
- PUSHs(sv_2mortal(newSViv(bbox[i])));
- }
-
-void
-i_ft2_bbox_r(font, cheight, cwidth, text, vlayout, utf8)
- Imager::Font::FT2 font
- double cheight
- double cwidth
- char *text
- int vlayout
- int utf8
- PREINIT:
- int bbox[8];
- int i;
- PPCODE:
-#ifdef SvUTF8
- if (SvUTF8(ST(3)))
- utf8 = 1;
-#endif
- if (i_ft2_bbox_r(font, cheight, cwidth, text, strlen(text), vlayout,
- utf8, bbox)) {
- EXTEND(SP, 8);
- for (i = 0; i < 8; ++i)
- PUSHs(sv_2mortal(newSViv(bbox[i])));
- }
-
-undef_int
-i_ft2_text(font, im, tx, ty, cl, cheight, cwidth, text, align, aa, vlayout, utf8)
- Imager::Font::FT2 font
- Imager::ImgRaw im
- int tx
- int ty
- Imager::Color cl
- double cheight
- double cwidth
- int align
- int aa
- int vlayout
- int utf8
- PREINIT:
- char *text;
- STRLEN len;
- CODE:
-#ifdef SvUTF8
- if (SvUTF8(ST(7))) {
- utf8 = 1;
- }
-#endif
- text = SvPV(ST(7), len);
- RETVAL = i_ft2_text(font, im, tx, ty, cl, cheight, cwidth, text,
- len, align, aa, vlayout, utf8);
- OUTPUT:
- RETVAL
-
-undef_int
-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 ty
- int channel
- double cheight
- double cwidth
- 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,
- len, align, aa, vlayout, 1);
- OUTPUT:
- RETVAL
-
-void
-ft2_transform_box(font, x0, x1, x2, x3)
- Imager::Font::FT2 font
- int x0
- int x1
- int x2
- int x3
- PREINIT:
- int box[4];
- PPCODE:
- box[0] = x0; box[1] = x1; box[2] = x2; box[3] = x3;
- ft2_transform_box(font, box);
- EXTEND(SP, 4);
- PUSHs(sv_2mortal(newSViv(box[0])));
- PUSHs(sv_2mortal(newSViv(box[1])));
- PUSHs(sv_2mortal(newSViv(box[2])));
- PUSHs(sv_2mortal(newSViv(box[3])));
-
-void
-i_ft2_has_chars(handle, text_sv, utf8)
- Imager::Font::FT2 handle
- SV *text_sv
- int utf8
- PREINIT:
- char *text;
- STRLEN len;
- char *work;
- int count;
- int i;
- PPCODE:
-#ifdef SvUTF8
- if (SvUTF8(text_sv))
- utf8 = 1;
-#endif
- text = SvPV(text_sv, len);
- work = mymalloc(len);
- count = i_ft2_has_chars(handle, text, len, utf8, work);
- if (GIMME_V == G_ARRAY) {
- EXTEND(SP, count);
- for (i = 0; i < count; ++i) {
- PUSHs(sv_2mortal(newSViv(work[i])));
- }
- }
- else {
- EXTEND(SP, 1);
- PUSHs(sv_2mortal(newSVpv(work, count)));
- }
- myfree(work);
-
-void
-i_ft2_face_name(handle)
- Imager::Font::FT2 handle
- PREINIT:
- char name[255];
- int len;
- PPCODE:
- len = i_ft2_face_name(handle, name, sizeof(name));
- if (len) {
- EXTEND(SP, 1);
- PUSHs(sv_2mortal(newSVpv(name, 0)));
- }
-
-undef_int
-i_ft2_can_face_name()
-
-void
-i_ft2_glyph_name(handle, text_sv, utf8 = 0, reliable_only = 1)
- Imager::Font::FT2 handle
- SV *text_sv
- int utf8
- int reliable_only
- PREINIT:
- char const *text;
- STRLEN work_len;
- int len;
- char name[255];
- PPCODE:
-#ifdef SvUTF8
- if (SvUTF8(text_sv))
- utf8 = 1;
-#endif
- text = SvPV(text_sv, work_len);
- len = work_len;
- while (len) {
- unsigned long ch;
- if (utf8) {
- ch = i_utf8_advance(&text, &len);
- if (ch == ~0UL) {
- i_push_error(0, "invalid UTF8 character");
- break;
- }
- }
- else {
- ch = *text++;
- --len;
- }
- EXTEND(SP, 1);
- if (i_ft2_glyph_name(handle, ch, name, sizeof(name),
- reliable_only)) {
- PUSHs(sv_2mortal(newSVpv(name, 0)));
- }
- else {
- PUSHs(&PL_sv_undef);
- }
- }
-
-int
-i_ft2_can_do_glyph_names()
-
-int
-i_ft2_face_has_glyph_names(handle)
- Imager::Font::FT2 handle
-
-int
-i_ft2_is_multiple_master(handle)
- Imager::Font::FT2 handle
-
-void
-i_ft2_get_multiple_masters(handle)
- Imager::Font::FT2 handle
- PREINIT:
- i_font_mm mm;
- int i;
- PPCODE:
- if (i_ft2_get_multiple_masters(handle, &mm)) {
- EXTEND(SP, 2+mm.num_axis);
- PUSHs(sv_2mortal(newSViv(mm.num_axis)));
- PUSHs(sv_2mortal(newSViv(mm.num_designs)));
- for (i = 0; i < mm.num_axis; ++i) {
- AV *av = newAV();
- SV *sv;
- av_extend(av, 3);
- sv = newSVpv(mm.axis[i].name, strlen(mm.axis[i].name));
- SvREFCNT_inc(sv);
- av_store(av, 0, sv);
- sv = newSViv(mm.axis[i].minimum);
- SvREFCNT_inc(sv);
- av_store(av, 1, sv);
- sv = newSViv(mm.axis[i].maximum);
- SvREFCNT_inc(sv);
- av_store(av, 2, sv);
- PUSHs(newRV_noinc((SV *)av));
- }
- }
-undef_int
-i_ft2_set_mm_coords(handle, ...)
- Imager::Font::FT2 handle
- PROTOTYPE: DISABLE
- PREINIT:
- long *coords;
- int ix_coords, i;
- CODE:
- /* T_ARRAY handling by xsubpp seems to be busted in 5.6.1, so
- transfer the array manually */
- ix_coords = items-1;
- coords = mymalloc(sizeof(long) * ix_coords);
- for (i = 0; i < ix_coords; ++i) {
- coords[i] = (long)SvIV(ST(1+i));
- }
- RETVAL = i_ft2_set_mm_coords(handle, ix_coords, coords);
- myfree(coords);
- OUTPUT:
- RETVAL
-
-#endif
MODULE = Imager PACKAGE = Imager::FillHandle PREFIX=IFILL_
int
IFILL_CLONE_SKIP(...)
CODE:
+ (void)items; /* avoid unused warning for XS variable */
RETVAL = 1;
OUTPUT:
RETVAL
Imager::Color bg
int combine
int hatch
- int dx
- int dy
+ i_img_dim dx
+ i_img_dim dy
PREINIT:
unsigned char *cust_hatch;
STRLEN len;
Imager::Color::Float bg
int combine
int hatch
- int dx
- int dy
+ i_img_dim dx
+ i_img_dim dy
PREINIT:
unsigned char *cust_hatch;
STRLEN len;
Imager::FillHandle
i_new_fill_image(src, matrix, xoff, yoff, combine)
Imager::ImgRaw src
- int xoff
- int yoff
+ i_img_dim xoff
+ i_img_dim yoff
int combine
PREINIT:
double matrix[9];
Imager::Internal::Hlines
i_int_hlines_new(start_y, count_y, start_x, count_x)
- int start_y
+ i_img_dim start_y
int count_y
- int start_x
+ i_img_dim start_x
int count_x
Imager::Internal::Hlines
void
i_int_hlines_add(hlines, y, minx, width)
Imager::Internal::Hlines hlines
- int y
- int minx
- int width
+ i_img_dim y
+ i_img_dim minx
+ i_img_dim width
void
i_int_hlines_DESTROY(hlines)
int
i_int_hlines_CLONE_SKIP(cls)
- SV *cls
#endif
BOOT:
PERL_SET_GLOBAL_CALLBACKS;
+ PERL_PL_SET_GLOBAL_CALLBACKS;
\ No newline at end of file