X-Git-Url: http://git.imager.perl.org/imager.git/blobdiff_plain/7477ff14dc863339428b6f9f4b863adcd9fa1103..e1c0692925:/imager.h diff --git a/imager.h b/imager.h index 944c97f6..f5bb2da5 100644 --- a/imager.h +++ b/imager.h @@ -2,12 +2,11 @@ #define _IMAGE_H_ #include "imconfig.h" +#include "immacros.h" #include "imio.h" #include "iolayer.h" -#include "log.h" #include "stackmach.h" - #ifndef _MSC_VER #include #endif @@ -24,10 +23,6 @@ #define PI 3.14159265358979323846 #endif -#ifndef MAXINT -#define MAXINT 2147483647 -#endif - #include "imdatatypes.h" undef_int i_has_format(char *frmt); @@ -48,23 +43,19 @@ 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 *IIM_new(int x,int y,int ch); -#define i_img_8_new IIM_new -void IIM_DESTROY(i_img *im); -i_img *i_img_new( void ); -i_img *i_img_empty(i_img *im,int x,int y); -i_img *i_img_empty_ch(i_img *im,int x,int y,int ch); +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 *i_img_alloc(void); -void i_img_init(i_img *im); - -void i_img_info(i_img *im,int *info); +i_img *im_img_alloc(pIMCTX); +void im_img_init(pIMCTX, i_img *im); -extern i_img *i_sametype(i_img *im, int xsize, int ysize); -extern i_img *i_sametype_chans(i_img *im, int xsize, int ysize, int channels); +void i_img_info(i_img *im,i_img_dim *info); -i_img *i_img_pal_new(int x, int y, int ch, int maxpal); +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 */ @@ -73,123 +64,89 @@ 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,int x,int y, const i_color *val); -extern int i_gpix(i_img *im,int x,int y,i_color *val); -extern int i_ppixf(i_img *im,int x,int y, const i_fcolor *val); -extern int i_gpixf(i_img *im,int x,int y,i_fcolor *val); - -#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))) - -extern int i_plin(i_img *im, int l, int r, int y, const i_color *vals); -extern int i_glin(i_img *im, int l, int r, int y, i_color *vals); -extern int i_plinf(i_img *im, int l, int r, int y, const i_fcolor *vals); -extern int i_glinf(i_img *im, int l, int r, int y, i_fcolor *vals); -extern int i_gsamp(i_img *im, int l, int r, int y, i_sample_t *samp, - const int *chans, int chan_count); -extern int i_gsampf(i_img *im, int l, int r, int y, i_fsample_t *samp, - const int *chans, int chan_count); -extern int i_gpal(i_img *im, int x, int r, int y, i_palidx *vals); -extern int i_ppal(i_img *im, int x, int r, int 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, +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); -#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))) - -#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) 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, int dx, int dy); + 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, int dx, int dy); + 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, int xoff, int yoff, int combine); +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,int x,int y,int ch); +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,int x1,int y1,int x2,int y2,const i_color *val); -void i_box_filled (i_img *im,int x1,int y1,int x2,int y2,const i_color *val); -int i_box_filledf (i_img *im,int x1,int y1,int x2,int y2,const i_fcolor *val); -void i_box_cfill(i_img *im, int x1, int y1, int x2, int y2, i_fill_t *fill); -void i_line (i_img *im,int x1,int y1,int x2,int y2,const i_color *val, int endp); -void i_line_aa (i_img *im,int x1,int y1,int x2,int y2,const i_color *val, int endp); -void i_arc (i_img *im,int x,int y,float rad,float d1,float d2,const i_color *val); -int i_arc_out(i_img *im,i_img_dim x,i_img_dim y,i_img_dim rad,float d1,float 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,float d1,float d2,const 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_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,int x,int y,float rad,float d1,float d2,i_fill_t *fill); +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,float x, float y,float rad,const i_color *val); +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,int x1,int y1,int x2,int y2,int tx,int ty); -void i_copyto_trans(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty,const i_color *trans); +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, int tx, int ty, int src_minx, int src_miny, int src_maxx, int src_maxy); +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, - 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); extern int i_compose(i_img *out, i_img *src, - int out_left, int out_top, int src_left, int src_top, - int width, int height, int combine, double opacity); + 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); @@ -198,17 +155,25 @@ 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, int xsize, int ysize, const double *matrix); -extern i_img *i_matrix_transform_bg(i_img *im, int xsize, int ysize, const double *matrix, 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,int seedx,int seedy, const i_color *dcol); -undef_int i_flood_cfill(i_img *im, int seedx, int seedy, i_fill_t *fill); -undef_int i_flood_fill_border (i_img *im,int seedx,int seedy, const i_color *dcol, const i_color *border); -undef_int i_flood_cfill_border(i_img *im, int seedx, int seedy, i_fill_t *fill, const i_color *border); +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 */ @@ -227,120 +192,47 @@ int i_img_samef(i_img *im1,i_img *im2, double epsilon, const char *what); /* font routines */ -undef_int i_init_fonts( int t1log ); - -#ifdef HAVE_LIBT1 - -undef_int i_init_t1( int t1log ); -int i_t1_new( char *pfb, char *afm ); -int i_t1_destroy( int font_id ); -undef_int i_t1_cp( i_img *im, int xb, int yb, int channel, int fontnum, float points, char* str, size_t len, int align, int utf8, char const *flags ); -undef_int i_t1_text( i_img *im, int xb, int yb, const i_color *cl, int fontnum, float points, const char* str, size_t len, int align, int utf8, char const *flags ); -int i_t1_bbox( int fontnum, float point, const char *str, size_t len, int cords[6], int utf8, char const *flags ); -void i_t1_set_aa( int st ); -void close_t1( void ); -int i_t1_has_chars(int font_num, char const *text, size_t len, int utf8, char *out); -extern int i_t1_face_name(int font_num, char *name_buf, size_t name_buf_size); -extern int i_t1_glyph_name(int font_num, unsigned long ch, char *name_buf, - size_t name_buf_size); -#endif - #ifdef HAVE_LIBTT -undef_int i_init_tt( void ); +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,int xb,int yb,int channel,float points,char const* txt,size_t len,int smooth, int utf8, int align); -undef_int i_tt_text( TT_Fonthandle *handle, i_img *im, int xb, int yb, const i_color *cl, float points, char const* txt, size_t len, int smooth, int utf8, int align); -undef_int i_tt_bbox( TT_Fonthandle *handle, float points,const char *txt,size_t len,int cords[6], int utf8); -int i_tt_has_chars(TT_Fonthandle *handle, char const *text, size_t len, int utf8, char *out); +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); -int i_tt_face_name(TT_Fonthandle *handle, char *name_buf, +size_t i_tt_face_name(TT_Fonthandle *handle, char *name_buf, size_t name_buf_size); -int i_tt_glyph_name(TT_Fonthandle *handle, unsigned long ch, char *name_buf, +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 */ -/* functions for reading and writing formats */ - -/* general reader callback - userdata - data the user passed into the reader - buffer - the buffer to fill with data - need - the amount of data needed - want - the amount of space we have to store data - fill buffer and return the number of bytes read, 0 for eof, -1 for error -*/ - -typedef int (*i_read_callback_t)(char *userdata, char *buffer, int need, - int want); - -/* i_gen_reader() translates the low-level requests from whatever library - into buffered requests. - but the called function can always bypass buffering by only ever - reading I bytes. -*/ -#define CBBUFSIZ 4096 - -typedef struct { - i_read_callback_t cb; - char *userdata; - char buffer[CBBUFSIZ]; - int length; - int cpos; -} i_gen_read_data; - -extern int i_gen_reader(i_gen_read_data *info, char *buffer, int need); -extern i_gen_read_data *i_gen_read_data_new(i_read_callback_t cb, char *userdata); -extern void i_free_gen_read_data(i_gen_read_data *); - -/* general writer callback - userdata - the data the user passed into the writer - data - the data to write - data_size - the number of bytes to write - write the data, return non-zero on success, zero on failure. -*/ -typedef int (*i_write_callback_t)(char *userdata, char const *data, int size); - -typedef struct { - i_write_callback_t cb; - char *userdata; - char buffer[CBBUFSIZ]; - int maxlength; - int filledto; -} i_gen_write_data; - -extern int i_gen_writer(i_gen_write_data *info, char const *data, int size); -extern i_gen_write_data *i_gen_write_data_new(i_write_callback_t cb, char *userdata, int maxlength); -extern int i_free_gen_write_data(i_gen_write_data *, int flush); - 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); -extern i_img *i_img_pal_new(int x, int y, int channels, int maxpal); +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, int x, int y, - int w, int h); -extern i_img *i_img_16_new(int x, int y, int ch); +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 *i_img_double_new(int x, int y, int ch); +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 void i_get_file_background(i_img *im, i_color *bg); -extern void i_get_file_backgroundf(i_img *im, i_fcolor *bg); +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 * i_test_format_probe(io_glue *data, int length); -#ifdef HAVE_LIBJPEG -i_img * -i_readjpeg_wiol(io_glue *ig, int length, char** iptc_itext, int *itlength); -undef_int i_writejpeg_wiol(i_img *im, io_glue *ig, int qfactor); -#endif /* HAVE_LIBJPEG */ - -i_img * i_readraw_wiol(io_glue *ig, int x, int y, int datachannels, int storechannels, int intrl); +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); @@ -358,17 +250,17 @@ undef_int i_writetga_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, 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, float Value, int Axis); -i_img * i_scale_nn(i_img *im, float scx, float scy); -i_img * i_scale_mixing(i_img *src, int width, int height); +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); +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(int width, int height, int channels, +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, @@ -380,17 +272,18 @@ 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,int light_x,int light_y,int strength); -void i_bumpmap_complex(i_img *im, i_img *bump, int channel, int tx, int ty, float Lx, float Ly, - float Lz, float cd, float cs, float n, i_color *Ia, i_color *Il, i_color *Is); +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,int size); -void i_watermark(i_img *im,i_img *wmark,int tx,int ty,int pixdiff); +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_radnoise(i_img *im,int xo,int yo,float rscale,float ascale); -void i_turbnoise(i_img *im,float xo,float yo,float scale); -void i_gradgen(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure); -int i_nearest_color(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure); +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, @@ -407,36 +300,6 @@ i_new_fill_fount(double xa, double ya, double xb, double yb, void malloc_state( void ); -/* this is sort of obsolete now */ - -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); - - i_img*(*i_img_new)( void ); - i_img*(*i_img_empty)(i_img *im,int x,int y); - i_img*(*i_img_empty_ch)(i_img *im,int x,int y,int ch); - void(*i_img_exorcise)(i_img *im); - - void(*i_img_info)(i_img *im,int *info); - - void(*i_img_setmask)(i_img *im,int ch_mask); - int (*i_img_getmask)(i_img *im); - - /* - int (*i_ppix)(i_img *im,int x,int y,i_color *val); - int (*i_gpix)(i_img *im,int x,int y,i_color *val); - */ - void(*i_box)(i_img *im,int x1,int y1,int x2,int y2,const i_color *val); - void(*i_line)(i_img *im,int x1,int y1,int x2,int y2,const i_color *val,int endp); - void(*i_arc)(i_img *im,int x,int y,float rad,float d1,float d2,const i_color *val); - void(*i_copyto)(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty); - void(*i_copyto_trans)(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty,const i_color *trans); - int(*i_rubthru)(i_img *im,i_img *src,int tx,int ty, int src_minx, int src_miny, int src_maxx, int src_maxy); - -} symbol_table_t; - #include "imerror.h" /* image tag processing */ @@ -474,14 +337,14 @@ extern void i_tags_print(i_img_tags *tags); /* image file limits */ extern int -i_set_image_file_limits(int width, int height, int bytes); +im_set_image_file_limits(im_context_t ctx, i_img_dim width, i_img_dim height, size_t bytes); extern int -i_get_image_file_limits(int *width, int *height, int *bytes); +im_get_image_file_limits(im_context_t ctx, i_img_dim *width, i_img_dim *height, size_t *bytes); extern int -i_int_check_image_file_limits(int width, int height, int channels, int sample_size); +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(int size); +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); @@ -495,18 +358,15 @@ void* myrealloc_file_line(void *p, size_t newsize, char* file,int line); #define myfree(x) (myfree_file_line((x), __FILE__, __LINE__)) void malloc_state (void); -void* mymalloc_comm (int size, char *comm); void bndcheck_all (void); #else -#define malloc_comm(a,b) (mymalloc(a)) void malloc_state(void); #endif /* IMAGER_MALLOC_DEBUG */ #include "imrender.h" -#include "immacros.h" extern void i_adapt_colors(int dest_channels, int src_channels, i_color *colors, @@ -523,11 +383,30 @@ 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, int l, int r, int y, i_sample_t *samples, +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, int l, int r, int y, i_fsample_t *samples, +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