]> git.imager.perl.org - imager.git/blobdiff - imdatatypes.h
re-work jpeg tests - move "no jpeg support" tests into t101nojpeg.t to
[imager.git] / imdatatypes.h
index 774e9d9f30e8450a19e97912879fde82b2f59fca..21fe65acac8a1f0bff07c4b288b684f2661cadf3 100644 (file)
@@ -1,8 +1,8 @@
 #ifndef _DATATYPES_H_
 #define _DATATYPES_H_
 
-#include "imio.h"
 #include "imconfig.h"
+#include "imio.h"
 
 #define MAXCHANNELS 4
 
@@ -76,10 +76,10 @@ typedef struct {
 } i_img_tags;
 
 typedef struct i_img_ i_img;
-typedef int (*i_f_ppix_t)(i_img *im, int x, int y, i_color *pix);
-typedef int (*i_f_ppixf_t)(i_img *im, int x, int y, i_fcolor *pix);
-typedef int (*i_f_plin_t)(i_img *im, int x, int r, int y, i_color *vals);
-typedef int (*i_f_plinf_t)(i_img *im, int x, int r, int y, i_fcolor *vals);
+typedef int (*i_f_ppix_t)(i_img *im, int x, int y, const i_color *pix);
+typedef int (*i_f_ppixf_t)(i_img *im, int x, int y, const i_fcolor *pix);
+typedef int (*i_f_plin_t)(i_img *im, int x, int r, int y, const i_color *vals);
+typedef int (*i_f_plinf_t)(i_img *im, int x, int r, int y, const i_fcolor *vals);
 typedef int (*i_f_gpix_t)(i_img *im, int x, int y, i_color *pix);
 typedef int (*i_f_gpixf_t)(i_img *im, int x, int y, i_fcolor *pix);
 typedef int (*i_f_glin_t)(i_img *im, int x, int r, int y, i_color *vals);
@@ -91,20 +91,125 @@ typedef int (*i_f_gsampf_t)(i_img *im, int x, int r, int y, i_fsample_t *samp,
                             const int *chan, int chan_count);
 
 typedef int (*i_f_gpal_t)(i_img *im, int x, int r, int y, i_palidx *vals);
-typedef int (*i_f_ppal_t)(i_img *im, int x, int r, int y, i_palidx *vals);
-typedef int (*i_f_addcolors_t)(i_img *im, i_color *colors, int count);
+typedef int (*i_f_ppal_t)(i_img *im, int x, int r, int y, const i_palidx *vals);
+typedef int (*i_f_addcolors_t)(i_img *im, const i_color *colors, int count);
 typedef int (*i_f_getcolors_t)(i_img *im, int i, i_color *, int count);
 typedef int (*i_f_colorcount_t)(i_img *im);
 typedef int (*i_f_maxcolors_t)(i_img *im);
-typedef int (*i_f_findcolor_t)(i_img *im, i_color *color, i_palidx *entry);
-typedef int (*i_f_setcolors_t)(i_img *im, int index, i_color *colors, 
+typedef int (*i_f_findcolor_t)(i_img *im, const i_color *color, i_palidx *entry);
+typedef int (*i_f_setcolors_t)(i_img *im, int index, const i_color *colors, 
                               int count);
 
 typedef void (*i_f_destroy_t)(i_img *im);
 
+typedef int (*i_f_gsamp_bits_t)(i_img *im, int x, int r, int y, unsigned *samp,
+                           const int *chans, int chan_count, int bits);
+typedef int (*i_f_psamp_bits_t)(i_img *im, int x, int r, int y, unsigned const *samp,
+                                const int *chans, int chan_count, int bits);
+
+typedef int i_img_dim;
+
+/*
+=item i_img
+=category Data Types
+=synopsis i_img *img;
+
+This is Imager's image type.
+
+It contains the following members:
+
+=over
+
+=item *
+
+channels - the number of channels in the image
+
+=item *
+
+xsize, ysize - the width and height of the image in pixels
+
+=item *
+
+bytes - the number of bytes used to store the image data.  Undefined
+where virtual is non-zero.
+
+=item *
+
+ch_mask - a mask of writable channels.  eg. if this is 6 then only
+channels 1 and 2 are writable.  There may be bits set for which there
+are no channels in the image.
+
+=item *
+
+bits - the number of bits stored per sample.  Should be one of
+i_8_bits, i_16_bits, i_double_bits.
+
+=item *
+
+type - either i_direct_type for direct color images, or i_palette_type
+for paletted images.
+
+=item *
+
+virtual - if zero then this image is-self contained.  If non-zero then
+this image could be an interface to some other implementation.
+
+=item *
+
+idata - the image data.  This should not be directly accessed.  A new
+image implementation can use this to store its image data.
+i_img_destroy() will myfree() this pointer if it's non-null.
+
+=item *
+
+tags - a structure storing the image's tags.  This should only be
+accessed via the i_tags_*() functions.
+
+=item *
+
+ext_data - a pointer for use internal to an image implementation.
+This should be freed by the image's destroy handler.
+
+=item *
+
+im_data - data internal to Imager.  This is initialized by
+i_img_init().
+
+=item *
+
+i_f_ppix, i_f_ppixf, i_f_plin, i_f_plinf, i_f_gpix, i_f_gpixf,
+i_f_glin, i_f_glinf, i_f_gsamp, i_f_gampf - implementations for each
+of the required image functions.  An image implementation should
+initialize these between calling i_img_alloc() and i_img_init().
+
+=item *
+
+i_f_gpal, i_f_ppal, i_f_addcolors, i_f_getcolors, i_f_colorcount,
+i_f_maxcolors, i_f_findcolor, i_f_setcolors - implementations for each
+paletted image function.
+
+=item *
+
+i_f_destroy - custom image destruction function.  This should be used
+to release memory if necessary.
+
+=item *
+
+i_f_gsamp_bits - implements i_gsamp_bits() for this image.
+
+=item *
+
+i_f_psamp_bits - implements i_psamp_bits() for this image.
+
+=back
+
+=cut
+*/
+
 struct i_img_ {
   int channels;
-  int xsize,ysize,bytes;
+  i_img_dim xsize,ysize;
+  size_t bytes;
   unsigned int ch_mask;
   i_img_bits_t bits;
   i_img_type_t type;
@@ -138,6 +243,12 @@ struct i_img_ {
   i_f_setcolors_t i_f_setcolors;
 
   i_f_destroy_t i_f_destroy;
+
+  /* as of 0.61 */
+  i_f_gsamp_bits_t i_f_gsamp_bits;
+  i_f_psamp_bits_t i_f_psamp_bits;
+
+  void *im_data;
 };
 
 /* ext_data for paletted images
@@ -226,6 +337,7 @@ int octt_add(struct octt *ct,unsigned char r,unsigned char g,unsigned char b);
 void octt_dump(struct octt *ct);
 void octt_count(struct octt *ct,int *tot,int max,int *overflow);
 void octt_delete(struct octt *ct);
+void octt_histo(struct octt *ct, unsigned int **col_usage_it_adr);
 
 /* font bounding box results */
 enum bounding_box_index_t {
@@ -250,6 +362,16 @@ 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);
+
+/* combine functions modify their target and are permitted to modify
+   the source to prevent having to perform extra copying/memory
+   allocations, etc
+   The out array has I<channels> channels.
+
+   The in array has I<channels> channels + an alpha channel if one
+   isn't included in I<channels>.
+*/
+
 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,
@@ -304,11 +426,11 @@ 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;
+  i_fill_with_color_f f_fill_with_color;
 
   /* called for other sample sizes */
   /* this must be non-NULL */
-  i_fill_with_fcolor_f fill_with_fcolor;
+  i_fill_with_fcolor_f f_fill_with_fcolor;
 
   /* called if non-NULL to release any extra resources */
   i_fill_destroy_f destroy;
@@ -387,6 +509,7 @@ typedef enum i_make_colors_tag {
   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_mono, /* fixed mono color map */
   mc_mask = 0xFF /* (mask for generator) */
 } i_make_colors;
 
@@ -508,7 +631,17 @@ typedef struct i_gif_opts {
   int eliminate_unused;
 } i_gif_opts;
 
+/* distance measures used by some filters */
+enum {
+  i_dmeasure_euclidean = 0,
+  i_dmeasure_euclidean_squared = 1,
+  i_dmeasure_manhatten = 2,
+  i_dmeasure_limit = 2,
+};
+
+#include "iolayert.h"
 
+#include "rendert.h"
 
 #endif