8 /* used for palette indices in some internal code (which might be
11 typedef unsigned char i_palidx;
13 /* We handle 2 types of sample, this is hopefully the most common, and the
14 smaller of the ones we support */
15 typedef unsigned char i_sample_t;
17 typedef struct { i_sample_t gray_color; } gray_color;
18 typedef struct { i_sample_t r,g,b; } rgb_color;
19 typedef struct { i_sample_t r,g,b,a; } rgba_color;
20 typedef struct { i_sample_t c,m,y,k; } cmyk_color;
22 typedef int undef_int; /* special value to put in typemaps to retun undef on 0 and 1 on 1 */
29 i_sample_t channel[MAXCHANNELS];
33 /* this is the larger sample type, it should be able to accurately represent
34 any sample size we use */
35 typedef double i_fsample_t;
37 typedef struct { i_fsample_t gray_color; } i_fgray_color_t;
38 typedef struct { i_fsample_t r, g, b; } i_frgb_color_t;
39 typedef struct { i_fsample_t r, g, b, a; } i_frgba_color_t;
40 typedef struct { i_fsample_t c, m, y, k; } i_fcmyk_color_t;
47 i_fsample_t channel[MAXCHANNELS];
51 i_direct_type, /* direct colour, keeps RGB values per pixel */
52 i_palette_type /* keeps a palette index per pixel */
56 /* bits per sample, not per pixel */
57 /* a paletted image might have one bit per sample */
60 i_double_bits = sizeof(double) * 8
64 char *name; /* name of a given tag, might be NULL */
65 int code; /* number of a given tag, -1 if it has no meaning */
66 char *data; /* value of a given tag if it's not an int, may be NULL */
67 int size; /* size of the data */
68 int idata; /* value of a given tag if data is NULL */
72 int count; /* how many tags have been set */
73 int alloc; /* how many tags have been allocated for */
77 typedef struct i_img_ i_img;
78 typedef int (*i_f_ppix_t)(i_img *im, int x, int y, i_color *pix);
79 typedef int (*i_f_ppixf_t)(i_img *im, int x, int y, i_fcolor *pix);
80 typedef int (*i_f_plin_t)(i_img *im, int x, int r, int y, i_color *vals);
81 typedef int (*i_f_plinf_t)(i_img *im, int x, int r, int y, i_fcolor *vals);
82 typedef int (*i_f_gpix_t)(i_img *im, int x, int y, i_color *pix);
83 typedef int (*i_f_gpixf_t)(i_img *im, int x, int y, i_fcolor *pix);
84 typedef int (*i_f_glin_t)(i_img *im, int x, int r, int y, i_color *vals);
85 typedef int (*i_f_glinf_t)(i_img *im, int x, int r, int y, i_fcolor *vals);
87 typedef int (*i_f_gsamp_t)(i_img *im, int x, int r, int y, i_sample_t *samp,
88 const int *chans, int chan_count);
89 typedef int (*i_f_gsampf_t)(i_img *im, int x, int r, int y, i_fsample_t *samp,
90 const int *chan, int chan_count);
92 typedef int (*i_f_gpal_t)(i_img *im, int x, int r, int y, i_palidx *vals);
93 typedef int (*i_f_ppal_t)(i_img *im, int x, int r, int y, i_palidx *vals);
94 typedef int (*i_f_addcolors_t)(i_img *im, i_color *colors, int count);
95 typedef int (*i_f_getcolors_t)(i_img *im, int i, i_color *, int count);
96 typedef int (*i_f_colorcount_t)(i_img *im);
97 typedef int (*i_f_maxcolors_t)(i_img *im);
98 typedef int (*i_f_findcolor_t)(i_img *im, i_color *color, i_palidx *entry);
99 typedef int (*i_f_setcolors_t)(i_img *im, int index, i_color *colors,
102 typedef void (*i_f_destroy_t)(i_img *im);
106 int xsize,ysize,bytes;
107 unsigned int ch_mask;
110 int virtual; /* image might not keep any data, must use functions */
111 unsigned char *idata; /* renamed to force inspection of existing code */
112 /* can be NULL if virtual is non-zero */
117 /* interface functions */
119 i_f_ppixf_t i_f_ppixf;
121 i_f_plinf_t i_f_plinf;
123 i_f_gpixf_t i_f_gpixf;
125 i_f_glinf_t i_f_glinf;
126 i_f_gsamp_t i_f_gsamp;
127 i_f_gsampf_t i_f_gsampf;
129 /* only valid for type == i_palette_type */
132 i_f_addcolors_t i_f_addcolors;
133 i_f_getcolors_t i_f_getcolors;
134 i_f_colorcount_t i_f_colorcount;
135 i_f_maxcolors_t i_f_maxcolors;
136 i_f_findcolor_t i_f_findcolor;
137 i_f_setcolors_t i_f_setcolors;
139 i_f_destroy_t i_f_destroy;
142 /* ext_data for paletted images
145 int count; /* amount of space used in palette (in entries) */
146 int alloc; /* amount of space allocated for palette (in entries) */
152 The types in here so far are:
154 doubly linked bucket list - pretty efficient
155 octtree - no idea about goodness
172 struct i_bitmap* btm_new(int xsize,int ysize);
173 void btm_destroy(struct i_bitmap *btm);
174 int btm_test(struct i_bitmap *btm,int x,int y);
175 void btm_set(struct i_bitmap *btm,int x,int y);
184 /* Stack/Linked list */
189 int fill; /* Number used in this link */
194 int multip; /* # of copies in a single chain */
195 int ssize; /* size of each small element */
196 int count; /* number of elements on the list */
202 struct llink *llink_new( struct llink* p,int size );
203 int llist_llink_push( struct llist *lst, struct llink *lnk, void *data );
207 struct llist *llist_new( int multip, int ssize );
208 void llist_destroy( struct llist *l );
209 void llist_push( struct llist *l, void *data );
210 void llist_dump( struct llist *l );
211 int llist_pop( struct llist *l,void *data );
223 struct octt *octt_new(void);
224 int octt_add(struct octt *ct,unsigned char r,unsigned char g,unsigned char b);
225 void octt_dump(struct octt *ct);
226 void octt_count(struct octt *ct,int *tot,int max,int *overflow);
227 void octt_delete(struct octt *ct);
229 /* font bounding box results */
230 enum bounding_box_index_t {