9 /* used for palette indices in some internal code (which might be
12 typedef unsigned char i_palidx;
14 /* We handle 2 types of sample, this is hopefully the most common, and the
15 smaller of the ones we support */
16 typedef unsigned char i_sample_t;
18 typedef struct { i_sample_t gray_color; } gray_color;
19 typedef struct { i_sample_t r,g,b; } rgb_color;
20 typedef struct { i_sample_t r,g,b,a; } rgba_color;
21 typedef struct { i_sample_t c,m,y,k; } cmyk_color;
23 typedef int undef_int; /* special value to put in typemaps to retun undef on 0 and 1 on 1 */
30 i_sample_t channel[MAXCHANNELS];
34 /* this is the larger sample type, it should be able to accurately represent
35 any sample size we use */
36 typedef double i_fsample_t;
38 typedef struct { i_fsample_t gray_color; } i_fgray_color_t;
39 typedef struct { i_fsample_t r, g, b; } i_frgb_color_t;
40 typedef struct { i_fsample_t r, g, b, a; } i_frgba_color_t;
41 typedef struct { i_fsample_t c, m, y, k; } i_fcmyk_color_t;
48 i_fsample_t channel[MAXCHANNELS];
52 i_direct_type, /* direct colour, keeps RGB values per pixel */
53 i_palette_type /* keeps a palette index per pixel */
57 /* bits per sample, not per pixel */
58 /* a paletted image might have one bit per sample */
61 i_double_bits = sizeof(double) * 8
65 char *name; /* name of a given tag, might be NULL */
66 int code; /* number of a given tag, -1 if it has no meaning */
67 char *data; /* value of a given tag if it's not an int, may be NULL */
68 int size; /* size of the data */
69 int idata; /* value of a given tag if data is NULL */
73 int count; /* how many tags have been set */
74 int alloc; /* how many tags have been allocated for */
78 typedef struct i_img_ i_img;
79 typedef int (*i_f_ppix_t)(i_img *im, int x, int y, const i_color *pix);
80 typedef int (*i_f_ppixf_t)(i_img *im, int x, int y, const i_fcolor *pix);
81 typedef int (*i_f_plin_t)(i_img *im, int x, int r, int y, const i_color *vals);
82 typedef int (*i_f_plinf_t)(i_img *im, int x, int r, int y, const i_fcolor *vals);
83 typedef int (*i_f_gpix_t)(i_img *im, int x, int y, i_color *pix);
84 typedef int (*i_f_gpixf_t)(i_img *im, int x, int y, i_fcolor *pix);
85 typedef int (*i_f_glin_t)(i_img *im, int x, int r, int y, i_color *vals);
86 typedef int (*i_f_glinf_t)(i_img *im, int x, int r, int y, i_fcolor *vals);
88 typedef int (*i_f_gsamp_t)(i_img *im, int x, int r, int y, i_sample_t *samp,
89 const int *chans, int chan_count);
90 typedef int (*i_f_gsampf_t)(i_img *im, int x, int r, int y, i_fsample_t *samp,
91 const int *chan, int chan_count);
93 typedef int (*i_f_gpal_t)(i_img *im, int x, int r, int y, i_palidx *vals);
94 typedef int (*i_f_ppal_t)(i_img *im, int x, int r, int y, const i_palidx *vals);
95 typedef int (*i_f_addcolors_t)(i_img *im, const i_color *colors, int count);
96 typedef int (*i_f_getcolors_t)(i_img *im, int i, i_color *, int count);
97 typedef int (*i_f_colorcount_t)(i_img *im);
98 typedef int (*i_f_maxcolors_t)(i_img *im);
99 typedef int (*i_f_findcolor_t)(i_img *im, const i_color *color, i_palidx *entry);
100 typedef int (*i_f_setcolors_t)(i_img *im, int index, const i_color *colors,
103 typedef void (*i_f_destroy_t)(i_img *im);
105 typedef int i_img_dim;
109 i_img_dim xsize,ysize;
111 unsigned int ch_mask;
114 int virtual; /* image might not keep any data, must use functions */
115 unsigned char *idata; /* renamed to force inspection of existing code */
116 /* can be NULL if virtual is non-zero */
121 /* interface functions */
123 i_f_ppixf_t i_f_ppixf;
125 i_f_plinf_t i_f_plinf;
127 i_f_gpixf_t i_f_gpixf;
129 i_f_glinf_t i_f_glinf;
130 i_f_gsamp_t i_f_gsamp;
131 i_f_gsampf_t i_f_gsampf;
133 /* only valid for type == i_palette_type */
136 i_f_addcolors_t i_f_addcolors;
137 i_f_getcolors_t i_f_getcolors;
138 i_f_colorcount_t i_f_colorcount;
139 i_f_maxcolors_t i_f_maxcolors;
140 i_f_findcolor_t i_f_findcolor;
141 i_f_setcolors_t i_f_setcolors;
143 i_f_destroy_t i_f_destroy;
146 /* ext_data for paletted images
149 int count; /* amount of space used in palette (in entries) */
150 int alloc; /* amount of space allocated for palette (in entries) */
156 The types in here so far are:
158 doubly linked bucket list - pretty efficient
159 octtree - no idea about goodness
176 struct i_bitmap* btm_new(int xsize,int ysize);
177 void btm_destroy(struct i_bitmap *btm);
178 int btm_test(struct i_bitmap *btm,int x,int y);
179 void btm_set(struct i_bitmap *btm,int x,int y);
188 /* Stack/Linked list */
193 int fill; /* Number used in this link */
198 int multip; /* # of copies in a single chain */
199 int ssize; /* size of each small element */
200 int count; /* number of elements on the list */
206 struct llink *llink_new( struct llink* p,int size );
207 int llist_llink_push( struct llist *lst, struct llink *lnk, void *data );
211 struct llist *llist_new( int multip, int ssize );
212 void llist_destroy( struct llist *l );
213 void llist_push( struct llist *l, void *data );
214 void llist_dump( struct llist *l );
215 int llist_pop( struct llist *l,void *data );
227 struct octt *octt_new(void);
228 int octt_add(struct octt *ct,unsigned char r,unsigned char g,unsigned char b);
229 void octt_dump(struct octt *ct);
230 void octt_count(struct octt *ct,int *tot,int max,int *overflow);
231 void octt_delete(struct octt *ct);
232 void octt_histo(struct octt *ct, unsigned int **col_usage_it_adr);
234 /* font bounding box results */
235 enum bounding_box_index_t {
250 typedef void (*i_fill_with_color_f)
251 (struct i_fill_tag *fill, int x, int y, int width, int channels,
253 typedef void (*i_fill_with_fcolor_f)
254 (struct i_fill_tag *fill, int x, int y, int width, int channels,
256 typedef void (*i_fill_destroy_f)(struct i_fill_tag *fill);
257 typedef void (*i_fill_combine_f)(i_color *out, i_color *in, int channels,
259 typedef void (*i_fill_combinef_f)(i_fcolor *out, i_fcolor *in, int channels,
262 /* fountain fill types */
270 } i_fountain_seg_type;
278 double start, middle, end;
280 i_fountain_seg_type type;
281 i_fountain_color color;
307 typedef struct i_fill_tag
309 /* called for 8-bit/sample image (and maybe lower) */
310 /* this may be NULL, if so call fill_with_fcolor */
311 i_fill_with_color_f fill_with_color;
313 /* called for other sample sizes */
314 /* this must be non-NULL */
315 i_fill_with_fcolor_f fill_with_fcolor;
317 /* called if non-NULL to release any extra resources */
318 i_fill_destroy_f destroy;
320 /* if non-zero the caller will fill data with the original data
322 i_fill_combine_f combine;
323 i_fill_combinef_f combinef;
343 describes an axis of a MM font.
344 Modelled on FT2's FT_MM_Axis.
345 It would be nice to have a default entry too, but FT2
348 typedef struct i_font_mm_axis_tag {
354 #define IM_FONT_MM_MAX_AXES 4
357 multiple master information for a font, if any
358 modelled on FT2's FT_Multi_Master.
360 typedef struct i_font_mm_tag {
362 int num_designs; /* provided but not necessarily useful */
363 i_font_mm_axis axis[IM_FONT_MM_MAX_AXES];
368 struct TT_Fonthandle_;
370 typedef struct TT_Fonthandle_ TT_Fonthandle;
376 typedef struct FT2_Fonthandle FT2_Fonthandle;
380 /* transparency handling for quantized output */
381 typedef enum i_transp_tag {
382 tr_none, /* ignore any alpha channel */
383 tr_threshold, /* threshold the transparency - uses tr_threshold */
384 tr_errdiff, /* error diffusion */
385 tr_ordered /* an ordered dither */
388 /* controls how we build the colour map */
389 typedef enum i_make_colors_tag {
390 mc_none, /* user supplied colour map only */
391 mc_web_map, /* Use the 216 colour web colour map */
392 mc_addi, /* Addi's algorithm */
393 mc_median_cut, /* median cut - similar to giflib, hopefully */
394 mc_mono, /* fixed mono color map */
395 mc_mask = 0xFF /* (mask for generator) */
398 /* controls how we translate the colours */
399 typedef enum i_translate_tag {
400 pt_giflib, /* get gif lib to do it (ignores make_colours) */
401 pt_closest, /* just use the closest match within the hashbox */
402 pt_perturb, /* randomly perturb the data - uses perturb_size*/
403 pt_errdiff /* error diffusion dither - uses errdiff */
406 /* Which error diffusion map to use */
407 typedef enum i_errdiff_tag {
408 ed_floyd, /* floyd-steinberg */
409 ed_jarvis, /* Jarvis, Judice and Ninke */
410 ed_stucki, /* Stucki */
411 ed_custom, /* the map found in ed_map|width|height|orig */
412 ed_mask = 0xFF, /* mask to get the map */
413 ed_bidir = 0x100 /* change direction for each row */
416 /* which ordered dither map to use
417 currently only available for transparency
418 I don't know of a way to do ordered dither of an image against some
421 typedef enum i_ord_dith_tag
423 od_random, /* sort of random */
424 od_dot8, /* large dot */
428 od_slashline, /* / line dither */
429 od_backline, /* \ line dither */
430 od_tiny, /* small checkerbox */
431 od_custom /* custom 8x8 map */
434 typedef struct i_gif_pos_tag {
438 /* passed into i_writegif_gen() to control quantization */
439 typedef struct i_quantize_tag {
440 /* how to handle transparency */
442 /* the threshold at which to make pixels opaque */
444 i_errdiff tr_errdiff;
445 i_ord_dith tr_orddith;
446 unsigned char tr_custom[64];
448 /* how to make the colour map */
449 i_make_colors make_colors;
451 /* any existing colours
452 mc_existing is an existing colour table
453 mc_count is the number of existing colours
454 mc_size is the total size of the array that mc_existing points
455 at - this must be at least 256
461 /* how we translate the colours */
462 i_translate translate;
464 /* the error diffusion map to use if translate is mc_errdiff */
466 /* the following define the error diffusion values to use if
467 errdiff is ed_custom. ed_orig is the column on the top row that
468 represents the current
471 int ed_width, ed_height, ed_orig;
473 /* the amount of perturbation to use for translate is mc_perturb */
477 typedef struct i_gif_opts {
478 /* each image has a local color map */
481 /* images are interlaced */
484 /* time for which image is displayed
494 int user_input_count;
495 char *user_input_flags;
502 /* this is added to the color table when we make an image transparent */
505 /* image positions */
507 i_gif_pos *positions;
509 /* Netscape loop extension - number of loops */
512 /* should be eliminate unused colors? */
513 int eliminate_unused;
516 /* distance measures used by some filters */
518 i_dmeasure_euclidean = 0,
519 i_dmeasure_euclidean_squared = 1,
520 i_dmeasure_manhatten = 2,
521 i_dmeasure_limit = 2,
524 #include "iolayert.h"