]> git.imager.perl.org - imager.git/blobdiff - image.h
More support for autodetection of formats, still some error comes up in
[imager.git] / image.h
diff --git a/image.h b/image.h
index 45f50408f4c60de5731df5838f9d252b8ae91b42..9ca74a3cb0a56d7adba3f48f02af74712ed338ab 100644 (file)
--- a/image.h
+++ b/image.h
@@ -42,6 +42,11 @@ 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 *IIM_new(int x,int y,int ch);
 void   IIM_DESTROY(i_img *im);
 i_img *i_img_new( void );
@@ -53,6 +58,7 @@ void   i_img_destroy(i_img *im);
 void   i_img_info(i_img *im,int *info);
 
 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);
 
 i_img *i_img_pal_new(int x, int y, int ch, int maxpal);
 
@@ -64,10 +70,12 @@ int    i_img_getchannels(i_img *im);
 
 /* Base functions */
 
+#if 0
 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);
 int i_ppixf(i_img *im,int x,int y,i_color *val);
 int i_gpixf(i_img *im,int x,int y,i_color *val);
+#endif
 
 #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)))
@@ -91,6 +99,14 @@ int i_glin_d(i_img *im,int l, int r, int y, i_color *val);
 #define i_gsampf(im, l, r, y, samps, chans, count) \
   (((im)->i_f_gsampf)((im), (l), (r), (y), (samps), (chans), (count)))
 
+#define i_psamp(im, l, r, y, samps, chans, count) \
+  (((im)->i_f_gsamp)((im), (l), (r), (y), (samps), (chans), (count)))
+#define i_psampf(im, l, r, y, samps, chans, count) \
+  (((im)->i_f_gsampf)((im), (l), (r), (y), (samps), (chans), (count)))
+
+
+
+
 #define i_findcolor(im, color, entry) \
   (((im)->i_f_findcolor) ? ((im)->i_f_findcolor)((im), (color), (entry)) : 0)
 
@@ -117,15 +133,80 @@ int i_glin_d(i_img *im,int l, int r, int y, i_color *val);
 #define i_img_type(im) ((im)->type)
 #define i_img_bits(im) ((im)->bits)
 
+/* Generic fills */
+struct i_fill_tag;
+
+typedef void (*i_fill_with_color_f)
+     (struct i_fill_tag *fill, int x, int y, int width, int channels, 
+      i_color *data);
+typedef void (*i_fill_with_fcolor_f)
+     (struct i_fill_tag *fill, int x, int y, int width, int channels,
+      i_fcolor *data);
+typedef void (*i_fill_destroy_f)(struct i_fill_tag *fill);
+typedef void (*i_fill_combine_f)(i_color *out, i_color *in, int channels, 
+                                 int count);
+typedef void (*i_fill_combinef_f)(i_fcolor *out, i_fcolor *in, int channels,
+                                  int count);
+
+
+typedef struct i_fill_tag
+{
+  /* called for 8-bit/sample image (and maybe lower) */
+  /* this may be NULL, if so call fill_with_fcolor */
+  i_fill_with_color_f fill_with_color;
+
+  /* called for other sample sizes */
+  /* this must be non-NULL */
+  i_fill_with_fcolor_f fill_with_fcolor;
+
+  /* called if non-NULL to release any extra resources */
+  i_fill_destroy_f destroy;
+
+  /* if non-zero the caller will fill data with the original data
+     from the image */
+  i_fill_combine_f combine;
+  i_fill_combinef_f combinef;
+} i_fill_t;
+
+typedef enum {
+  ic_none,
+  ic_normal,
+  ic_multiply,
+  ic_dissolve,
+  ic_add,
+  ic_subtract,
+  ic_diff,
+  ic_lighten,
+  ic_darken,
+  ic_hue,
+  ic_sat,
+  ic_value,
+  ic_color
+} i_combine_t;
+
+extern i_fill_t *i_new_fill_solidf(i_fcolor *c, int combine);
+extern i_fill_t *i_new_fill_solid(i_color *c, int combine);
+extern i_fill_t *
+i_new_fill_hatch(i_color *fg, i_color *bg, int combine, int hatch, 
+                 unsigned char *cust_hatch, int dx, int dy);
+extern i_fill_t *
+i_new_fill_hatchf(i_fcolor *fg, i_fcolor *bg, int combine, int hatch, 
+                  unsigned char *cust_hatch, int dx, int dy);
+extern i_fill_t *
+i_new_fill_image(i_img *im, double *matrix, int xoff, int yoff, int combine);
+extern void i_fill_destroy(i_fill_t *fill);
+
 float i_gpix_pch(i_img *im,int x,int y,int ch);
 
 /* functions for drawing primitives */
 
 void i_box         (i_img *im,int x1,int y1,int x2,int y2,i_color *val);
 void i_box_filled  (i_img *im,int x1,int y1,int x2,int y2,i_color *val);
-void i_draw        (i_img *im,int x1,int y1,int x2,int y2,i_color *val);
-void i_line_aa     (i_img *im,int x1,int y1,int x2,int y2,i_color *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,i_color *val, int endp);
+void i_line_aa     (i_img *im,int x1,int y1,int x2,int y2,i_color *val, int endp);
 void i_arc         (i_img *im,int x,int y,float rad,float d1,float d2,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_circle_aa   (i_img *im,float x, float y,float rad,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,i_color *trans);
@@ -139,13 +220,17 @@ extern i_img *i_matrix_transform(i_img *im, int xsize, int ysize, double *matrix
 
 void i_bezier_multi(i_img *im,int l,double *x,double *y,i_color *val);
 void i_poly_aa     (i_img *im,int l,double *x,double *y,i_color *val);
+void i_poly_aa_cfill(i_img *im,int l,double *x,double *y,i_fill_t *fill);
+
+undef_int i_flood_fill  (i_img *im,int seedx,int seedy,i_color *dcol);
+undef_int i_flood_cfill(i_img *im, int seedx, int seedy, i_fill_t *fill);
 
-void i_flood_fill  (i_img *im,int seedx,int seedy,i_color *dcol);
 
 /* image processing functions */
 
 void i_gaussian    (i_img *im,float stdev);
 void i_conv        (i_img *im,float *coeff,int len);
+void i_unsharp_mask(i_img *im, double stddev, double scale);
 
 /* colour manipulation */
 extern int i_convert(i_img *im, i_img *src, float *coeff, int outchan, int inchan);
@@ -155,17 +240,17 @@ float i_img_diff   (i_img *im1,i_img *im2);
 
 /* font routines */
 
-undef_int i_init_fonts( void );
+undef_int i_init_fonts( int t1log );
 
 #ifdef HAVE_LIBT1
 #include <t1lib.h>
 
-undef_int init_t1( void );
+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, int len, int align );
-undef_int i_t1_text( i_img *im, int xb, int yb, i_color *cl, int fontnum, float points, char* str, int len, int align );
-void      i_t1_bbox( int fontnum, float point, char *str, int len, int cords[6] );
+undef_int i_t1_cp( i_img *im, int xb, int yb, int channel, int fontnum, float points, char* str, int len, int align, int utf8, char const *flags );
+undef_int i_t1_text( i_img *im, int xb, int yb, i_color *cl, int fontnum, float points, char* str, int len, int align, int utf8, char const *flags );
+void      i_t1_bbox( int fontnum, float point, char *str, int len, int cords[6], int utf8, char const *flags );
 void      i_t1_set_aa( int st );
 void      close_t1( void );
 
@@ -173,39 +258,17 @@ void      close_t1( void );
 
 #ifdef HAVE_LIBTT
 
-#include <freetype.h>
-#define TT_CHC 5
-
-struct TT_Instancehandle_ {
-  TT_Instance instance;
-  TT_Instance_Metrics imetrics;
-  TT_Glyph_Metrics gmetrics[256];
-  TT_Glyph glyphs[256];
-  int smooth;
-  int ptsize;
-  int order;
-};
-
-typedef struct TT_Instancehandle_ TT_Instancehandle;
-
-struct TT_Fonthandle_ {
-  TT_Face face;
-  TT_Face_Properties properties;
-  TT_Instancehandle instanceh[TT_CHC];
-  TT_CharMap char_map;
-};
+struct TT_Fonthandle_;
 
 typedef struct TT_Fonthandle_ TT_Fonthandle;
 
-
-
-undef_int init_tt( void );
+undef_int i_init_tt( void );
 TT_Fonthandle* i_tt_new(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* txt,int len,int smooth);
-undef_int i_tt_text( TT_Fonthandle *handle, i_img *im, int xb, int yb, i_color *cl, float points, char* txt, int len, int smooth);
-undef_int i_tt_bbox( TT_Fonthandle *handle, float points,char *txt,int len,int cords[6]);
-
+undef_int i_tt_cp( TT_Fonthandle *handle,i_img *im,int xb,int yb,int channel,float points,char const* txt,int len,int smooth, int utf8);
+undef_int i_tt_text( TT_Fonthandle *handle, i_img *im, int xb, int yb, i_color *cl, float points, char const* txt, int len, int smooth, int utf8);
+undef_int i_tt_bbox( TT_Fonthandle *handle, float points,char *txt,int len,int cords[6], int utf8);
+int i_tt_has_chars(TT_Fonthandle *handle, char const *text, int len, int utf8, char *out);
 
 #endif  /* End of freetype headers */
 
@@ -220,15 +283,17 @@ extern int i_ft2_getdpi(FT2_Fonthandle *handle, int *xdpi, int *ydpi);
 extern int i_ft2_settransform(FT2_Fonthandle *handle, double *matrix);
 extern int i_ft2_sethinting(FT2_Fonthandle *handle, int hinting);
 extern int i_ft2_bbox(FT2_Fonthandle *handle, double cheight, double cwidth, 
-                      char *text, int len, int *bbox);
+                      char const *text, int len, int *bbox, int utf8);
 extern int i_ft2_text(FT2_Fonthandle *handle, i_img *im, int tx, int ty, 
                       i_color *cl, double cheight, double cwidth, 
-                      char *text, int len, int align, int aa, int vlayout,
-                      int utf8);
+                      char const *text, int len, int align, int aa, 
+                      int vlayout, int utf8);
 extern int i_ft2_cp(FT2_Fonthandle *handle, i_img *im, int tx, int ty, 
                     int channel, double cheight, double cwidth, 
-                    char *text, int len, int align, int aa, int vlayout, 
+                    char const *text, int len, int align, int aa, int vlayout, 
                     int utf8);
+extern int i_ft2_has_chars(FT2_Fonthandle *handle, char const *text, int len,
+                           int utf8, char *work);
 
 #endif
 
@@ -272,7 +337,7 @@ typedef struct {
 
 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 free_gen_read_data(i_gen_read_data *);
+extern void i_free_gen_read_data(i_gen_read_data *);
 
 /* general writer callback
    userdata - the data the user passed into the writer
@@ -292,7 +357,7 @@ typedef struct {
 
 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 free_gen_write_data(i_gen_write_data *, int flush);
+extern int i_free_gen_write_data(i_gen_write_data *, int flush);
 
 /* transparency handling for quantized output */
 typedef enum i_transp_tag {
@@ -307,6 +372,7 @@ typedef enum i_make_colors_tag {
   mc_none, /* user supplied colour map only */
   mc_web_map, /* Use the 216 colour web colour map */
   mc_addi, /* Addi's algorithm */
+  mc_median_cut, /* median cut - similar to giflib, hopefully */
   mc_mask = 0xFF /* (mask for generator) */
 } i_make_colors;
 
@@ -423,6 +489,9 @@ typedef struct i_gif_opts {
 
   /* Netscape loop extension - number of loops */
   int loop_count;
+
+  /* should be eliminate unused colors? */
+  int eliminate_unused;
 } i_gif_opts;
 
 extern void quant_makemap(i_quantize *quant, i_img **imgs, int count);
@@ -437,6 +506,12 @@ 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_16_new_low(i_img *im, int x, int y, int ch);
+extern i_img *i_img_double_new(int x, int y, int ch);
+extern i_img *i_img_double_new_low(i_img *im, int x, int y, int ch);
+
+
+char * i_test_format_probe(io_glue *data, int length);
+
 
 #ifdef HAVE_LIBJPEG
 i_img *   
@@ -446,8 +521,11 @@ undef_int i_writejpeg_wiol(i_img *im, io_glue *ig, int qfactor);
 
 #ifdef HAVE_LIBTIFF
 i_img   * i_readtiff_wiol(io_glue *ig, int length);
+i_img  ** i_readtiff_multi_wiol(io_glue *ig, int length, int *count);
 undef_int i_writetiff_wiol(i_img *im, io_glue *ig);
+undef_int i_writetiff_multi_wiol(io_glue *ig, i_img **imgs, int count);
 undef_int i_writetiff_wiol_faxable(i_img *im, io_glue *ig, int fine);
+undef_int i_writetiff_multi_wiol_faxable(io_glue *ig, i_img **imgs, int count, int fine);
 
 #endif /* HAVE_LIBTIFF */
 
@@ -458,17 +536,20 @@ undef_int i_writepng_wiol(i_img *im, io_glue *ig);
 
 #ifdef HAVE_LIBGIF
 i_img *i_readgif(int fd, int **colour_table, int *colours);
+i_img *i_readgif_wiol(io_glue *ig, int **colour_table, int *colours);
 i_img *i_readgif_scalar(char *data, int length, int **colour_table, int *colours);
 i_img *i_readgif_callback(i_read_callback_t callback, char *userdata, int **colour_table, int *colours);
 extern i_img **i_readgif_multi(int fd, int *count);
 extern i_img **i_readgif_multi_scalar(char *data, int length, int *count);
 extern i_img **i_readgif_multi_callback(i_read_callback_t callback, char *userdata, int *count);
+extern i_img **i_readgif_multi_wiol(io_glue *ig, int *count);
 undef_int i_writegif(i_img *im,int fd,int colors,int pixdev,int fixedlen,i_color fixed[]);
 undef_int i_writegifmc(i_img *im,int fd,int colors);
 undef_int i_writegifex(i_img *im,int fd);
-undef_int i_writegif_gen(i_quantize *quant, int fd, i_img **imgs, int count, i_gif_opts *opts);
-undef_int i_writegif_callback(i_quantize *quant, i_write_callback_t cb, char *userdata, int maxbuffer, i_img **imgs, int count, i_gif_opts *opts);
-
+undef_int i_writegif_gen(i_quantize *quant, int fd, i_img **imgs, int count);
+undef_int i_writegif_callback(i_quantize *quant, i_write_callback_t cb, char *userdata, int maxbuffer, i_img **imgs, int count);
+undef_int i_writegif_wiol(io_glue *ig, i_quantize *quant, 
+                          i_img **imgs, int count);
 void i_qdist(i_img *im);
 
 #endif /* HAVE_LIBGIF */
@@ -479,9 +560,17 @@ undef_int i_writeraw_wiol(i_img* im, io_glue *ig);
 i_img   * i_readpnm_wiol(io_glue *ig, int length);
 undef_int i_writeppm_wiol(i_img *im, io_glue *ig);
 
-extern int i_writebmp_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 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, float Value, int Axis);
 i_img * i_scale_nn(i_img *im, float scx, float scy);
 i_img * i_haar(i_img *im);
@@ -495,12 +584,15 @@ i_img * i_transform2(int width, int height, int channels,
                     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_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_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);
@@ -509,6 +601,58 @@ 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);
 void i_nearest_color(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure);
+i_img *i_diff_image(i_img *im, i_img *im2, int mindist);
+typedef enum {
+  i_fst_linear,
+  i_fst_curved,
+  i_fst_sine,
+  i_fst_sphere_up,
+  i_fst_sphere_down,
+  i_fst_end
+} i_fountain_seg_type;
+typedef enum {
+  i_fc_direct,
+  i_fc_hue_up,
+  i_fc_hue_down,
+  i_fc_end
+} i_fountain_color;
+typedef struct {
+  double start, middle, end;
+  i_fcolor c[2];
+  i_fountain_seg_type type;
+  i_fountain_color color;
+} i_fountain_seg;
+typedef enum {
+  i_fr_none,
+  i_fr_sawtooth,
+  i_fr_triangle,
+  i_fr_saw_both,
+  i_fr_tri_both
+} i_fountain_repeat;
+typedef enum {
+  i_ft_linear,
+  i_ft_bilinear,
+  i_ft_radial,
+  i_ft_radial_square,
+  i_ft_revolution,
+  i_ft_conical,
+  i_ft_end
+} i_fountain_type;
+typedef enum {
+  i_fts_none,
+  i_fts_grid,
+  i_fts_random,
+  i_fts_circle
+} i_ft_supersample;
+void 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 */
 
@@ -531,11 +675,12 @@ typedef struct {
   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,i_color *val);
-  void(*i_draw)(i_img *im,int x1,int y1,int x2,int y2,i_color *val);
+  void(*i_line)(i_img *im,int x1,int y1,int x2,int y2,i_color *val,int endp);
   void(*i_arc)(i_img *im,int x,int y,float rad,float d1,float d2,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,i_color *trans);
@@ -568,14 +713,29 @@ extern int i_failed(int code, char const *msg);
 
 /* image tag processing */
 extern void i_tags_new(i_img_tags *tags);
-extern int i_tags_addn(i_img_tags *tags, char *name, int code, int idata);
-extern int i_tags_add(i_img_tags *tags, char *name, int code, char *data, 
-                      int size, int idata);
+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 void i_tags_destroy(i_img_tags *tags);
-extern int i_tags_find(i_img_tags *tags, char *name, int start, int *entry);
+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 *name);
+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_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);
 
 #endif