Initial Commit

This commit is contained in:
Riley Schneider
2025-12-03 16:38:10 +01:00
parent c5e26bf594
commit b732d8d4b5
17680 changed files with 5977495 additions and 2 deletions

View File

@@ -0,0 +1,22 @@
#include "imager.h"
typedef struct {
i_img_dim min,max;
} minmax;
typedef struct {
minmax *data;
i_img_dim lines;
} i_mmarray;
/* FIXME: Merge this into datatypes.{c,h} */
void i_mmarray_cr(i_mmarray *ar,i_img_dim l);
void i_mmarray_dst(i_mmarray *ar);
void i_mmarray_add(i_mmarray *ar,i_img_dim x,i_img_dim y);
i_img_dim i_mmarray_gmin(i_mmarray *ar,i_img_dim y);
i_img_dim i_mmarray_getm(i_mmarray *ar,i_img_dim y);
void i_mmarray_info(i_mmarray *ar);
#if 0
void i_mmarray_render(i_img *im,i_mmarray *ar,i_color *val);
#endif

View File

@@ -0,0 +1,58 @@
#ifndef _DYNALOAD_H_
#define _DYNALOAD_H_
#include "log.h"
#include "EXTERN.h"
#include "perl.h"
#include "ppport.h"
#include "ext.h"
typedef struct DSO_handle_tag DSO_handle;
typedef struct {
HV* hv;
char *key;
void *store;
} UTIL_args;
#if 0
int getobj(void *hv_t,char *key,char *type,void **store);
int getint(void *hv_t,char *key,int *store);
int getdouble(void *hv_t,char *key,double *store);
int getvoid(void *hv_t,char *key,void **store);
#endif
void *DSO_open(char* file,char** evalstring);
func_ptr *DSO_funclist(DSO_handle *handle);
int DSO_close(void *);
void DSO_call(DSO_handle *handle,int func_index,HV* hv);
#ifdef __EMX__ /* OS/2 */
# ifndef RTLD_LAZY
# define RTLD_LAZY 0
# endif /* RTLD_LAZY */
int dlclose(minthandle_t);
#endif /* __EMX__ */
#ifdef DLSYMUN
#define I_EVALSTR "_evalstr"
#define I_SYMBOL_TABLE "_symbol_table"
#define I_UTIL_TABLE "_util_table"
#define I_FUNCTION_LIST "_function_list"
#define I_INSTALL_TABLES "_install_tables"
#else
#define I_EVALSTR "evalstr"
#define I_SYMBOL_TABLE "symbol_table"
#define I_UTIL_TABLE "util_table"
#define I_FUNCTION_LIST "function_list"
#define I_INSTALL_TABLES "install_tables"
#endif
#endif /* _DYNALOAD_H_ */

View File

@@ -0,0 +1,50 @@
#include "imdatatypes.h"
#ifndef IMAGER_EXT_H
#define IMAGER_EXT_H
/* structures for passing data between Imager-plugin and the Imager-module */
typedef struct {
char *name;
void (*iptr)(void* ptr);
char *pcode;
} func_ptr;
typedef struct {
int (*getstr)(void *hv_t,char* key,char **store);
int (*getint)(void *hv_t,char *key,int *store);
int (*getdouble)(void *hv_t,char* key,double *store);
int (*getvoid)(void *hv_t,char* key,void **store);
int (*getobj)(void *hv_t,char* key,char* type,void **store);
} UTIL_table_t;
typedef struct {
undef_int (*i_has_format)(char *frmt);
i_color*(*ICL_set)(i_color *cl,unsigned char r,unsigned char g,unsigned char b,unsigned char a);
void (*ICL_info)(const i_color *cl);
im_context_t (*im_get_context_f)(void);
i_img*(*im_img_empty_ch_f)(im_context_t, i_img *im,i_img_dim x,i_img_dim y,int ch);
void(*i_img_exorcise_f)(i_img *im);
void(*i_img_info_f)(i_img *im,i_img_dim *info);
void(*i_img_setmask_f)(i_img *im,int ch_mask);
int (*i_img_getmask_f)(i_img *im);
/*
int (*i_ppix)(i_img *im,i_img_dim x,i_img_dim y,i_color *val);
int (*i_gpix)(i_img *im,i_img_dim x,i_img_dim y,i_color *val);
*/
void(*i_box)(i_img *im,i_img_dim x1,i_img_dim y1,i_img_dim x2,i_img_dim y2,const i_color *val);
void(*i_line)(i_img *im,i_img_dim x1,i_img_dim y1,i_img_dim x2,i_img_dim y2,const i_color *val,int endp);
void(*i_arc)(i_img *im,i_img_dim x,i_img_dim y,double rad,double d1,double d2,const i_color *val);
void(*i_copyto)(i_img *im,i_img *src,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)(i_img *im,i_img *src,i_img_dim x1,i_img_dim y1,i_img_dim x2,i_img_dim y2,i_img_dim tx,i_img_dim ty,const i_color *trans);
int(*i_rubthru)(i_img *im,i_img *src,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);
} symbol_table_t;
#endif

View File

@@ -0,0 +1,34 @@
#include "imager.h"
static char *i_format_list[]={
#ifdef HAVE_LIBJPEG
"jpeg",
#endif
#ifdef HAVE_LIBTIFF
"tiff",
#endif
#ifdef HAVE_LIBPNG
"png",
#endif
#ifdef HAVE_LIBGIF
"gif",
#endif
#ifdef HAVE_LIBT1
"t1",
#endif
#ifdef HAVE_LIBTT
"tt",
#endif
#ifdef HAVE_WIN32
"w32",
#endif
#ifdef HAVE_FT2
"ft2",
#endif
"raw",
"pnm",
"bmp",
"tga",
"ifs",
NULL};

View File

@@ -0,0 +1,420 @@
#ifndef _IMAGE_H_
#define _IMAGE_H_
#include "imconfig.h"
#include "immacros.h"
#include "imio.h"
#include "iolayer.h"
#include "stackmach.h"
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#ifdef SUNOS
#include <strings.h>
#endif
#ifndef PI
#define PI 3.14159265358979323846
#endif
#include "imdatatypes.h"
undef_int i_has_format(char *frmt);
/* constructors and destructors */
i_color *ICL_new_internal( unsigned char r,unsigned char g,unsigned char b,unsigned char a);
i_color *ICL_set_internal(i_color *cl,unsigned char r,unsigned char g,unsigned char b,unsigned char a);
void ICL_info (const i_color *cl);
void ICL_DESTROY (i_color *cl);
void ICL_add (i_color *dst, i_color *src, int ch);
extern i_fcolor *i_fcolor_new(double r, double g, double b, double a);
extern void i_fcolor_destroy(i_fcolor *cl);
extern void i_rgb_to_hsvf(i_fcolor *color);
extern void i_hsv_to_rgbf(i_fcolor *color);
extern void i_rgb_to_hsv(i_color *color);
extern void i_hsv_to_rgb(i_color *color);
i_img *im_img_8_new(pIMCTX, i_img_dim x,i_img_dim y,int ch);
#define i_img_empty(im, x, y) i_img_empty_ch((im), (x), (y), 3)
i_img *im_img_empty_ch(pIMCTX, i_img *im,i_img_dim x,i_img_dim y,int ch);
#define i_img_empty_ch(im, x, y, ch) im_img_empty_ch(aIMCTX, (im), (x), (y), (ch))
void i_img_exorcise(i_img *im);
void i_img_destroy(i_img *im);
i_img *im_img_alloc(pIMCTX);
void im_img_init(pIMCTX, i_img *im);
void i_img_info(i_img *im,i_img_dim *info);
extern i_img *i_sametype(i_img *im, i_img_dim xsize, i_img_dim ysize);
extern i_img *i_sametype_chans(i_img *im, i_img_dim xsize, i_img_dim ysize, int channels);
/* Image feature settings */
void i_img_setmask (i_img *im,int ch_mask);
int i_img_getmask (i_img *im);
int i_img_getchannels(i_img *im);
i_img_dim i_img_get_width(i_img *im);
i_img_dim i_img_get_height(i_img *im);
i_color_model_t i_img_color_model(i_img *im);
int i_img_alpha_channel(i_img *im, int *channel);
int i_img_color_channels(i_img *im);
/* Base functions */
extern int (i_ppix)(i_img *im,i_img_dim x,i_img_dim y, const i_color *val);
extern int (i_gpix)(i_img *im,i_img_dim x,i_img_dim y,i_color *val);
extern int (i_ppixf)(i_img *im,i_img_dim x,i_img_dim y, const i_fcolor *val);
extern int (i_gpixf)(i_img *im,i_img_dim x,i_img_dim y,i_fcolor *val);
extern i_img_dim (i_plin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y,
const i_color *vals);
extern i_img_dim (i_glin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y,
i_color *vals);
extern i_img_dim (i_plinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y,
const i_fcolor *vals);
extern i_img_dim (i_glinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y,
i_fcolor *vals);
extern i_img_dim (i_gsamp)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y,
i_sample_t *samp, const int *chans, int chan_count);
extern i_img_dim
(i_gsampf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samp,
const int *chans, int chan_count);
extern i_img_dim
(i_gpal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, i_palidx *vals);
extern i_img_dim
(i_ppal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, const i_palidx *vals);
extern int (i_addcolors)(i_img *im, const i_color *colors, int count);
extern int (i_getcolors)(i_img *im, int i, i_color *, int count);
extern int (i_colorcount)(i_img *im);
extern int (i_maxcolors)(i_img *im);
extern int (i_findcolor)(i_img *im, const i_color *color, i_palidx *entry);
extern int (i_setcolors)(i_img *im, int index, const i_color *colors,
int count);
extern i_fill_t *i_new_fill_solidf(const i_fcolor *c, int combine);
extern i_fill_t *i_new_fill_solid(const i_color *c, int combine);
extern i_fill_t *
i_new_fill_hatch(const i_color *fg, const i_color *bg, int combine, int hatch,
const unsigned char *cust_hatch, i_img_dim dx, i_img_dim dy);
extern i_fill_t *
i_new_fill_hatchf(const i_fcolor *fg, const i_fcolor *bg, int combine, int hatch,
const unsigned char *cust_hatch, i_img_dim dx, i_img_dim dy);
extern i_fill_t *
i_new_fill_image(i_img *im, const double *matrix, i_img_dim xoff, i_img_dim yoff, int combine);
extern i_fill_t *i_new_fill_opacity(i_fill_t *, double alpha_mult);
extern void i_fill_destroy(i_fill_t *fill);
float i_gpix_pch(i_img *im,i_img_dim x,i_img_dim y,int ch);
/* functions for drawing primitives */
void i_box (i_img *im,i_img_dim x1,i_img_dim y1,i_img_dim x2,i_img_dim y2,const i_color *val);
void i_box_filled (i_img *im,i_img_dim x1,i_img_dim y1,i_img_dim x2,i_img_dim y2,const i_color *val);
int i_box_filledf (i_img *im,i_img_dim x1,i_img_dim y1,i_img_dim x2,i_img_dim y2,const i_fcolor *val);
void i_box_cfill(i_img *im, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, i_fill_t *fill);
void i_line (i_img *im,i_img_dim x1,i_img_dim y1,i_img_dim x2,i_img_dim y2,const i_color *val, int endp);
void i_line_aa (i_img *im,i_img_dim x1,i_img_dim y1,i_img_dim x2,i_img_dim y2,const i_color *val, int endp);
void i_arc (i_img *im,i_img_dim x,i_img_dim y,double rad,double d1,double d2,const i_color *val);
int i_arc_out(i_img *im,i_img_dim x,i_img_dim y,i_img_dim rad,double d1,double d2,const i_color *val);
int i_arc_out_aa(i_img *im,i_img_dim x,i_img_dim y,i_img_dim rad,double d1,double d2,const i_color *val);
void i_arc_aa (i_img *im, double x, double y, double rad, double d1, double d2, const i_color *val);
void i_arc_cfill(i_img *im,i_img_dim x,i_img_dim y,double rad,double d1,double d2,i_fill_t *fill);
void i_arc_aa_cfill(i_img *im,double x,double y,double rad,double d1,double d2,i_fill_t *fill);
void i_circle_aa (i_img *im,double x, double y,double rad,const i_color *val);
void i_circle_aa_fill(i_img *im,double x, double y,double rad,i_fill_t *fill);
int i_circle_out (i_img *im,i_img_dim x, i_img_dim y, i_img_dim rad,const i_color *val);
int i_circle_out_aa (i_img *im,i_img_dim x, i_img_dim y, i_img_dim rad,const i_color *val);
void i_copyto (i_img *im,i_img *src,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(i_img *im,i_img *src,i_img_dim x1,i_img_dim y1,i_img_dim x2,i_img_dim y2,i_img_dim tx,i_img_dim ty,const i_color *trans);
i_img* i_copy (i_img *src);
int i_rubthru (i_img *im, i_img *src, 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);
extern int
i_compose_mask(i_img *out, i_img *src, i_img *mask,
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);
extern int
i_compose(i_img *out, i_img *src,
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);
extern i_img *
i_combine(i_img **src, const int *channels, int in_count);
undef_int i_flipxy (i_img *im, int direction);
extern i_img *i_rotate90(i_img *im, int degrees);
extern i_img *i_rotate_exact(i_img *im, double amount);
extern i_img *i_rotate_exact_bg(i_img *im, double amount, const i_color *backp, const i_fcolor *fbackp);
extern i_img *i_matrix_transform(i_img *im, i_img_dim xsize, i_img_dim ysize, const double *matrix);
extern i_img *i_matrix_transform_bg(i_img *im, i_img_dim xsize, i_img_dim ysize, const double *matrix, const i_color *backp, const i_fcolor *fbackp);
void i_bezier_multi(i_img *im,int l,const double *x,const double *y,const i_color *val);
int i_poly_aa (i_img *im,int l,const double *x,const double *y,const i_color *val);
int i_poly_aa_cfill(i_img *im,int l,const double *x,const double *y,i_fill_t *fill);
int i_poly_aa_m (i_img *im,int l,const double *x,const double *y, i_poly_fill_mode_t mode, const i_color *val);
int i_poly_aa_cfill_m(i_img *im,int l,const double *x,const double *y, i_poly_fill_mode_t mode, i_fill_t *fill);
extern int
i_poly_poly_aa(i_img *im, int count, const i_polygon_t *polys,
i_poly_fill_mode_t mode, const i_color *val);
extern int
i_poly_poly_aa_cfill(i_img *im, int count, const i_polygon_t *polys,
i_poly_fill_mode_t mode, i_fill_t *fill);
undef_int i_flood_fill (i_img *im,i_img_dim seedx,i_img_dim seedy, const i_color *dcol);
undef_int i_flood_cfill(i_img *im, i_img_dim seedx, i_img_dim seedy, i_fill_t *fill);
undef_int i_flood_fill_border (i_img *im,i_img_dim seedx,i_img_dim seedy, const i_color *dcol, const i_color *border);
undef_int i_flood_cfill_border(i_img *im, i_img_dim seedx, i_img_dim seedy, i_fill_t *fill, const i_color *border);
/* image processing functions */
int i_gaussian (i_img *im, double stddev);
int i_gaussian2 (i_img *im, double stddevX, double stddevY);
int i_conv (i_img *im,const double *coeff,int len);
void i_unsharp_mask(i_img *im, double stddev, double scale);
/* colour manipulation */
extern i_img *i_convert(i_img *src, const double *coeff, int outchan, int inchan);
extern void i_map(i_img *im, unsigned char (*maps)[256], unsigned int mask);
float i_img_diff (i_img *im1,i_img *im2);
double i_img_diffd(i_img *im1,i_img *im2);
int i_img_samef(i_img *im1,i_img *im2, double epsilon, const char *what);
/* font routines */
#ifdef HAVE_LIBTT
extern void i_tt_start(void);
TT_Fonthandle* i_tt_new(const char *fontname);
void i_tt_destroy( TT_Fonthandle *handle );
undef_int i_tt_cp( TT_Fonthandle *handle,i_img *im,i_img_dim xb,i_img_dim yb,int channel,double points,char const* txt,size_t len,int smooth, int utf8, int align);
undef_int i_tt_text( TT_Fonthandle *handle, i_img *im, i_img_dim xb, i_img_dim yb, const i_color *cl, double points, char const* txt, size_t len, int smooth, int utf8, int align);
undef_int i_tt_bbox( TT_Fonthandle *handle, double points,const char *txt,size_t len,i_img_dim cords[6], int utf8);
size_t i_tt_has_chars(TT_Fonthandle *handle, char const *text, size_t len, int utf8, char *out);
void i_tt_dump_names(TT_Fonthandle *handle);
size_t i_tt_face_name(TT_Fonthandle *handle, char *name_buf,
size_t name_buf_size);
size_t i_tt_glyph_name(TT_Fonthandle *handle, unsigned long ch, char *name_buf,
size_t name_buf_size);
#endif /* End of freetype headers */
extern void i_quant_makemap(i_quantize *quant, i_img **imgs, int count);
extern i_palidx *i_quant_translate(i_quantize *quant, i_img *img);
extern void i_quant_transparent(i_quantize *quant, i_palidx *indices, i_img *img, i_palidx trans_index);
i_img *im_img_pal_new(pIMCTX, i_img_dim x, i_img_dim y, int ch, int maxpal);
extern i_img *i_img_to_pal(i_img *src, i_quantize *quant);
extern i_img *i_img_to_rgb(i_img *src);
extern i_img *i_img_masked_new(i_img *targ, i_img *mask, i_img_dim x, i_img_dim y,
i_img_dim w, i_img_dim h);
extern i_img *im_img_16_new(pIMCTX, i_img_dim x, i_img_dim y, int ch);
extern i_img *i_img_to_rgb16(i_img *im);
extern i_img *im_img_double_new(pIMCTX, i_img_dim x, i_img_dim y, int ch);
extern i_img *i_img_to_drgb(i_img *im);
extern int i_img_is_monochrome(i_img *im, int *zero_is_white);
extern int i_get_file_background(i_img *im, i_color *bg);
extern int i_get_file_backgroundf(i_img *im, i_fcolor *bg);
const char * im_test_format_probe(im_context_t ctx, io_glue *data, int length);
#define i_test_format_probe(io, length) im_test_format_probe(aIMCTX, (io), (length))
/* file type magic to extend file detection */
extern int im_add_file_magic(im_context_t ctx, const char *name,
const unsigned char *bits, const unsigned char *mask,
size_t length);
#define i_add_file_magic(name, bits, mask, length) \
im_add_file_magic(aIMCTX, (name), (bits), (mask), (length))
i_img * i_readraw_wiol(io_glue *ig, i_img_dim x, i_img_dim y, int datachannels, int storechannels, int intrl);
undef_int i_writeraw_wiol(i_img* im, io_glue *ig);
i_img * i_readpnm_wiol(io_glue *ig, int allow_incomplete);
i_img ** i_readpnm_multi_wiol(io_glue *ig, int *count, int allow_incomplete);
undef_int i_writeppm_wiol(i_img *im, io_glue *ig);
extern int i_writebmp_wiol(i_img *im, io_glue *ig);
extern i_img *i_readbmp_wiol(io_glue *ig, int allow_incomplete);
int tga_header_verify(unsigned char headbuf[18]);
i_img * i_readtga_wiol(io_glue *ig, int length);
undef_int i_writetga_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen);
i_img * i_readrgb_wiol(io_glue *ig, int length);
undef_int i_writergb_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen);
i_img * i_scaleaxis(i_img *im, double Value, int Axis);
i_img * i_scale_nn(i_img *im, double scx, double scy);
i_img * i_scale_mixing(i_img *src, i_img_dim width, i_img_dim height);
i_img * i_haar(i_img *im);
int i_count_colors(i_img *im,int maxc);
int i_get_anonymous_color_histo(i_img *im, unsigned int **col_usage, int maxc);
i_img * i_transform(i_img *im, int *opx, int opxl, int *opy,int opyl,double parm[],int parmlen);
struct rm_op;
i_img * i_transform2(i_img_dim width, i_img_dim height, int channels,
struct rm_op *ops, int ops_count,
double *n_regs, int n_regs_count,
i_color *c_regs, int c_regs_count,
i_img **in_imgs, int in_imgs_count);
/* filters */
void i_contrast(i_img *im, float intensity);
void i_hardinvert(i_img *im);
void i_hardinvertall(i_img *im);
void i_noise(i_img *im, float amount, unsigned char type);
void i_bumpmap(i_img *im,i_img *bump,int channel,i_img_dim light_x,i_img_dim light_y,i_img_dim strength);
void i_bumpmap_complex(i_img *im, i_img *bump, int channel, i_img_dim tx, i_img_dim ty, double Lx, double Ly,
double Lz, float cd, float cs, float n, i_color *Ia, i_color *Il, i_color *Is);
void i_postlevels(i_img *im,int levels);
void i_mosaic(i_img *im,i_img_dim size);
void i_watermark(i_img *im,i_img *wmark,i_img_dim tx,i_img_dim ty,int pixdiff);
void i_autolevels(i_img *im,float lsat,float usat,float skew);
void i_autolevels_mono(i_img *im,float lsat,float usat);
void i_radnoise(i_img *im,i_img_dim xo,i_img_dim yo,double rscale,double ascale);
void i_turbnoise(i_img *im,double xo,double yo,double scale);
void i_gradgen(i_img *im, int num, i_img_dim *xo, i_img_dim *yo, i_color *ival, int dmeasure);
int i_nearest_color(i_img *im, int num, i_img_dim *xo, i_img_dim *yo, i_color *ival, int dmeasure);
i_img *i_diff_image(i_img *im, i_img *im2, double mindist);
int
i_fountain(i_img *im, double xa, double ya, double xb, double yb,
i_fountain_type type, i_fountain_repeat repeat,
int combine, int super_sample, double ssample_param,
int count, i_fountain_seg *segs);
extern i_fill_t *
i_new_fill_fount(double xa, double ya, double xb, double yb,
i_fountain_type type, i_fountain_repeat repeat,
int combine, int super_sample, double ssample_param,
int count, i_fountain_seg *segs);
/* Debug only functions */
void malloc_state( void );
#include "imerror.h"
/* image tag processing */
extern void i_tags_new(i_img_tags *tags);
extern int i_tags_addn(i_img_tags *tags, char const *name, int code,
int idata);
extern int i_tags_add(i_img_tags *tags, char const *name, int code,
char const *data, int size, int idata);
extern int i_tags_set(i_img_tags *tags, char const *name,
char const *data, int size);
extern int i_tags_setn(i_img_tags *tags, char const *name, int idata);
extern void i_tags_destroy(i_img_tags *tags);
extern int i_tags_find(i_img_tags *tags, char const *name, int start,
int *entry);
extern int i_tags_findn(i_img_tags *tags, int code, int start, int *entry);
extern int i_tags_delete(i_img_tags *tags, int entry);
extern int i_tags_delbyname(i_img_tags *tags, char const *name);
extern int i_tags_delbycode(i_img_tags *tags, int code);
extern int i_tags_get_float(i_img_tags *tags, char const *name, int code,
double *value);
extern int i_tags_set_float(i_img_tags *tags, char const *name, int code,
double value);
extern int i_tags_set_float2(i_img_tags *tags, char const *name, int code,
double value, int places);
extern int i_tags_get_int(i_img_tags *tags, char const *name, int code,
int *value);
extern int i_tags_get_string(i_img_tags *tags, char const *name, int code,
char *value, size_t value_size);
extern int i_tags_get_color(i_img_tags *tags, char const *name, int code,
i_color *value);
extern int i_tags_set_color(i_img_tags *tags, char const *name, int code,
i_color const *value);
extern void i_tags_print(i_img_tags *tags);
/* image file limits */
extern int
im_set_image_file_limits(im_context_t ctx, i_img_dim width, i_img_dim height, size_t bytes);
extern int
im_get_image_file_limits(im_context_t ctx, i_img_dim *width, i_img_dim *height, size_t *bytes);
extern int
im_int_check_image_file_limits(im_context_t ctx, i_img_dim width, i_img_dim height, int channels, size_t sample_size);
/* memory allocation */
void* mymalloc(size_t size);
void myfree(void *p);
void* myrealloc(void *p, size_t newsize);
void* mymalloc_file_line (size_t size, char* file, int line);
void myfree_file_line (void *p, char*file, int line);
void* myrealloc_file_line(void *p, size_t newsize, char* file,int line);
#ifdef IMAGER_DEBUG_MALLOC
#define mymalloc(x) (mymalloc_file_line((x), __FILE__, __LINE__))
#define myrealloc(x,y) (myrealloc_file_line((x),(y), __FILE__, __LINE__))
#define myfree(x) (myfree_file_line((x), __FILE__, __LINE__))
void malloc_state (void);
void bndcheck_all (void);
#else
void malloc_state(void);
#endif /* IMAGER_MALLOC_DEBUG */
#include "imrender.h"
extern void
i_adapt_colors(int dest_channels, int src_channels, i_color *colors,
size_t count);
extern void
i_adapt_fcolors(int dest_channels, int src_channels, i_fcolor *colors,
size_t count);
extern void
i_adapt_colors_bg(int dest_channels, int src_channels, i_color *colors,
size_t count, i_color const *bg);
extern void
i_adapt_fcolors_bg(int dest_channels, int src_channels, i_fcolor *colors,
size_t count, i_fcolor const *bg);
extern int
i_gsamp_bg(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_sample_t *samples,
int out_channels, i_color const *bg);
extern int
i_gsampf_bg(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samples,
int out_channels, i_fcolor const *bg);
/* context object management */
extern im_context_t im_context_new(void);
extern void im_context_refinc(im_context_t ctx, const char *where);
extern void im_context_refdec(im_context_t ctx, const char *where);
extern im_context_t im_context_clone(im_context_t ctx, const char *where);
extern im_slot_t im_context_slot_new(im_slot_destroy_t);
extern void *im_context_slot_get(im_context_t ctx, im_slot_t slot);
extern int im_context_slot_set(im_context_t ctx, im_slot_t slot, void *);
extern im_context_t (*im_get_context)(void);
/* mutex API */
extern i_mutex_t i_mutex_new(void);
extern void i_mutex_destroy(i_mutex_t m);
extern void i_mutex_lock(i_mutex_t m);
extern void i_mutex_unlock(i_mutex_t m);
#include "imio.h"
#endif

View File

@@ -0,0 +1,167 @@
/* Declares utility functions useful across various files which
aren't meant to be available externally
*/
#ifndef IMAGEI_H_
#define IMAGEI_H_
#include "imager.h"
#include <stddef.h>
/* wrapper functions that implement the floating point sample version of a
function in terms of the 8-bit sample version
*/
extern int i_ppixf_fp(i_img *im, i_img_dim x, i_img_dim y, const i_fcolor *pix);
extern int i_gpixf_fp(i_img *im, i_img_dim x, i_img_dim y, i_fcolor *pix);
extern i_img_dim i_plinf_fp(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_fcolor *pix);
extern i_img_dim i_glinf_fp(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fcolor *pix);
extern i_img_dim i_gsampf_fp(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samp,
int const *chans, int chan_count);
/* wrapper functions that forward palette calls to the underlying image,
assuming the underlying image is the first pointer in whatever
ext_data points at
*/
extern int i_addcolors_forward(i_img *im, const i_color *, int count);
extern int i_getcolors_forward(i_img *im, int i, i_color *, int count);
extern int i_colorcount_forward(i_img *im);
extern int i_maxcolors_forward(i_img *im);
extern int i_findcolor_forward(i_img *im, const i_color *color,
i_palidx *entry);
extern int i_setcolors_forward(i_img *im, int index, const i_color *colors,
int count);
/* fallback handler for gsamp_bits */
extern i_img_dim i_gsamp_bits_fb(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, unsigned *samp,
const int *chans, int chan_count, int bits);
#define SampleFTo16(num) ((int)((num) * 65535.0 + 0.5))
/* we add that little bit to avoid rounding issues */
#define Sample16ToF(num) ((num) / 65535.0)
#define SampleFTo8(num) ((int)((num) * 255.0 + 0.5))
#define Sample8ToF(num) ((num) / 255.0)
#define Sample16To8(num) (((num)+128) / 257)
#define Sample8To16(num) ((num) * 257)
extern void i_get_combine(int combine, i_fill_combine_f *, i_fill_combinef_f *);
#define im_min(a, b) ((a) < (b) ? (a) : (b))
#define im_max(a, b) ((a) > (b) ? (a) : (b))
#include "ext.h"
extern UTIL_table_t i_UTIL_table;
/* test if all channels are writable */
#define I_ALL_CHANNELS_WRITABLE(im) (((im)->ch_mask & 0xF) == 0xf)
typedef struct i_int_hline_seg_tag {
i_img_dim minx, x_limit;
} i_int_hline_seg;
typedef struct i_int_hline_entry_tag {
i_img_dim count;
size_t alloc;
i_int_hline_seg segs[1];
} i_int_hline_entry;
/* represents a set of horizontal line segments to be filled in later */
typedef struct i_int_hlines_tag {
i_img_dim start_y, limit_y;
i_img_dim start_x, limit_x;
i_int_hline_entry **entries;
} i_int_hlines;
extern void
i_int_init_hlines(
i_int_hlines *hlines,
i_img_dim start_y,
i_img_dim count_y,
i_img_dim start_x,
i_img_dim width_x
);
extern void i_int_init_hlines_img(i_int_hlines *hlines, i_img *img);
extern void i_int_hlines_add(i_int_hlines *hlines, i_img_dim y, i_img_dim minx, i_img_dim width);
extern void i_int_hlines_destroy(i_int_hlines *hlines);
extern void i_int_hlines_fill_color(i_img *im, i_int_hlines *hlines, const i_color *val);
extern void i_int_hlines_fill_fill(i_img *im, i_int_hlines *hlines, i_fill_t *fill);
#define I_LIMIT_8(x) ((x) < 0 ? 0 : (x) > 255 ? 255 : (x))
#define I_LIMIT_DOUBLE(x) ((x) < 0.0 ? 0.0 : (x) > 1.0 ? 1.0 : (x))
#define IM_STRING(x) #x
/* I considered using assert.h here, but perl does it's own thing with
assert() and the NDEBUG test is opposite to the direction I prefer */
#ifdef IM_ASSERT
extern void im_assert_fail(char const *, int, char const *);
#define im_assert(x) ((x) ? (void)(0) : im_assert_fail(__FILE__, __LINE__, IM_STRING(x)))
#else
#define im_assert(x) (void)(0)
#endif
i_img_dim i_minx(i_img_dim a, i_img_dim b);
i_img_dim i_maxx(i_img_dim x, i_img_dim y);
i_img_dim i_abs(i_img_dim x);
#define i_min(a, b) i_minx((a), (b))
#define i_max(a, b) i_maxx((a), (b))
#define color_to_grey(col) ((col)->rgb.r * 0.222 + (col)->rgb.g * 0.707 + (col)->rgb.b * 0.071)
struct file_magic_entry {
unsigned char *magic;
size_t magic_size;
char *name;
unsigned char *mask;
};
typedef struct im_file_magic im_file_magic;
struct im_file_magic {
struct file_magic_entry m;
/* more magic to check */
im_file_magic *next;
};
#define IM_ERROR_COUNT 20
typedef struct im_context_tag {
int error_sp;
size_t error_alloc[IM_ERROR_COUNT];
i_errmsg error_stack[IM_ERROR_COUNT];
#ifdef IMAGER_LOG
/* the log file and level for this context */
FILE *lg_file;
int log_level;
/* whether we own the lg_file, false for stderr and for cloned contexts */
int own_log;
/* values supplied by lhead */
const char *filename;
int line;
#endif
/* file size limits */
i_img_dim max_width, max_height;
size_t max_bytes;
/* per context storage */
size_t slot_alloc;
void **slots;
/* registered file type magic */
im_file_magic *file_magic;
ptrdiff_t refcount;
} im_context_struct;
#define DEF_BYTES_LIMIT 0x40000000
#define im_size_t_max (~(size_t)0)
#endif

View File

@@ -0,0 +1,34 @@
/* This file is automatically generated by Makefile.PL.
Don't edit this file, since any changes will be lost */
#ifndef IMAGER_IMCONFIG_H
#define IMAGER_IMCONFIG_H
/*
Logging system
*/
#define IMAGER_LOG 1
/*
Compiler supports the GCC __attribute__((format...)) syntax.
*/
#define IMAGER_FORMAT_ATTR 1
/* We can use snprintf() */
#define IMAGER_SNPRINTF 1
/* We can use vsnprintf() */
#define IMAGER_VSNPRINTF 1
/*
Type and format code for formatted output as with printf.
This is intended for formatting i_img_dim values.
*/
typedef long long i_dim_format_t;
#define i_DF "I64d"
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
#ifndef IMAGER_IMERROR_H
#define IMAGER_IMERROR_H
/* error handling
see error.c for documentation
the error information is currently global
*/
typedef void (*i_error_cb)(int code, char const *msg);
typedef void (*i_failed_cb)(i_errmsg *msgs);
extern i_error_cb i_set_error_cb(i_error_cb);
extern i_failed_cb i_set_failed_cb(i_failed_cb);
extern void i_set_argv0(char const *);
extern int i_set_errors_fatal(int new_fatal);
extern i_errmsg *im_errors(pIMCTX);
extern void im_push_error(pIMCTX, int code, char const *msg);
#ifndef IMAGER_NO_CONTEXT
extern void i_push_errorf(int code, char const *fmt, ...) I_FORMAT_ATTR(2, 3);
#endif
extern void im_push_errorf(pIMCTX, int code, char const *fmt, ...) I_FORMAT_ATTR(3, 4);
extern void im_push_errorvf(im_context_t ctx, int code, char const *fmt, va_list);
extern void im_clear_error(pIMCTX);
extern int i_failed(int code, char const *msg);
#endif

View File

@@ -0,0 +1,10 @@
/* imexif.h - interface to Exif handling */
#ifndef IMAGER_IMEXIF_H
#define IMAGER_IMEXIF_H
#include <stddef.h>
#include "imdatatypes.h"
extern int im_decode_exif(i_img *im, const unsigned char *data, size_t length);
#endif /* ifndef IMAGER_IMEXIF_H */

View File

@@ -0,0 +1,261 @@
#ifndef IMAGER_IMEXT_H_
#define IMAGER_IMEXT_H_
#include "imexttypes.h"
#include "immacros.h"
extern im_ext_funcs *imager_function_ext_table;
#define DEFINE_IMAGER_CALLBACKS im_ext_funcs *imager_function_ext_table
#ifndef IMAGER_MIN_API_LEVEL
#define IMAGER_MIN_API_LEVEL IMAGER_API_LEVEL
#endif
#define PERL_INITIALIZE_IMAGER_CALLBACKS_NAME(name) \
do { \
imager_function_ext_table = INT2PTR(im_ext_funcs *, SvIV(get_sv(PERL_FUNCTION_TABLE_NAME, 1))); \
if (!imager_function_ext_table) \
croak("Imager API function table not found!"); \
if (imager_function_ext_table->version != IMAGER_API_VERSION) { \
croak("Imager API version incorrect loaded %d vs expected %d in %s", \
imager_function_ext_table->version, IMAGER_API_VERSION, (name)); \
} \
if (imager_function_ext_table->level < IMAGER_MIN_API_LEVEL) \
croak("API level %d below minimum of %d in %s", imager_function_ext_table->level, IMAGER_MIN_API_LEVEL, (name)); \
} while (0)
#define PERL_INITIALIZE_IMAGER_CALLBACKS PERL_INITIALIZE_IMAGER_CALLBACKS_NAME(__FILE__)
/* just for use here */
#define im_extt imager_function_ext_table
#define im_get_context() ((im_extt->f_im_get_context)())
#define im_context_refinc(ctx, where) ((im_extt->f_im_context_refinc)((ctx), (where)))
#define im_context_refdec(ctx, where) ((im_extt->f_im_context_refdec)((ctx), (where)))
#ifdef IMAGER_DEBUG_MALLOC
#define mymalloc(size) ((im_extt->f_mymalloc_file_line)((size), __FILE__, __LINE__))
#define myrealloc(ptr, size) ((im_extt->f_myrealloc_file_line)((ptr), (size), __FILE__, __LINE__))
#define myfree(ptr) ((im_extt->f_myfree_file_line)((ptr), __FILE__, __LINE__))
#else
#define mymalloc(size) ((im_extt->f_mymalloc)(size))
#define myfree(size) ((im_extt->f_myfree)(size))
#define myrealloc(block, newsize) ((im_extt->f_myrealloc)((block), (newsize)))
#endif
#define im_img_8_new(ctx, xsize, ysize, channels) ((im_extt->f_im_img_8_new)((ctx), (xsize), (ysize), (channels)))
#define im_img_16_new(ctx, xsize, ysize, channels) ((im_extt->f_im_img_16_new)((ctx), (xsize), (ysize), (channels)))
#define im_img_double_new(ctx, xsize, ysize, channels) ((im_extt->f_im_img_double_new)((ctx), (xsize), (ysize), (channels)))
#define im_img_pal_new(ctx, xsize, ysize, channels, maxpal) ((im_extt->f_im_img_pal_new)((ctx), (xsize), (ysize), (channels), (maxpal)))
#define i_img_destroy(im) ((im_extt->f_i_img_destroy)(im))
#define i_sametype(im, xsize, ysize) ((im_extt->f_i_sametype)((im), (xsize), (ysize)))
#define i_sametype_chans(im, xsize, ysize, channels) ((im_extt->f_i_sametype_chans)((im), (xsize), (ysize), (channels)))
#define i_img_info(im, info) ((im_extt->f_i_img_info)((im), (info)))
#ifndef IMAGER_DIRECT_IMAGE_CALLS
#define IMAGER_DIRECT_IMAGE_CALLS 1
#endif
#if !IMAGER_DIRECT_IMAGE_CALLS
#define i_ppix(im, x, y, val) ((im_extt->f_i_ppix)((im), (x), (y), (val)))
#define i_gpix(im, x, y, val) ((im_extt->f_i_gpix)((im), (x), (y), (val)))
#define i_ppixf(im, x, y, val) ((im_extt->f_i_ppixf)((im), (x), (y), (val)))
#define i_gpixf(im, x, y, val) ((im_extt->f_i_gpixf)((im), (x), (y), (val)))
#define i_plin(im, l, r, y, val) ((im_extt->f_i_plin)((im), (l), (r), (y), (val)))
#define i_glin(im, l, r, y, val) ((im_extt->f_i_glin)((im), (l), (r), (y), (val)))
#define i_plinf(im, l, r, y, val) ((im_extt->f_i_plinf)((im), (l), (r), (y), (val)))
#define i_glinf(im, l, r, y, val) ((im_extt->f_i_glinf)((im), (l), (r), (y), (val)))
#define i_gsamp(im, l, r, y, samps, chans, count) \
((im_extt->f_i_gsamp)((im), (l), (r), (y), (samps), (chans), (count)))
#define i_gsampf(im, l, r, y, samps, chans, count) \
((im_extt->f_i_gsampf)((im), (l), (r), (y), (samps), (chans), (count)))
#endif
#define i_gsamp_bits(im, l, r, y, samps, chans, count, bits) \
(((im)->i_f_gsamp_bits) ? ((im)->i_f_gsamp_bits)((im), (l), (r), (y), (samps), (chans), (count), (bits)) : -1)
#define i_psamp_bits(im, l, r, y, samps, chans, count, bits) \
(((im)->i_f_psamp_bits) ? ((im)->i_f_psamp_bits)((im), (l), (r), (y), (samps), (chans), (count), (bits)) : -1)
#define i_new_fill_solid(c, combine) ((im_extt->f_i_new_fill_solid)((c), (combine)))
#define i_new_fill_solidf(c, combine) ((im_extt->f_i_new_fill_solidf)((c), (combine)))
#define i_new_fill_hatch(fg, bg, combine, hatch, cust_hatch, dx, dy) \
((im_extt->f_i_new_fill_hatch)((fg), (bg), (combine), (hatch), (cust_hatch), (dx), (dy)))
#define i_new_fill_hatchf(fg, bg, combine, hatch, cust_hatch, dx, dy) \
((im_extt->f_i_new_fill_hatchf)((fg), (bg), (combine), (hatch), (cust_hatch), (dx), (dy)))
#define i_new_fill_image(im, matrix, xoff, yoff, combine) \
((im_extt->f_i_new_fill_image)((im), (matrix), (xoff), (yoff), (combine)))
#define i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, count, segs) \
((im_extt->f_i_new_fill_fount)((xa), (ya), (xb), (yb), (type), (repeat), (combine), (super_sample), (ssample_param), (count), (segs)))
#define i_fill_destroy(fill) ((im_extt->f_i_fill_destroy)(fill))
#define i_quant_makemap(quant, imgs, count) \
((im_extt->f_i_quant_makemap)((quant), (imgs), (count)))
#define i_quant_translate(quant, img) \
((im_extt->f_i_quant_translate)((quant), (img)))
#define i_quant_transparent(quant, indices, img, trans_index) \
((im_extt->f_i_quant_transparent)((quant), (indices), (img), (trans_index)))
#define im_clear_error(ctx) ((im_extt->f_im_clear_error)(ctx))
#define im_push_error(ctx, code, msg) ((im_extt->f_im_push_error)((ctx), (code), (msg)))
#define i_push_errorf (im_extt->f_i_push_errorf)
#define im_push_errorvf(ctx, code, fmt, list) \
((im_extt->f_im_push_errorvf)((ctx), (code), (fmt), (list)))
#define i_tags_new(tags) ((im_extt->f_i_tags_new)(tags))
#define i_tags_set(tags, name, data, size) \
((im_extt->f_i_tags_set)((tags), (name), (data), (size)))
#define i_tags_setn(tags, name, idata) \
((im_extt->f_i_tags_setn)((tags), (name), (idata)))
#define i_tags_destroy(tags) ((im_extt->f_i_tags_destroy)(tags))
#define i_tags_find(tags, name, start, entry) \
((im_extt->f_i_tags_find)((tags), (name), (start), (entry)))
#define i_tags_findn(tags, code, start, entry) \
((im_extt->f_i_tags_findn)((tags), (code), (start), (entry)))
#define i_tags_delete(tags, entry) \
((im_extt->f_i_tags_delete)((tags), (entry)))
#define i_tags_delbyname(tags, name) \
((im_extt->f_i_tags_delbyname)((tags), (name)))
#define i_tags_delbycode(tags, code) \
((im_extt->f_i_tags_delbycode)((tags), (code)))
#define i_tags_get_float(tags, name, code, value) \
((im_extt->f_i_tags_get_float)((tags), (name), (code), (value)))
#define i_tags_set_float(tags, name, code, value) \
((im_extt->f_i_tags_set_float)((tags), (name), (code), (value)))
#define i_tags_set_float2(tags, name, code, value, places) \
((im_extt->f_i_tags_set_float2)((tags), (name), (code), (value), (places)))
#define i_tags_get_int(tags, name, code, value) \
((im_extt->f_i_tags_get_int)((tags), (name), (code), (value)))
#define i_tags_get_string(tags, name, code, value, value_size) \
((im_extt->f_i_tags_get_string)((tags), (name), (code), (value), (value_size)))
#define i_tags_get_color(tags, name, code, value) \
((im_extt->f_i_tags_get_color)((tags), (name), (code), (value)))
#define i_tags_set_color(tags, name, code, value) \
((im_extt->f_i_tags_set_color)((tags), (name), (code), (value)))
#define i_box(im, x1, y1, x2, y2, val) ((im_extt->f_i_box)((im), (x1), (y1), (x2), (y2), (val)))
#define i_box_filled(im, x1, y1, x2, y2, val) ((im_extt->f_i_box_filled)((im), (x1), (y1), (x2), (y2), (val)))
#define i_box_cfill(im, x1, y1, x2, y2, fill) ((im_extt->f_i_box_cfill)((im), (x1), (y1), (x2), (y2), (fill)))
#define i_line(im, x1, y1, x2, y2, val, endp) ((im_extt->f_i_line)((im), (x1), (y1), (x2), (y2), (val), (endp)))
#define i_line_aa(im, x1, y1, x2, y2, val, endp) ((im_extt->f_i_line_aa)((im), (x1), (y1), (x2), (y2), (val), (endp)))
#define i_arc(im, x, y, rad, d1, d2, val) ((im_extt->f_i_arc)((im), (x), (y), (rad), (d1), (d2), (val)))
#define i_arc_aa(im, x, y, rad, d1, d2, val) ((im_extt->f_i_arc_aa)((im), (x), (y), (rad), (d1), (d2), (val)))
#define i_arc_cfill(im, x, y, rad, d1, d2, fill) ((im_extt->f_i_arc_cfill)((im), (x), (y), (rad), (d1), (d2), (fill)))
#define i_arc_aa_cfill(im, x, y, rad, d1, d2, fill) ((im_extt->f_i_arc_aa_cfill)((im), (x), (y), (rad), (d1), (d2), (fill)))
#define i_circle_aa(im, x, y, rad, val) ((im_extt->f_i_circle_aa)((im), (x), (y), (rad), (val)))
#define i_flood_fill(im, seedx, seedy, dcol) ((im_extt->f_i_flood_fill)((im), (seedx), (seedy), (dcol)))
#define i_flood_cfill(im, seedx, seedy, fill) ((im_extt->f_i_flood_cfill)((im), (seedx), (seedy), (fill)))
#define i_flood_fill_border(im, seedx, seedy, dcol, border) ((im_extt->f_i_flood_fill_border)((im), (seedx), (seedy), (dcol), (border)))
#define i_flood_cfill_border(im, seedx, seedy, fill, border) ((im_extt->f_i_flood_cfill_border)((im), (seedx), (seedy), (fill), (border)))
#define i_poly_aa_m(im, count, x, y, mode, c) ((im_extt->f_i_poly_aa_m)((im), (count), (x), (y), (mode), (c)))
#define i_poly_aa_cfill_m(im, count, x, y, mode, fill) ((im_extt->f_i_poly_aa_m)((im), (count), (x), (y), (mode), (fill)))
#define i_poly_poly_aa(im, count, polys, mode, c) ((im_extt->f_i_poly_poly_aa)((im), (count), (polys), (mode), (c)))
#define i_poly_poly_aa_cfill(im, count, polys, mode, fill) ((im_extt->f_i_poly_poly_aa_cfill)((im), (count), (polys), (mode), (fill)))
#define i_copyto(im, src, x1, y1, x2, y2, tx, ty) \
((im_extt->f_i_copyto)((im), (src), (x1), (y1), (x2), (y2), (tx), (ty)))
#define i_copyto_trans(im, src, x1, y1, x2, y2, tx, ty, trans) \
((im_extt->f_i_copyto_trans)((im), (src), (x1), (y1), (x2), (y2), (tx), (ty), (trans)))
#define i_copy(im) ((im_extt->f_i_copy)(im))
#define i_rubthru(im, src, tx, ty, src_minx, src_miny, src_maxx, src_maxy) \
((im_extt->f_i_rubthru)((im), (src), (tx), (ty), (src_minx), (src_miny), (src_maxx), (src_maxy)))
#define im_set_image_file_limits(ctx, max_width, max_height, max_bytes) \
((im_extt->f_im_set_image_file_limits)((max_width), (max_height), (max_bytes)))
#define im_get_image_file_limits(ctx, pmax_width, pmax_height, pmax_bytes) \
((im_extt->f_im_get_image_file_limits)((ctx), (pmax_width), (pmax_height), (pmax_bytes)))
#define im_int_check_image_file_limits(ctx, width, height, channels, sample_size) \
((im_extt->f_im_int_check_image_file_limits)((ctx), (width), (height), (channels), (sample_size)))
#define i_img_setmask(img, mask) ((im_extt->f_i_img_setmask)((img), (mask)))
#define i_img_getmask(img) ((im_extt->f_i_img_getmask)(img))
#define i_img_getchannels(img) ((im_extt->f_i_img_getchannels)(img))
#define i_img_get_width(img) ((im_extt->f_i_img_get_width)(img))
#define i_img_get_height(img) ((im_extt->f_i_img_get_height)(img))
#define i_lhead(file, line) ((im_extt->f_i_lhead)((file), (line)))
#define i_loog (im_extt->f_i_loog)
#define im_lhead(ctx, file, line) ((im_extt->f_im_lhead)((ctx), (file), (line)))
#define im_loog (im_extt->f_im_loog)
#define im_img_alloc(ctx) ((im_extt->f_im_img_alloc)(ctx))
#define im_img_init(ctx, img) ((im_extt->fm_i_img_init)((ctx), (img)))
#define i_img_is_monochrome(img, zero_is_white) ((im_extt->f_i_img_is_monochrome)((img), (zero_is_white)))
#define i_gsamp_bg(im, l, r, y, samples, out_channels, bg) \
((im_extt->f_i_gsamp_bg)((im), (l), (r), (y), (samples), (out_channels), (bg)))
#define i_gsampf_bg(im, l, r, y, samples, out_channels, bg) \
((im_extt->f_i_gsampf_bg)((im), (l), (r), (y), (samples), (out_channels), (bg)))
#define i_get_file_background(im, bg) \
((im_extt->f_i_get_file_background)((im), (bg)))
#define i_get_file_backgroundf(im, bg) \
((im_extt->f_i_get_file_backgroundf)((im), (bg)))
#define i_utf8_advance(p, s) ((im_extt->f_i_utf8_advance)((p), (s)))
#define i_render_new(im, width) ((im_extt->f_i_render_new)((im), (width)))
#define i_render_delete(r) ((im_extt->f_i_render_delete)(r))
#define i_render_color(r, x, y, width, src, color) \
((im_extt->f_i_render_color)((r), (x), (y), (width), (src), (color)))
#define i_render_fill(r, x, y, width, src, fill) \
((im_extt->f_i_render_fill)((r), (x), (y), (width), (src), (fill)))
#define i_render_line(r, x, y, width, src, line, combine) \
((im_extt->f_i_render_line)((r), (x), (y), (width), (src), (line), (combine)))
#define i_render_linef(r, x, y, width, src, line, combine) \
((im_extt->f_i_render_linef)((r), (x), (y), (width), (src), (line), (combine)))
#define i_io_getc_imp (im_extt->f_i_io_getc_imp)
#define i_io_peekc_imp (im_extt->f_i_io_peekc_imp)
#define i_io_peekn (im_extt->f_i_io_peekn)
#define i_io_putc_imp (im_extt->f_i_io_putc_imp)
#define i_io_read (im_extt->f_i_io_read)
#define i_io_write (im_extt->f_i_io_write)
#define i_io_seek (im_extt->f_i_io_seek)
#define i_io_flush (im_extt->f_i_io_flush)
#define i_io_close (im_extt->f_i_io_close)
#define i_io_set_buffered (im_extt->f_i_io_set_buffered)
#define i_io_gets (im_extt->f_i_io_gets)
#define im_io_new_fd(ctx, fd) ((im_extt->f_im_io_new_fd)(ctx, fd))
#define im_io_new_bufchain(ctx) ((im_extt->f_im_io_new_bufchain)(ctx))
#define im_io_new_buffer(ctx, data, len, closecb, closedata) \
((im_extt->f_im_io_new_buffer)((ctx), (data), (len), (closecb), (closedata)))
#define im_io_new_cb(ctx, p, readcb, writecb, seekcb, closecb, destroycb) \
((im_extt->f_im_io_new_cb)((ctx), (p), (readcb), (writecb), (seekcb), (closecb), (destroycb)))
#define io_slurp(ig, datap) ((im_extt->f_io_slurp)((ig), (datap)))
#define io_glue_destroy(ig) ((im_extt->f_io_glue_destroy)(ig))
#define i_mutex_new() ((im_extt->f_i_mutex_new)())
#define i_mutex_destroy(m) ((im_extt->f_i_mutex_destroy)(m))
#define i_mutex_lock(m) ((im_extt->f_i_mutex_lock)(m))
#define i_mutex_unlock(m) ((im_extt->f_i_mutex_unlock)(m))
#define im_context_slot_new(destructor) ((im_extt->f_im_context_slot_new)(destructor))
#define im_context_slot_get(ctx, slot) ((im_extt->f_im_context_slot_get)((ctx), (slot)))
#define im_context_slot_set(ctx, slot, value) ((im_extt->f_im_context_slot_set)((ctx), (slot), (value)))
#define im_push_errorf (im_extt->f_im_push_errorf)
#define i_img_alpha_channel(im, channel) ((im_extt->f_i_img_alpha_channel)((im), (channel)))
#define i_img_color_model(im) ((im_extt->f_i_img_color_model)((im)))
#define i_img_color_channels(im) ((im_extt->f_i_img_color_channels)((im)))
#define im_decode_exif(im, data, len) ((im_extt->f_im_decode_exif)((im), (data), (len)))
#ifdef IMAGER_LOG
#ifndef IMAGER_NO_CONTEXT
#define mm_log(x) { i_lhead(__FILE__,__LINE__); i_loog x; }
#endif
#define im_log(x) { im_lhead(aIMCTX, __FILE__,__LINE__); im_loog x; }
#else
#define mm_log(x)
#endif
#endif

View File

@@ -0,0 +1,11 @@
#ifndef IMAGER_IMEXTDEF_H
#define IMAGER_IMEXTDEF_H
#include "imexttypes.h"
extern im_ext_funcs imager_function_table;
#define PERL_SET_GLOBAL_CALLBACKS \
sv_setiv(get_sv(PERL_FUNCTION_TABLE_NAME, 1), PTR2IV(&imager_function_table));
#endif

View File

@@ -0,0 +1,33 @@
#ifndef IMAGER_IMEXTPL_H_
#define IMAGER_IMEXTPL_H_
#include "imextpltypes.h"
#include "immacros.h"
extern im_pl_ext_funcs *imager_perl_function_ext_table;
#define DEFINE_IMAGER_PERL_CALLBACKS im_pl_ext_funcs *imager_perl_function_ext_table
#ifndef IMAGER_MIN_PL_API_LEVEL
#define IMAGER_MIN_PL_API_LEVEL IMAGER_PL_API_LEVEL
#endif
#define PERL_INITIALIZE_IMAGER_PERL_CALLBACKS \
do { \
imager_perl_function_ext_table = INT2PTR(im_pl_ext_funcs *, SvIV(get_sv(PERL_PL_FUNCTION_TABLE_NAME, 1))); \
if (!imager_perl_function_ext_table) \
croak("Imager Perl API function table not found!"); \
if (imager_perl_function_ext_table->version != IMAGER_PL_API_VERSION) \
croak("Imager Perl API version incorrect"); \
if (imager_perl_function_ext_table->level < IMAGER_MIN_PL_API_LEVEL) \
croak("perl API level %d below minimum of %d", imager_perl_function_ext_table->level, IMAGER_MIN_PL_API_LEVEL); \
} while (0)
/* just for use here */
#define im_exttpl imager_perl_function_ext_table
#define ip_handle_quant_opts (im_exttpl->f_ip_handle_quant_opts)
#define ip_cleanup_quant_opts (im_exttpl->f_ip_cleanup_quant_opts)
#define ip_copy_colors_back (im_exttpl->f_ip_copy_colors_back)
#endif

View File

@@ -0,0 +1,33 @@
#ifndef IMAGER_IMEXTPLTYPES_H_
#define IMAGER_IMEXTPLTYPES_H_
#ifndef PERL_NO_GET_CONTEXT
#error Sorry, you need to build with PERL_NO_GET_CONTEXT
#endif
#define IMAGER_PL_API_VERSION 1
/* This file provides functions useful for external code in
interfacing with perl - these functions aren't part of the core
Imager API. */
#define IMAGER_PL_API_LEVEL 2
typedef struct {
int version;
int level;
/* IMAGER_PL_API_LEVEL 1 functions */
void (*f_ip_handle_quant_opts)(pTHX_ i_quantize *quant, HV *hv);
void (*f_ip_cleanup_quant_opts)(pTHX_ i_quantize *quant);
void (*f_ip_copy_colors_back)(pTHX_ HV *hv, i_quantize *quant);
/* IMAGER_PL_API_LEVEL 2 */
int (*f_ip_handle_quant_opts2)(pTHX_ i_quantize *quant, HV *hv);
/* IMAGER_PL_API_LEVEL 3 functions will go here */
} im_pl_ext_funcs;
#define PERL_PL_FUNCTION_TABLE_NAME "Imager::__ext_pl_func_table"
#endif

View File

@@ -0,0 +1,281 @@
#ifndef IMAGER_IMEXTTYPES_H_
#define IMAGER_IMEXTTYPES_H_
/* keep this file simple - apidocs.perl parses it. */
#include "imdatatypes.h"
#include <stdarg.h>
/*
IMAGER_API_VERSION is similar to the version number in the third and
fourth bytes of TIFF files - if it ever changes then the API has changed
too much for any application to remain compatible.
Version 2 changed the types of some parameters and pointers. A
simple recompile should be enough in most cases.
Version 3 changed the behaviour of some of the I/O layer functions,
and in some cases the initial seek position when calling file
readers. Switching away from calling readcb etc to i_io_read() etc
should fix your code.
Version 4 added i_psamp() and i_psampf() pointers to the i_img
structure.
Version 5 changed the return types of i_get_file_background() and
i_get_file_backgroundf() from void to int.
*/
#define IMAGER_API_VERSION 5
/*
IMAGER_API_LEVEL is the level of the structure. New function pointers
will always remain at the end (unless IMAGER_API_VERSION changes), and
will result in an increment of IMAGER_API_LEVEL.
*/
#define IMAGER_API_LEVEL 10
typedef struct {
int version;
int level;
/* IMAGER_API_LEVEL 1 functions */
void * (*f_mymalloc)(size_t size);
void (*f_myfree)(void *block);
void * (*f_myrealloc)(void *block, size_t newsize);
void* (*f_mymalloc_file_line)(size_t size, char* file, int line);
void (*f_myfree_file_line)(void *p, char*file, int line);
void* (*f_myrealloc_file_line)(void *p, size_t newsize, char* file,int line);
i_img *(*f_i_img_8_new)(i_img_dim xsize, i_img_dim ysize, int channels); /* SKIP */
i_img *(*f_i_img_16_new)(i_img_dim xsize, i_img_dim ysize, int channels); /* SKIP */
i_img *(*f_i_img_double_new)(i_img_dim xsize, i_img_dim ysize, int channels); /* SKIP */
i_img *(*f_i_img_pal_new)(i_img_dim xsize, i_img_dim ysize, int channels, int maxpal); /* SKIP */
void (*f_i_img_destroy)(i_img *im);
i_img *(*f_i_sametype)(i_img *im, i_img_dim xsize, i_img_dim ysize);
i_img *(*f_i_sametype_chans)(i_img *im, i_img_dim xsize, i_img_dim ysize, int channels);
void (*f_i_img_info)(i_img *im, i_img_dim *info);
int (*f_i_ppix)(i_img *im, i_img_dim x, i_img_dim y, const i_color *val);
int (*f_i_gpix)(i_img *im, i_img_dim x, i_img_dim y, i_color *val);
int (*f_i_ppixf)(i_img *im, i_img_dim x, i_img_dim y, const i_fcolor *val);
int (*f_i_gpixf)(i_img *im, i_img_dim x, i_img_dim y, i_fcolor *val);
i_img_dim (*f_i_plin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_color *vals);
i_img_dim (*f_i_glin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_color *vals);
i_img_dim (*f_i_plinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_fcolor *vals);
i_img_dim (*f_i_glinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fcolor *vals);
i_img_dim (*f_i_gsamp)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_sample_t *samp,
const int *chans, int chan_count);
i_img_dim (*f_i_gsampf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samp,
const int *chans, int chan_count);
i_img_dim (*f_i_gpal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, i_palidx *vals);
i_img_dim (*f_i_ppal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, const i_palidx *vals);
int (*f_i_addcolors)(i_img *im, const i_color *colors, int count);
int (*f_i_getcolors)(i_img *im, int i, i_color *, int count);
int (*f_i_colorcount)(i_img *im);
int (*f_i_maxcolors)(i_img *im);
int (*f_i_findcolor)(i_img *im, const i_color *color, i_palidx *entry);
int (*f_i_setcolors)(i_img *im, int index, const i_color *colors,
int count);
i_fill_t *(*f_i_new_fill_solid)(const i_color *c, int combine);
i_fill_t *(*f_i_new_fill_solidf)(const i_fcolor *c, int combine);
i_fill_t *(*f_i_new_fill_hatch)(const i_color *fg, const i_color *bg, int combine,
int hatch, const unsigned char *cust_hatch,
i_img_dim dx, i_img_dim dy);
i_fill_t *(*f_i_new_fill_hatchf)(const i_fcolor *fg, const i_fcolor *bg, int combine,
int hatch, const unsigned char *cust_hatch,
i_img_dim dx, i_img_dim dy);
i_fill_t *(*f_i_new_fill_image)(i_img *im, const double *matrix, i_img_dim xoff,
i_img_dim yoff, int combine);
i_fill_t *(*f_i_new_fill_fount)(double xa, double ya, double xb, double yb,
i_fountain_type type, i_fountain_repeat repeat,
int combine, int super_sample, double ssample_param,
int count, i_fountain_seg *segs);
void (*f_i_fill_destroy)(i_fill_t *fill);
void (*f_i_quant_makemap)(i_quantize *quant, i_img **imgs, int count);
i_palidx * (*f_i_quant_translate)(i_quantize *quant, i_img *img);
void (*f_i_quant_transparent)(i_quantize *quant, i_palidx *indices,
i_img *img, i_palidx trans_index);
void (*f_i_clear_error)(void); /* SKIP */
void (*f_i_push_error)(int code, char const *msg); /* SKIP */
void (*f_i_push_errorf)(int code, char const *fmt, ...) I_FORMAT_ATTR(2,3);
void (*f_i_push_errorvf)(int code, char const *fmt, va_list); /* SKIP */
void (*f_i_tags_new)(i_img_tags *tags);
int (*f_i_tags_set)(i_img_tags *tags, char const *name, char const *data,
int size);
int (*f_i_tags_setn)(i_img_tags *tags, char const *name, int idata);
void (*f_i_tags_destroy)(i_img_tags *tags);
int (*f_i_tags_find)(i_img_tags *tags, char const *name, int start,
int *entry);
int (*f_i_tags_findn)(i_img_tags *tags, int code, int start, int *entry);
int (*f_i_tags_delete)(i_img_tags *tags, int entry);
int (*f_i_tags_delbyname)(i_img_tags *tags, char const *name);
int (*f_i_tags_delbycode)(i_img_tags *tags, int code);
int (*f_i_tags_get_float)(i_img_tags *tags, char const *name, int code,
double *value);
int (*f_i_tags_set_float)(i_img_tags *tags, char const *name, int code,
double value);
int (*f_i_tags_set_float2)(i_img_tags *tags, char const *name, int code,
double value, int places);
int (*f_i_tags_get_int)(i_img_tags *tags, char const *name, int code,
int *value);
int (*f_i_tags_get_string)(i_img_tags *tags, char const *name, int code,
char *value, size_t value_size);
int (*f_i_tags_get_color)(i_img_tags *tags, char const *name, int code,
i_color *value);
int (*f_i_tags_set_color)(i_img_tags *tags, char const *name, int code,
i_color const *value);
void (*f_i_box)(i_img *im, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, const i_color *val);
void (*f_i_box_filled)(i_img *im, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, const i_color *val);
void (*f_i_box_cfill)(i_img *im, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, i_fill_t *fill);
void (*f_i_line)(i_img *im, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, const i_color *val, int endp);
void (*f_i_line_aa)(i_img *im, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, const i_color *val, int endp);
void (*f_i_arc)(i_img *im, i_img_dim x, i_img_dim y, double rad, double d1, double d2, const i_color *val);
void (*f_i_arc_aa)(i_img *im, double x, double y, double rad, double d1, double d2, const i_color *val);
void (*f_i_arc_cfill)(i_img *im, i_img_dim x, i_img_dim y, double rad, double d1, double d2, i_fill_t *val);
void (*f_i_arc_aa_cfill)(i_img *im, double x, double y, double rad, double d1, double d2, i_fill_t *fill);
void (*f_i_circle_aa)(i_img *im, double x, double y, double rad, const i_color *val);
int (*f_i_flood_fill)(i_img *im, i_img_dim seedx, i_img_dim seedy, const i_color *dcol);
int (*f_i_flood_cfill)(i_img *im, i_img_dim seedx, i_img_dim seedy, i_fill_t *fill);
void (*f_i_copyto)(i_img *im, i_img *src, 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 (*f_i_copyto_trans)(i_img *im, i_img *src, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, i_img_dim tx, i_img_dim ty, const i_color *trans);
i_img *(*f_i_copy)(i_img *im);
int (*f_i_rubthru)(i_img *im, i_img *src, 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);
/* IMAGER_API_LEVEL 2 functions */
int (*f_i_set_image_file_limits)(i_img_dim width, i_img_dim height, size_t bytes); /* SKIP */
int (*f_i_get_image_file_limits)(i_img_dim *width, i_img_dim *height, size_t *bytes); /* SKIP */
int (*f_i_int_check_image_file_limits)(i_img_dim width, i_img_dim height, int channels, size_t sample_size); /* SKIP */
int (*f_i_flood_fill_border)(i_img *im, i_img_dim seedx, i_img_dim seedy, const i_color *dcol, const i_color *border);
int (*f_i_flood_cfill_border)(i_img *im, i_img_dim seedx, i_img_dim seedy, i_fill_t *fill, const i_color *border);
/* IMAGER_API_LEVEL 3 functions */
void (*f_i_img_setmask)(i_img *im, int ch_mask);
int (*f_i_img_getmask)(i_img *im);
int (*f_i_img_getchannels)(i_img *im);
i_img_dim (*f_i_img_get_width)(i_img *im);
i_img_dim (*f_i_img_get_height)(i_img *im);
void (*f_i_lhead)(const char *file, int line_number);
void (*f_i_loog)(int level, const char *msg, ...) I_FORMAT_ATTR(2,3);
/* IMAGER_API_LEVEL 4 functions will be added here */
i_img *(*f_i_img_alloc)(void); /* SKIP */
void (*f_i_img_init)(i_img *); /* SKIP */
/* IMAGER_API_LEVEL 5 functions will be added here */
/* added i_psampf?_bits macros */
int (*f_i_img_is_monochrome)(i_img *, int *zero_is_white);
int (*f_i_gsamp_bg)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_sample_t *samples,
int out_channels, i_color const * bg);
int (*f_i_gsampf_bg)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samples,
int out_channels, i_fcolor const * bg);
int (*f_i_get_file_background)(i_img *im, i_color *bg);
int (*f_i_get_file_backgroundf)(i_img *im, i_fcolor *bg);
unsigned long (*f_i_utf8_advance)(char const **p, size_t *len);
i_render *(*f_i_render_new)(i_img *im, i_img_dim width);
void (*f_i_render_delete)(i_render *r);
void (*f_i_render_color)(i_render *r, i_img_dim x, i_img_dim y,
i_img_dim width, unsigned char const *src,
i_color const *color);
void (*f_i_render_fill)(i_render *r, i_img_dim x, i_img_dim y,
i_img_dim width, unsigned char const *src,
i_fill_t *fill);
void (*f_i_render_line)(i_render *r, i_img_dim x, i_img_dim y,
i_img_dim width, const i_sample_t *src,
i_color *line, i_fill_combine_f combine);
void (*f_i_render_linef)(i_render *r, i_img_dim x, i_img_dim y,
i_img_dim width, const double *src,
i_fcolor *line, i_fill_combinef_f combine);
/* Level 6 lost to mis-numbering */
/* IMAGER_API_LEVEL 7 */
int (*f_i_io_getc_imp)(io_glue *ig);
int (*f_i_io_peekc_imp)(io_glue *ig);
ssize_t (*f_i_io_peekn)(io_glue *ig, void *buf, size_t size);
int (*f_i_io_putc_imp)(io_glue *ig, int c);
ssize_t (*f_i_io_read)(io_glue *, void *buf, size_t size);
ssize_t (*f_i_io_write)(io_glue *, const void *buf, size_t size);
off_t (*f_i_io_seek)(io_glue *, off_t offset, int whence);
int (*f_i_io_flush)(io_glue *ig);
int (*f_i_io_close)(io_glue *ig);
int (*f_i_io_set_buffered)(io_glue *ig, int buffered);
ssize_t (*f_i_io_gets)(io_glue *ig, char *, size_t, int);
i_io_glue_t *(*f_io_new_fd)(int fd); /* SKIP */
i_io_glue_t *(*f_io_new_bufchain)(void); /* SKIP */
i_io_glue_t *(*f_io_new_buffer)(const char *data, size_t len, i_io_closebufp_t closecb, void *closedata); /* SKIP */
i_io_glue_t *(*f_io_new_cb)(void *p, i_io_readl_t readcb, i_io_writel_t writecb, i_io_seekl_t seekcb, i_io_closel_t closecb, i_io_destroyl_t destroycb); /* SKIP */
size_t (*f_io_slurp)(i_io_glue_t *ig, unsigned char **c);
void (*f_io_glue_destroy)(i_io_glue_t *ig);
/* IMAGER_API_LEVEL 8 */
i_img *(*f_im_img_8_new)(im_context_t ctx, i_img_dim xsize, i_img_dim ysize, int channels);
i_img *(*f_im_img_16_new)(im_context_t ctx, i_img_dim xsize, i_img_dim ysize, int channels);
i_img *(*f_im_img_double_new)(im_context_t ctx, i_img_dim xsize, i_img_dim ysize, int channels);
i_img *(*f_im_img_pal_new)(im_context_t ctx, i_img_dim xsize, i_img_dim ysize, int channels, int maxpal);
void (*f_im_clear_error)(im_context_t ctx);
void (*f_im_push_error)(im_context_t ctx, int code, char const *msg);
void (*f_im_push_errorvf)(im_context_t ctx, int code, char const *fmt, va_list);
void (*f_im_push_errorf)(im_context_t , int code, char const *fmt, ...) I_FORMAT_ATTR(3,4);
int (*f_im_set_image_file_limits)(im_context_t ctx, i_img_dim width, i_img_dim height, size_t bytes);
int (*f_im_get_image_file_limits)(im_context_t ctx, i_img_dim *width, i_img_dim *height, size_t *bytes);
int (*f_im_int_check_image_file_limits)(im_context_t ctx, i_img_dim width, i_img_dim height, int channels, size_t sample_size);
i_img *(*f_im_img_alloc)(im_context_t ctx);
void (*f_im_img_init)(im_context_t ctx, i_img *);
i_io_glue_t *(*f_im_io_new_fd)(im_context_t ctx, int fd);
i_io_glue_t *(*f_im_io_new_bufchain)(im_context_t ctx);
i_io_glue_t *(*f_im_io_new_buffer)(im_context_t ctx, const char *data, size_t len, i_io_closebufp_t closecb, void *closedata);
i_io_glue_t *(*f_im_io_new_cb)(im_context_t ctx, void *p, i_io_readl_t readcb, i_io_writel_t writecb, i_io_seekl_t seekcb, i_io_closel_t closecb, i_io_destroyl_t destroycb);
im_context_t (*f_im_get_context)(void);
void (*f_im_lhead)( im_context_t, const char *file, int line );
void (*f_im_loog)(im_context_t, int level,const char *msg, ... ) I_FORMAT_ATTR(3,4);
void (*f_im_context_refinc)(im_context_t, const char *where);
void (*f_im_context_refdec)(im_context_t, const char *where);
i_errmsg *(*f_im_errors)(im_context_t);
i_mutex_t (*f_i_mutex_new)(void);
void (*f_i_mutex_destroy)(i_mutex_t m);
void (*f_i_mutex_lock)(i_mutex_t m);
void (*f_i_mutex_unlock)(i_mutex_t m);
im_slot_t (*f_im_context_slot_new)(im_slot_destroy_t);
int (*f_im_context_slot_set)(im_context_t, im_slot_t, void *);
void *(*f_im_context_slot_get)(im_context_t, im_slot_t);
/* IMAGER_API_LEVEL 9 */
int (*f_i_poly_poly_aa)(i_img *im, int count, const i_polygon_t *polys,
i_poly_fill_mode_t mode, const i_color *val);
int (*f_i_poly_poly_aa_cfill)(i_img *im, int count, const i_polygon_t *polys,
i_poly_fill_mode_t mode, i_fill_t *fill);
int (*f_i_poly_aa_m)(i_img *im, int l, const double *x, const double *y,
i_poly_fill_mode_t mode, const i_color *val);
int (*f_i_poly_aa_cfill_m)(i_img *im, int l, const double *x,
const double *y, i_poly_fill_mode_t mode,
i_fill_t *fill);
int (*f_i_img_alpha_channel)(i_img *im, int *channel);
i_color_model_t (*f_i_img_color_model)(i_img *im);
int (*f_i_img_color_channels)(i_img *im);
/* IMAGER_API_LEVEL 10 functions will be added here */
int (*f_im_decode_exif)(i_img *im, const unsigned char *data, size_t length);
/* IMAGER_API_LEVEL 11 functions will be added here */
} im_ext_funcs;
#define PERL_FUNCTION_TABLE_NAME "Imager::__ext_func_table"
#endif

View File

@@ -0,0 +1,27 @@
#ifndef IMAGER_IMIO_H_
#define IMAGER_IMIO_H_
#include <stdio.h>
#include <sys/stat.h>
#include "imconfig.h"
#include "log.h"
typedef struct i_mempool {
void **p;
unsigned int alloc;
unsigned int used;
} i_mempool;
void i_mempool_init(i_mempool *mp);
void i_mempool_extend(i_mempool *mp);
void *i_mempool_alloc(i_mempool *mp, size_t size);
void i_mempool_destroy(i_mempool *mp);
#ifdef _MSC_VER
#undef min
#undef max
#endif
extern unsigned long i_utf8_advance(char const **p, size_t *len);
#endif

View File

@@ -0,0 +1,154 @@
/*
Imager "functions" implemented as macros
I suppose these could go in imdatatypes, but they aren't types.
*/
#ifndef IMAGER_IMMACROS_H_
#define IMAGER_IMMACROS_H_
/*
=item i_img_has_alpha(C<im>)
=category Image Information
Return true if the image has an alpha channel.
=cut
*/
#define i_img_has_alpha(im) (i_img_alpha_channel((im), NULL))
/*
=item i_psamp(im, left, right, y, samples, channels, channel_count)
=category Drawing
Writes sample values from C<samples> to C<im> for the horizontal line
(left, y) to (right-1, y) inclusive for the channels specified by
C<channels>, an array of C<int> with C<channel_count> elements.
If C<channels> is C<NULL> then the first C<channels_count> channels
are written to for each pixel.
Returns the number of samples written, which should be (right - left)
* channel_count. If a channel not in the image is in channels, left
is negative, left is outside the image or y is outside the image,
returns -1 and pushes an error.
=cut
*/
#define i_psamp(im, l, r, y, samps, chans, count) \
(((im)->i_f_psamp)((im), (l), (r), (y), (samps), (chans), (count)))
/*
=item i_psampf(im, left, right, y, samples, channels, channel_count)
=category Drawing
Writes floating point sample values from C<samples> to C<im> for the
horizontal line (left, y) to (right-1, y) inclusive for the channels
specified by C<channels>, an array of C<int> with C<channel_count>
elements.
If C<channels> is C<NULL> then the first C<channels_count> channels
are written to for each pixel.
Returns the number of samples written, which should be (right - left)
* channel_count. If a channel not in the image is in channels, left
is negative, left is outside the image or y is outside the image,
returns -1 and pushes an error.
=cut
*/
#define i_psampf(im, l, r, y, samps, chans, count) \
(((im)->i_f_psampf)((im), (l), (r), (y), (samps), (chans), (count)))
#ifndef IMAGER_DIRECT_IMAGE_CALLS
#define IMAGER_DIRECT_IMAGE_CALLS 1
#endif
#if IMAGER_DIRECT_IMAGE_CALLS
#define i_ppix(im, x, y, val) (((im)->i_f_ppix)((im), (x), (y), (val)))
#define i_gpix(im, x, y, val) (((im)->i_f_gpix)((im), (x), (y), (val)))
#define i_ppixf(im, x, y, val) (((im)->i_f_ppixf)((im), (x), (y), (val)))
#define i_gpixf(im, x, y, val) (((im)->i_f_gpixf)((im), (x), (y), (val)))
#define i_plin(im, l, r, y, val) (((im)->i_f_plin)(im, l, r, y, val))
#define i_glin(im, l, r, y, val) (((im)->i_f_glin)(im, l, r, y, val))
#define i_plinf(im, l, r, y, val) (((im)->i_f_plinf)(im, l, r, y, val))
#define i_glinf(im, l, r, y, val) (((im)->i_f_glinf)(im, l, r, y, val))
#define i_gsamp(im, l, r, y, samps, chans, count) \
(((im)->i_f_gsamp)((im), (l), (r), (y), (samps), (chans), (count)))
#define i_gsampf(im, l, r, y, samps, chans, count) \
(((im)->i_f_gsampf)((im), (l), (r), (y), (samps), (chans), (count)))
#endif
#define i_gsamp_bits(im, l, r, y, samps, chans, count, bits) \
(((im)->i_f_gsamp_bits) ? ((im)->i_f_gsamp_bits)((im), (l), (r), (y), (samps), (chans), (count), (bits)) : -1)
#define i_psamp_bits(im, l, r, y, samps, chans, count, bits) \
(((im)->i_f_psamp_bits) ? ((im)->i_f_psamp_bits)((im), (l), (r), (y), (samps), (chans), (count), (bits)) : -1)
#define i_findcolor(im, color, entry) \
(((im)->i_f_findcolor) ? ((im)->i_f_findcolor)((im), (color), (entry)) : 0)
#define i_gpal(im, l, r, y, vals) \
(((im)->i_f_gpal) ? ((im)->i_f_gpal)((im), (l), (r), (y), (vals)) : 0)
#define i_ppal(im, l, r, y, vals) \
(((im)->i_f_ppal) ? ((im)->i_f_ppal)((im), (l), (r), (y), (vals)) : 0)
#define i_addcolors(im, colors, count) \
(((im)->i_f_addcolors) ? ((im)->i_f_addcolors)((im), (colors), (count)) : -1)
#define i_getcolors(im, index, color, count) \
(((im)->i_f_getcolors) ? \
((im)->i_f_getcolors)((im), (index), (color), (count)) : 0)
#define i_setcolors(im, index, color, count) \
(((im)->i_f_setcolors) ? \
((im)->i_f_setcolors)((im), (index), (color), (count)) : 0)
#define i_colorcount(im) \
(((im)->i_f_colorcount) ? ((im)->i_f_colorcount)(im) : -1)
#define i_maxcolors(im) \
(((im)->i_f_maxcolors) ? ((im)->i_f_maxcolors)(im) : -1)
#define i_findcolor(im, color, entry) \
(((im)->i_f_findcolor) ? ((im)->i_f_findcolor)((im), (color), (entry)) : 0)
#define i_img_virtual(im) ((im)->virtual)
#define i_img_type(im) ((im)->type)
#define i_img_bits(im) ((im)->bits)
#define pIMCTX im_context_t my_im_ctx
#ifdef IMAGER_NO_CONTEXT
#define dIMCTXctx(ctx) pIMCTX = (ctx)
#define dIMCTX dIMCTXctx(im_get_context())
#define dIMCTXim(im) dIMCTXctx((im)->context)
#define dIMCTXio(io) dIMCTXctx((io)->context)
#define aIMCTX my_im_ctx
#else
#define aIMCTX im_get_context()
#endif
#define i_img_8_new(xsize, ysize, channels) im_img_8_new(aIMCTX, (xsize), (ysize), (channels))
#define i_img_16_new(xsize, ysize, channels) im_img_16_new(aIMCTX, (xsize), (ysize), (channels))
#define i_img_double_new(xsize, ysize, channels) im_img_double_new(aIMCTX, (xsize), (ysize), (channels))
#define i_img_pal_new(xsize, ysize, channels, maxpal) im_img_pal_new(aIMCTX, (xsize), (ysize), (channels), (maxpal))
#define i_img_alloc() im_img_alloc(aIMCTX)
#define i_img_init(im) im_img_init(aIMCTX, im)
#define i_set_image_file_limits(width, height, bytes) im_set_image_file_limits(aIMCTX, width, height, bytes)
#define i_get_image_file_limits(width, height, bytes) im_get_image_file_limits(aIMCTX, width, height, bytes)
#define i_int_check_image_file_limits(width, height, channels, sample_size) im_int_check_image_file_limits(aIMCTX, width, height, channels, sample_size)
#define i_clear_error() im_clear_error(aIMCTX)
#define i_push_errorvf(code, fmt, args) im_push_errorvf(aIMCTX, code, fmt, args)
#define i_push_error(code, msg) im_push_error(aIMCTX, code, msg)
#define i_errors() im_errors(aIMCTX)
#define io_new_fd(fd) im_io_new_fd(aIMCTX, (fd))
#define io_new_bufchain() im_io_new_bufchain(aIMCTX)
#define io_new_buffer(data, len, closecb, closectx) im_io_new_buffer(aIMCTX, (data), (len), (closecb), (closectx))
#define io_new_cb(p, readcb, writecb, seekcb, closecb, destroycb) \
im_io_new_cb(aIMCTX, (p), (readcb), (writecb), (seekcb), (closecb), (destroycb))
#endif

View File

@@ -0,0 +1,31 @@
/*
This header file defines types that Imager's typemap uses to convert to
perl types.
This is meant for use in XS code, not in normal C source.
*/
#ifndef IMAGER_IMPERL_H
#define IMAGER_IMPERL_H
#include "imdatatypes.h"
typedef i_color* Imager__Color;
typedef i_fcolor* Imager__Color__Float;
typedef i_img* Imager__ImgRaw;
typedef int undef_neg_int;
typedef i_img * Imager;
#ifdef HAVE_LIBTT
typedef TT_Fonthandle* Imager__Font__TT;
#endif
/* 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;
typedef io_glue *Imager__IO;
#endif

View File

@@ -0,0 +1,7 @@
#ifndef IMAGER_IMPERLIO_H
#define IMAGER_IMPERLIO_H
extern i_io_glue_t *
im_io_new_perlio(pTHX_ PerlIO *handle);
#endif

View File

@@ -0,0 +1,28 @@
#ifndef IMAGER_IMRENDER_H
#define IMAGER_IMRENDER_H
#include "rendert.h"
extern void
i_render_init(i_render *r, i_img *im, i_img_dim width);
extern void
i_render_done(i_render *r);
extern void
i_render_color(i_render *r, i_img_dim x, i_img_dim y, i_img_dim width,
unsigned char const *src, i_color const *color);
extern void
i_render_fill(i_render *r, i_img_dim x, i_img_dim y, i_img_dim width,
unsigned char const *src, i_fill_t *fill);
extern void
i_render_line(i_render *r, i_img_dim x, i_img_dim y, i_img_dim width,
const i_sample_t *src, i_color *line, i_fill_combine_f combine);
extern void
i_render_linef(i_render *r, i_img_dim x, i_img_dim y, i_img_dim width,
const double *src, i_fcolor *line, i_fill_combinef_f combine);
extern i_render *
i_render_new(i_img *im, i_img_dim width);
extern void
i_render_delete(i_render *r);
#endif

View File

@@ -0,0 +1,47 @@
#ifndef _IOLAYER_H_
#define _IOLAYER_H_
/* How the IO layer works:
*
* Start by getting an io_glue object by calling the appropriate
* io_new...() function. After that data can be read via the
* io_glue->readcb() method.
*
*/
#include "iolayert.h"
/* #define BBSIZ 1096 */
#define BBSIZ 16384
#define IO_FAKE_SEEK 1<<0L
#define IO_TEMP_SEEK 1<<1L
void io_glue_gettypes (io_glue *ig, int reqmeth);
/* XS functions */
io_glue *im_io_new_fd(pIMCTX, int fd);
io_glue *im_io_new_bufchain(pIMCTX);
io_glue *im_io_new_buffer(pIMCTX, const char *data, size_t len, i_io_closebufp_t closecb, void *closedata);
io_glue *im_io_new_cb(pIMCTX, void *p, i_io_readl_t readcb, i_io_writel_t writecb, i_io_seekl_t seekcb, i_io_closel_t closecb, i_io_destroyl_t destroycb);
size_t io_slurp(io_glue *ig, unsigned char **c);
void io_glue_destroy(io_glue *ig);
void i_io_dump(io_glue *ig, int flags);
/* Buffered I/O */
extern int i_io_getc_imp(io_glue *ig);
extern int i_io_peekc_imp(io_glue *ig);
extern ssize_t i_io_peekn(io_glue *ig, void *buf, size_t size);
extern int i_io_putc_imp(io_glue *ig, int c);
extern ssize_t i_io_read(io_glue *ig, void *buf, size_t size);
extern ssize_t i_io_write(io_glue *ig, const void *buf, size_t size);
extern off_t i_io_seek(io_glue *ig, off_t offset, int whence);
extern int i_io_flush(io_glue *ig);
extern int i_io_close(io_glue *ig);
extern int i_io_set_buffered(io_glue *ig, int buffered);
extern ssize_t i_io_gets(io_glue *ig, char *, size_t, int);
#endif /* _IOLAYER_H_ */

View File

@@ -0,0 +1,110 @@
#ifndef IMAGER_IOLAYERT_H
#define IMAGER_IOLAYERT_H
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include <sys/types.h>
#include <stddef.h>
#include <stdio.h>
typedef enum { FDSEEK, FDNOSEEK, BUFFER, CBSEEK, CBNOSEEK, BUFCHAIN } io_type;
#ifdef _MSC_VER
typedef int ssize_t;
#endif
typedef struct i_io_glue_t i_io_glue_t;
/* compatibility for now */
typedef i_io_glue_t io_glue;
/* Callbacks we give out */
typedef ssize_t(*i_io_readp_t) (io_glue *ig, void *buf, size_t count);
typedef ssize_t(*i_io_writep_t)(io_glue *ig, const void *buf, size_t count);
typedef off_t (*i_io_seekp_t) (io_glue *ig, off_t offset, int whence);
typedef int (*i_io_closep_t)(io_glue *ig);
typedef ssize_t(*i_io_sizep_t) (io_glue *ig);
typedef void (*i_io_closebufp_t)(void *p);
typedef void (*i_io_destroyp_t)(i_io_glue_t *ig);
/* Callbacks we get */
typedef ssize_t(*i_io_readl_t) (void *p, void *buf, size_t count);
typedef ssize_t(*i_io_writel_t)(void *p, const void *buf, size_t count);
typedef off_t (*i_io_seekl_t) (void *p, off_t offset, int whence);
typedef int (*i_io_closel_t)(void *p);
typedef void (*i_io_destroyl_t)(void *p);
typedef ssize_t(*i_io_sizel_t) (void *p);
extern char *io_type_names[];
/* Structures to describe data sources */
struct i_io_glue_t {
io_type type;
void *exdata;
i_io_readp_t readcb;
i_io_writep_t writecb;
i_io_seekp_t seekcb;
i_io_closep_t closecb;
i_io_sizep_t sizecb;
i_io_destroyp_t destroycb;
unsigned char *buffer;
unsigned char *read_ptr;
unsigned char *read_end;
unsigned char *write_ptr;
unsigned char *write_end;
size_t buf_size;
/* non-zero if we encountered EOF */
int buf_eof;
/* non-zero if we've seen an error */
int error;
/* if non-zero we do write buffering (enabled by default) */
int buffered;
im_context_t context;
};
#define I_IO_DUMP_CALLBACKS 1
#define I_IO_DUMP_BUFFER 2
#define I_IO_DUMP_STATUS 4
#define I_IO_DUMP_DEFAULT (I_IO_DUMP_BUFFER | I_IO_DUMP_STATUS)
#define i_io_type(ig) ((ig)->source.ig_type)
#define i_io_raw_read(ig, buf, size) ((ig)->readcb((ig), (buf), (size)))
#define i_io_raw_write(ig, data, size) ((ig)->writecb((ig), (data), (size)))
#define i_io_raw_seek(ig, offset, whence) ((ig)->seekcb((ig), (offset), (whence)))
#define i_io_raw_close(ig) ((ig)->closecb(ig))
#define i_io_is_buffered(ig) ((int)((ig)->buffered))
#define i_io_getc(ig) \
((ig)->read_ptr < (ig)->read_end ? \
*((ig)->read_ptr++) : \
i_io_getc_imp(ig))
#define i_io_nextc(ig) \
((void)((ig)->read_ptr < (ig)->read_end ? \
((ig)->read_ptr++, 0) : \
i_io_getc_imp(ig)))
#define i_io_peekc(ig) \
((ig)->read_ptr < (ig)->read_end ? \
*((ig)->read_ptr) : \
i_io_peekc_imp(ig))
#define i_io_putc(ig, c) \
((ig)->write_ptr < (ig)->write_end && !(ig)->error ? \
*(ig)->write_ptr++ = (c) : \
i_io_putc_imp(ig, (c)))
#define i_io_eof(ig) \
((ig)->read_ptr == (ig)->read_end && (ig)->buf_eof)
#define i_io_error(ig) \
((ig)->read_ptr == (ig)->read_end && (ig)->error)
#endif

View File

@@ -0,0 +1,56 @@
#ifndef _LOG_H_
#define _LOG_H_
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include "imdatatypes.h"
/*
input: name of file to log too
input: onoff, 0 means no logging
global: creates a global variable FILE* lg_file
*/
int im_init_log(pIMCTX, const char *name, int onoff );
#define i_init_log(name, onoff) im_init_log(aIMCTX, name, onoff)
#ifndef IMAGER_NO_CONTEXT
void i_fatal ( int exitcode,const char *fmt, ... );
#endif
void im_fatal (pIMCTX, int exitcode,const char *fmt, ... );
void im_lhead ( pIMCTX, const char *file, int line );
void i_lhead ( const char *file, int line );
void i_loog(int level,const char *msg, ... ) I_FORMAT_ATTR(2,3);
void im_loog(pIMCTX, int level,const char *msg, ... ) I_FORMAT_ATTR(3,4);
/*
=item im_log((aIMCTX, level, format, ...))
=category Logging
This is the main entry point to logging. Note that the extra set of
parentheses are required due to limitations in C89 macros.
This will format a string with the current file and line number to the
log file if logging is enabled.
This must be called with a context object defined by one of the
C<dIMCTX> macros in scope.
This can also be called as C<mm_log((level, format, args))> in which
case the currently active context is used and any in scope context is
ignored.
=cut
*/
#ifdef IMAGER_LOG
#ifndef IMAGER_NO_CONTEXT
#define mm_log(x) { i_lhead(__FILE__,__LINE__); i_loog x; }
#endif
#define im_log(x) { im_lhead(aIMCTX, __FILE__,__LINE__); im_loog x; }
#else
#define mm_log(x)
#define im_log(x)
#endif
#endif /* _LOG_H_ */

View File

@@ -0,0 +1,42 @@
#include "imdatatypes.h"
#include "immacros.h"
/* structures for passing data between Imager-plugin and the Imager-module */
#include "ext.h"
#define getINT(k,s) (util_table->getint(INP,k,s))
#define getDOUBLE(k,s) (util_table->getdouble(INP,k,s))
#define getVOID(k,s) (util_table->getvoid(INP,k,(void**)s))
#define getSTR(k,s) (util_table->getstr(INP,k,(char**)s))
#define getOBJ(k,t,s) (util_table->getobj(INP,k,t,(void**)s))
#define i_color_set(cl,r,g,b,a) (symbol_table->i_color_set(cl,r,g,b,a))
#define i_color_info(cl) (symbol_table->i_color_info(cl))
#define im_get_context() (symbol_table->im_get_context_f())
#define i_img_empty_ch(im,x,y,ch) ((symbol_table->i_img_empty_ch_f(im_get_context(), im,x,y,ch))
#define i_img_exorcise(im) (symbol_table->i_img_exorcise_f(im))
#define i_img_info(im,info) (symbol_table->i_img_info_f(im,info))
#define i_img_setmask(im,ch_mask) (symbol_table->i_img_setmask_f(im,ch_mask))
#define i_img_getmask(im) (symbol_table->i_img_getmask_f(im))
/*
Not needed? The i_gpix() macro in image.h will call the right function
directly.
#define i_ppix(im,x,y,val) (symbol_table->i_ppix(im,x,y,val))
#define i_gpix(im,x,y,val) (symbol_table->i_gpix(im,x,y,val))
*/
#define i_box(im, x1, y1, x2, y2,val) (symbol_table->i_box(im, x1, y1, x2, y2,val))
#define i_draw(im, x1, y1, x2, y2,val) (symbol_table->i_draw(im, x1, y1, x2, y2,val))
#define i_arc(im, x, y, rad, d1, d2,val) (symbol_table->i_arc(im, x, y, rad, d1, d2,val))
#define i_copyto(im,src, x1, y1, x2, y2, tx, ty,trans) (symbol_table->i_copyto(im,src, x1, y1, x2, y2, tx, ty,trans))
#define i_rubthru(im,src, tx, ty) (symbol_table->i_rubthru(im,src, tx, ty))
#ifdef WIN32
extern char __declspec(dllexport) evalstr[];
extern func_ptr __declspec(dllexport) function_list[];
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,89 @@
#ifndef _REGMACH_H_
#define _REGMACH_H_
#include <stdio.h>
#include <math.h>
#include "imager.h"
enum rm_byte_codes {
rbc_add, /* ra + rb -> r*/
rbc_subtract, /* ra - rb -> r */
rbc_mult, /* ra * rb -> r */
rbc_div, /* ra / rb -> r */
rbc_mod, /* ra % rb -> r */
rbc_pow, /* ra ** rb -> r */
rbc_uminus, /* -ra -> r */
rbc_multp, /* pa ** rb -> p */
rbc_addp, /* pa + pb -> p */
rbc_subtractp, /* pa - pb -> p */
/* rbcParm, we just preload a register */
rbc_sin, /* sin(ra) -> r */
rbc_cos, /* cos(ra) -> r */
rbc_atan2, /* atan2(ra,rb) -> r */
rbc_sqrt, /* sqrt(ra) -> r */
rbc_distance, /* distance(rx, ry, rx, ry) -> r */
/* getp? codes must be in order */
rbc_getp1, /* getp1(ra, rb) -> p */
rbc_getp2, /* getp2(ra, rb) -> p */
rbc_getp3, /* getp3(ra, rb) -> p */
rbc_value, /* value(pa) -> r */
rbc_hue, /* hue(pa) -> r */
rbc_sat, /* sat(pa) -> r */
rbc_hsv, /* hsv(rh, rs, rv) -> p */
rbc_red, /* red(pa) -> r */
rbc_green, /* green(pa) -> r */
rbc_blue, /* blue(pa) -> r */
rbc_rgb, /* rgb(rr, rg, rb) -> p */
rbc_int, /* int(ra) -> r */
rbc_if, /* if(rc, rt, rf) -> r */
rbc_ifp, /* if(rc, pt, pf) -> p */
rbc_le, /* ra <= rb -> r */
rbc_lt, /* ra < rb -> r */
rbc_ge, /* ra >= rb -> r */
rbc_gt, /* ra > rb -> r */
rbc_eq, /* ra == rb -> r -- does approx equal */
rbc_ne, /* ra != rb -> r -- does approx equal */
rbc_and, /* ra && rb -> r */
rbc_or, /* ra || rb -> r */
rbc_not, /* !ra -> r */
rbc_abs, /* abs(ra) -> r */
rbc_ret, /* returns pa */
rbc_jump, /* jump to ja */
rbc_jumpz, /* jump if ra == 0 to jb */
rbc_jumpnz, /* jump if ra != 0 to jb */
rbc_set, /* ra -> r */
rbc_setp, /* pa -> p*/
rbc_print, /* print(ra) -> r -- prints, leaves on stack */
rbc_rgba, /* rgba(ra, rb, rc, rd) -> p */
rbc_hsva, /* hsva(ra, rb, rc, rd) -> p */
rbc_alpha, /* alpha(pa) -> r */
rbc_log, /* log(ra) -> r */
rbc_exp, /* exp(ra) -> r */
rbc_det, /* det(ra, rb, rc, rd) -> r */
rbc_op_count
};
/* rm_word was originally char, but even for some simpler expressions
I was getting close to running out of register numbers.
It should also simplify structure alignment issues. (I hope.)
*/
typedef int rm_word;
#define RM_WORD_PACK "i"
struct rm_op {
rm_word code; /* op code */
rm_word ra; /* first operand */
rm_word rb; /* possible second operand */
rm_word rc; /* possible third operand */
rm_word rd; /* possible fourth operand */
rm_word rout; /* output register */
};
i_color i_rm_run(struct rm_op codes[], size_t code_count,
double n_regs[], size_t n_regs_count,
i_color c_regs[], size_t c_regs_count,
i_img *images[], size_t image_count);
/* op_run(fx, sizeof(fx), parms, 2)) */
#endif /* _REGMACH_H_ */

View File

@@ -0,0 +1,19 @@
#ifndef IMAGER_RENDERT_H
#define IMAGER_RENDERT_H
#include "imdatatypes.h"
struct i_render_tag {
int magic;
i_img *im;
i_img_dim line_width;
i_color *line_8;
i_fcolor *line_double;
i_img_dim fill_width;
i_color *fill_line_8;
i_fcolor *fill_line_double;
};
#endif

View File

@@ -0,0 +1,25 @@
#ifndef _STACKMACH_H_
#define _STACKMACH_H_
#include <stdio.h>
#include <math.h>
enum ByteCodes {
bcAdd,
bcSubtract,
bcMult,
bcDiv,
bcParm,
bcSin,
bcCos
};
double i_op_run(int codes[], size_t code_size, double parms[], size_t parm_size);
/* op_run(fx, sizeof(fx), parms, 2)) */
#endif /* _STACKMACH_H_ */