X-Git-Url: http://git.imager.perl.org/imager.git/blobdiff_plain/a60905e49753b5f89573fbf3b4136dfc87206d4e..5aea8b490f5071452c692298c390c0270fa37050:/imdatatypes.h diff --git a/imdatatypes.h b/imdatatypes.h index 2c00b792..7866d7b2 100644 --- a/imdatatypes.h +++ b/imdatatypes.h @@ -1,6 +1,7 @@ #ifndef _DATATYPES_H_ #define _DATATYPES_H_ +#include #include "imconfig.h" #include "imio.h" @@ -22,6 +23,49 @@ typedef struct { i_sample_t c,m,y,k; } cmyk_color; typedef int undef_int; /* special value to put in typemaps to retun undef on 0 and 1 on 1 */ +/* +=item i_color +=category Data Types +=synopsis i_color black; +=synopsis black.rgba.r = black.rgba.g = black.rgba.b = black.rgba.a = 0; + +Type for 8-bit/sample color. + +Samples as per; + + i_color c; + +i_color is a union of: + +=over + +=item * + +gray - contains a single element gray_color, eg. C + +=item * + +C - contains three elements C, C, C, eg. C + +=item * + +C - contains four elements C, C, C, C, eg. C + +=item * + +C - contains four elements C, C, C, C, +eg. C. Note that Imager never uses CMYK colors except when +reading/writing files. + +=item * + +channels - an array of four channels, eg C. + +=back + +=cut +*/ + typedef union { gray_color gray; rgb_color rgb; @@ -40,6 +84,17 @@ typedef struct { i_fsample_t r, g, b; } i_frgb_color_t; typedef struct { i_fsample_t r, g, b, a; } i_frgba_color_t; typedef struct { i_fsample_t c, m, y, k; } i_fcmyk_color_t; +/* +=item i_fcolor +=category Data Types + +This is the double/sample color type. + +Its layout exactly corresponds to i_color. + +=cut +*/ + typedef union { i_fgray_color_t gray; i_frgb_color_t rgb; @@ -102,8 +157,124 @@ typedef int (*i_f_setcolors_t)(i_img *im, int index, const i_color *colors, 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); + +/* +=item i_img_dim +=category Data Types +=synopsis i_img_dim x; +=order 90 + +A signed integer type that represents an image dimension or ordinate. + +May be larger than int on some platforms. + +=cut +*/ + typedef int i_img_dim; +/* +=item i_img +=category Data Types +=synopsis i_img *img; +=order 10 + +This is Imager's image type. + +It contains the following members: + +=over + +=item * + +C - the number of channels in the image + +=item * + +C, C - the width and height of the image in pixels + +=item * + +C - the number of bytes used to store the image data. Undefined +where virtual is non-zero. + +=item * + +C - 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 * + +C - the number of bits stored per sample. Should be one of +i_8_bits, i_16_bits, i_double_bits. + +=item * + +C - either i_direct_type for direct color images, or i_palette_type +for paletted images. + +=item * + +C - if zero then this image is-self contained. If non-zero +then this image could be an interface to some other implementation. + +=item * + +C - 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 * + +C - a structure storing the image's tags. This should only be +accessed via the i_tags_*() functions. + +=item * + +C - a pointer for use internal to an image implementation. +This should be freed by the image's destroy handler. + +=item * + +C - 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; i_img_dim xsize,ysize; @@ -141,6 +312,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 @@ -162,10 +339,6 @@ typedef struct { */ - - - - /* bitmap mask */ struct i_bitmap { @@ -179,12 +352,6 @@ int btm_test(struct i_bitmap *btm,int x,int y); void btm_set(struct i_bitmap *btm,int x,int y); - - - - - - /* Stack/Linked list */ struct llink { @@ -248,16 +415,26 @@ enum bounding_box_index_t { struct i_fill_tag; typedef void (*i_fill_with_color_f) - (struct i_fill_tag *fill, int x, int y, int width, int channels, +(struct i_fill_tag *fill, i_img_dim x, i_img_dim y, i_img_dim 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, + (struct i_fill_tag *fill, i_img_dim x, i_img_dim y, i_img_dim 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. + + The in array has I channels + an alpha channel if one + isn't included in I. +*/ + typedef void (*i_fill_combine_f)(i_color *out, i_color *in, int channels, - int count); + i_img_dim count); typedef void (*i_fill_combinef_f)(i_fcolor *out, i_fcolor *in, int channels, - int count); + i_img_dim count); /* fountain fill types */ typedef enum { @@ -303,16 +480,28 @@ typedef enum { i_fts_circle } i_ft_supersample; +/* +=item i_fill_t +=category Data Types +=synopsis i_fill_t *fill; + +This is the "abstract" base type for Imager's fill types. + +Unless you're implementing a new fill type you'll typically treat this +as an opaque type. + +=cut +*/ 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; @@ -371,12 +560,6 @@ typedef struct TT_Fonthandle_ TT_Fonthandle; #endif -#ifdef HAVE_FT2 - -typedef struct FT2_Fonthandle FT2_Fonthandle; - -#endif - /* transparency handling for quantized output */ typedef enum i_transp_tag { tr_none, /* ignore any alpha channel */ @@ -437,6 +620,8 @@ typedef struct i_gif_pos_tag { /* passed into i_writegif_gen() to control quantization */ typedef struct i_quantize_tag { + int version; + /* how to handle transparency */ i_transp transp; /* the threshold at which to make pixels opaque */ @@ -472,6 +657,7 @@ typedef struct i_quantize_tag { /* the amount of perturbation to use for translate is mc_perturb */ int perturb; + /* version 2 members after here */ } i_quantize; typedef struct i_gif_opts { @@ -523,7 +709,7 @@ enum { #include "iolayert.h" -#include "rendert.h" +typedef struct i_render_tag i_render; #endif