Commit | Line | Data |
---|---|---|
02d1d628 AMH |
1 | #ifndef _DATATYPES_H_ |
2 | #define _DATATYPES_H_ | |
3 | ||
92bda632 | 4 | #include "imconfig.h" |
d5477d3d | 5 | #include "imio.h" |
02d1d628 AMH |
6 | |
7 | #define MAXCHANNELS 4 | |
8 | ||
faa9b3e7 TC |
9 | /* used for palette indices in some internal code (which might be |
10 | exposed at some point | |
11 | */ | |
12 | typedef unsigned char i_palidx; | |
13 | ||
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; | |
17 | ||
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; | |
02d1d628 AMH |
22 | |
23 | typedef int undef_int; /* special value to put in typemaps to retun undef on 0 and 1 on 1 */ | |
24 | ||
6cfee9d1 TC |
25 | /* |
26 | =item i_color | |
27 | =category Data Types | |
28 | =synopsis i_color black; | |
29 | =synopsis black.rgba.r = black.rgba.g = black.rgba.b = black.rgba.a = 0; | |
30 | ||
31 | Type for 8-bit/sample color. | |
32 | ||
33 | Samples as per; | |
34 | ||
35 | i_color c; | |
36 | ||
37 | i_color is a union of: | |
38 | ||
39 | =over | |
40 | ||
41 | =item * | |
42 | ||
43 | gray - contains a single element gray_color, eg. c.gray.gray_color | |
44 | ||
45 | =item * | |
46 | ||
47 | rgb - contains three elements r, g, b, eg. c.rgb.r | |
48 | ||
49 | =item * | |
50 | ||
51 | rgba - contains four elements r, g, b, a, eg. c.rgba.a | |
52 | ||
53 | =item * | |
54 | ||
55 | cmyk - contains four elements c, m, y, k, eg. C<c.cmyk.y>. Note that | |
56 | Imager never uses CMYK colors except when reading/writing files. | |
57 | ||
58 | =item * | |
59 | ||
60 | channels - an array of four channels, eg C<c.channels[2]>. | |
61 | ||
62 | =back | |
63 | ||
64 | =cut | |
65 | */ | |
66 | ||
02d1d628 AMH |
67 | typedef union { |
68 | gray_color gray; | |
69 | rgb_color rgb; | |
70 | rgba_color rgba; | |
71 | cmyk_color cmyk; | |
faa9b3e7 | 72 | i_sample_t channel[MAXCHANNELS]; |
02d1d628 AMH |
73 | unsigned int ui; |
74 | } i_color; | |
75 | ||
faa9b3e7 TC |
76 | /* this is the larger sample type, it should be able to accurately represent |
77 | any sample size we use */ | |
78 | typedef double i_fsample_t; | |
02d1d628 | 79 | |
faa9b3e7 TC |
80 | typedef struct { i_fsample_t gray_color; } i_fgray_color_t; |
81 | typedef struct { i_fsample_t r, g, b; } i_frgb_color_t; | |
82 | typedef struct { i_fsample_t r, g, b, a; } i_frgba_color_t; | |
83 | typedef struct { i_fsample_t c, m, y, k; } i_fcmyk_color_t; | |
84 | ||
6cfee9d1 TC |
85 | /* |
86 | =item i_fcolor | |
87 | =category Data Types | |
88 | ||
89 | This is the double/sample color type. | |
90 | ||
91 | Its layout exactly corresponds to i_color. | |
92 | ||
93 | =cut | |
94 | */ | |
95 | ||
faa9b3e7 TC |
96 | typedef union { |
97 | i_fgray_color_t gray; | |
98 | i_frgb_color_t rgb; | |
99 | i_frgba_color_t rgba; | |
100 | i_fcmyk_color_t cmyk; | |
101 | i_fsample_t channel[MAXCHANNELS]; | |
102 | } i_fcolor; | |
103 | ||
104 | typedef enum { | |
105 | i_direct_type, /* direct colour, keeps RGB values per pixel */ | |
26fd367b | 106 | i_palette_type /* keeps a palette index per pixel */ |
faa9b3e7 TC |
107 | } i_img_type_t; |
108 | ||
109 | typedef enum { | |
110 | /* bits per sample, not per pixel */ | |
111 | /* a paletted image might have one bit per sample */ | |
112 | i_8_bits = 8, | |
113 | i_16_bits = 16, | |
26fd367b | 114 | i_double_bits = sizeof(double) * 8 |
faa9b3e7 TC |
115 | } i_img_bits_t; |
116 | ||
117 | typedef struct { | |
118 | char *name; /* name of a given tag, might be NULL */ | |
119 | int code; /* number of a given tag, -1 if it has no meaning */ | |
120 | char *data; /* value of a given tag if it's not an int, may be NULL */ | |
121 | int size; /* size of the data */ | |
122 | int idata; /* value of a given tag if data is NULL */ | |
123 | } i_img_tag; | |
124 | ||
125 | typedef struct { | |
126 | int count; /* how many tags have been set */ | |
127 | int alloc; /* how many tags have been allocated for */ | |
128 | i_img_tag *tags; | |
129 | } i_img_tags; | |
130 | ||
131 | typedef struct i_img_ i_img; | |
97ac0a96 TC |
132 | typedef int (*i_f_ppix_t)(i_img *im, int x, int y, const i_color *pix); |
133 | typedef int (*i_f_ppixf_t)(i_img *im, int x, int y, const i_fcolor *pix); | |
134 | typedef int (*i_f_plin_t)(i_img *im, int x, int r, int y, const i_color *vals); | |
135 | typedef int (*i_f_plinf_t)(i_img *im, int x, int r, int y, const i_fcolor *vals); | |
faa9b3e7 TC |
136 | typedef int (*i_f_gpix_t)(i_img *im, int x, int y, i_color *pix); |
137 | typedef int (*i_f_gpixf_t)(i_img *im, int x, int y, i_fcolor *pix); | |
138 | typedef int (*i_f_glin_t)(i_img *im, int x, int r, int y, i_color *vals); | |
139 | typedef int (*i_f_glinf_t)(i_img *im, int x, int r, int y, i_fcolor *vals); | |
140 | ||
141 | typedef int (*i_f_gsamp_t)(i_img *im, int x, int r, int y, i_sample_t *samp, | |
18accb2a | 142 | const int *chans, int chan_count); |
faa9b3e7 | 143 | typedef int (*i_f_gsampf_t)(i_img *im, int x, int r, int y, i_fsample_t *samp, |
18accb2a | 144 | const int *chan, int chan_count); |
faa9b3e7 TC |
145 | |
146 | typedef int (*i_f_gpal_t)(i_img *im, int x, int r, int y, i_palidx *vals); | |
97ac0a96 TC |
147 | typedef int (*i_f_ppal_t)(i_img *im, int x, int r, int y, const i_palidx *vals); |
148 | typedef int (*i_f_addcolors_t)(i_img *im, const i_color *colors, int count); | |
faa9b3e7 TC |
149 | typedef int (*i_f_getcolors_t)(i_img *im, int i, i_color *, int count); |
150 | typedef int (*i_f_colorcount_t)(i_img *im); | |
151 | typedef int (*i_f_maxcolors_t)(i_img *im); | |
97ac0a96 TC |
152 | typedef int (*i_f_findcolor_t)(i_img *im, const i_color *color, i_palidx *entry); |
153 | typedef int (*i_f_setcolors_t)(i_img *im, int index, const i_color *colors, | |
faa9b3e7 TC |
154 | int count); |
155 | ||
156 | typedef void (*i_f_destroy_t)(i_img *im); | |
157 | ||
bd8052a6 TC |
158 | typedef int (*i_f_gsamp_bits_t)(i_img *im, int x, int r, int y, unsigned *samp, |
159 | const int *chans, int chan_count, int bits); | |
160 | typedef int (*i_f_psamp_bits_t)(i_img *im, int x, int r, int y, unsigned const *samp, | |
161 | const int *chans, int chan_count, int bits); | |
162 | ||
6cfee9d1 TC |
163 | /* |
164 | =item i_img_dim | |
165 | =category Data Types | |
166 | =synopsis i_img_dim x; | |
167 | =order 90 | |
168 | ||
169 | A signed integer type that represents an image dimension or ordinate. | |
170 | ||
171 | May be larger than int on some platforms. | |
172 | ||
173 | =cut | |
174 | */ | |
d5477d3d TC |
175 | typedef int i_img_dim; |
176 | ||
bd8052a6 TC |
177 | /* |
178 | =item i_img | |
179 | =category Data Types | |
180 | =synopsis i_img *img; | |
6cfee9d1 | 181 | =order 10 |
bd8052a6 TC |
182 | |
183 | This is Imager's image type. | |
184 | ||
185 | It contains the following members: | |
186 | ||
187 | =over | |
188 | ||
189 | =item * | |
190 | ||
191 | channels - the number of channels in the image | |
192 | ||
193 | =item * | |
194 | ||
195 | xsize, ysize - the width and height of the image in pixels | |
196 | ||
197 | =item * | |
198 | ||
199 | bytes - the number of bytes used to store the image data. Undefined | |
200 | where virtual is non-zero. | |
201 | ||
202 | =item * | |
203 | ||
204 | ch_mask - a mask of writable channels. eg. if this is 6 then only | |
205 | channels 1 and 2 are writable. There may be bits set for which there | |
206 | are no channels in the image. | |
207 | ||
208 | =item * | |
209 | ||
210 | bits - the number of bits stored per sample. Should be one of | |
211 | i_8_bits, i_16_bits, i_double_bits. | |
212 | ||
213 | =item * | |
214 | ||
215 | type - either i_direct_type for direct color images, or i_palette_type | |
216 | for paletted images. | |
217 | ||
218 | =item * | |
219 | ||
220 | virtual - if zero then this image is-self contained. If non-zero then | |
221 | this image could be an interface to some other implementation. | |
222 | ||
223 | =item * | |
224 | ||
225 | idata - the image data. This should not be directly accessed. A new | |
226 | image implementation can use this to store its image data. | |
227 | i_img_destroy() will myfree() this pointer if it's non-null. | |
228 | ||
229 | =item * | |
230 | ||
231 | tags - a structure storing the image's tags. This should only be | |
232 | accessed via the i_tags_*() functions. | |
233 | ||
234 | =item * | |
235 | ||
236 | ext_data - a pointer for use internal to an image implementation. | |
237 | This should be freed by the image's destroy handler. | |
238 | ||
239 | =item * | |
240 | ||
241 | im_data - data internal to Imager. This is initialized by | |
242 | i_img_init(). | |
243 | ||
244 | =item * | |
245 | ||
246 | i_f_ppix, i_f_ppixf, i_f_plin, i_f_plinf, i_f_gpix, i_f_gpixf, | |
247 | i_f_glin, i_f_glinf, i_f_gsamp, i_f_gampf - implementations for each | |
248 | of the required image functions. An image implementation should | |
249 | initialize these between calling i_img_alloc() and i_img_init(). | |
250 | ||
251 | =item * | |
252 | ||
253 | i_f_gpal, i_f_ppal, i_f_addcolors, i_f_getcolors, i_f_colorcount, | |
254 | i_f_maxcolors, i_f_findcolor, i_f_setcolors - implementations for each | |
255 | paletted image function. | |
256 | ||
257 | =item * | |
258 | ||
259 | i_f_destroy - custom image destruction function. This should be used | |
260 | to release memory if necessary. | |
261 | ||
262 | =item * | |
263 | ||
264 | i_f_gsamp_bits - implements i_gsamp_bits() for this image. | |
265 | ||
266 | =item * | |
267 | ||
268 | i_f_psamp_bits - implements i_psamp_bits() for this image. | |
269 | ||
270 | =back | |
271 | ||
272 | =cut | |
273 | */ | |
274 | ||
faa9b3e7 | 275 | struct i_img_ { |
02d1d628 | 276 | int channels; |
d5477d3d TC |
277 | i_img_dim xsize,ysize; |
278 | size_t bytes; | |
02d1d628 | 279 | unsigned int ch_mask; |
faa9b3e7 TC |
280 | i_img_bits_t bits; |
281 | i_img_type_t type; | |
282 | int virtual; /* image might not keep any data, must use functions */ | |
283 | unsigned char *idata; /* renamed to force inspection of existing code */ | |
284 | /* can be NULL if virtual is non-zero */ | |
285 | i_img_tags tags; | |
02d1d628 | 286 | |
02d1d628 | 287 | void *ext_data; |
02d1d628 | 288 | |
faa9b3e7 TC |
289 | /* interface functions */ |
290 | i_f_ppix_t i_f_ppix; | |
291 | i_f_ppixf_t i_f_ppixf; | |
292 | i_f_plin_t i_f_plin; | |
293 | i_f_plinf_t i_f_plinf; | |
294 | i_f_gpix_t i_f_gpix; | |
295 | i_f_gpixf_t i_f_gpixf; | |
296 | i_f_glin_t i_f_glin; | |
297 | i_f_glinf_t i_f_glinf; | |
298 | i_f_gsamp_t i_f_gsamp; | |
299 | i_f_gsampf_t i_f_gsampf; | |
300 | ||
301 | /* only valid for type == i_palette_type */ | |
302 | i_f_gpal_t i_f_gpal; | |
303 | i_f_ppal_t i_f_ppal; | |
304 | i_f_addcolors_t i_f_addcolors; | |
305 | i_f_getcolors_t i_f_getcolors; | |
306 | i_f_colorcount_t i_f_colorcount; | |
307 | i_f_maxcolors_t i_f_maxcolors; | |
308 | i_f_findcolor_t i_f_findcolor; | |
309 | i_f_setcolors_t i_f_setcolors; | |
310 | ||
311 | i_f_destroy_t i_f_destroy; | |
bd8052a6 TC |
312 | |
313 | /* as of 0.61 */ | |
314 | i_f_gsamp_bits_t i_f_gsamp_bits; | |
315 | i_f_psamp_bits_t i_f_psamp_bits; | |
316 | ||
317 | void *im_data; | |
faa9b3e7 | 318 | }; |
02d1d628 | 319 | |
faa9b3e7 TC |
320 | /* ext_data for paletted images |
321 | */ | |
322 | typedef struct { | |
323 | int count; /* amount of space used in palette (in entries) */ | |
324 | int alloc; /* amount of space allocated for palette (in entries) */ | |
325 | i_color *pal; | |
326 | int last_found; | |
327 | } i_img_pal_ext; | |
02d1d628 | 328 | |
faa9b3e7 | 329 | /* Helper datatypes |
02d1d628 AMH |
330 | The types in here so far are: |
331 | ||
332 | doubly linked bucket list - pretty efficient | |
333 | octtree - no idea about goodness | |
334 | ||
335 | needed: hashes. | |
336 | ||
337 | */ | |
338 | ||
02d1d628 AMH |
339 | /* bitmap mask */ |
340 | ||
341 | struct i_bitmap { | |
342 | int xsize,ysize; | |
343 | char *data; | |
344 | }; | |
345 | ||
346 | struct i_bitmap* btm_new(int xsize,int ysize); | |
347 | void btm_destroy(struct i_bitmap *btm); | |
348 | int btm_test(struct i_bitmap *btm,int x,int y); | |
349 | void btm_set(struct i_bitmap *btm,int x,int y); | |
350 | ||
351 | ||
02d1d628 AMH |
352 | /* Stack/Linked list */ |
353 | ||
354 | struct llink { | |
355 | struct llink *p,*n; | |
356 | void *data; | |
357 | int fill; /* Number used in this link */ | |
358 | }; | |
359 | ||
360 | struct llist { | |
361 | struct llink *h,*t; | |
362 | int multip; /* # of copies in a single chain */ | |
363 | int ssize; /* size of each small element */ | |
364 | int count; /* number of elements on the list */ | |
365 | }; | |
366 | ||
367 | ||
368 | /* Links */ | |
369 | ||
370 | struct llink *llink_new( struct llink* p,int size ); | |
371 | int llist_llink_push( struct llist *lst, struct llink *lnk, void *data ); | |
372 | ||
373 | /* Lists */ | |
374 | ||
375 | struct llist *llist_new( int multip, int ssize ); | |
376 | void llist_destroy( struct llist *l ); | |
377 | void llist_push( struct llist *l, void *data ); | |
378 | void llist_dump( struct llist *l ); | |
379 | int llist_pop( struct llist *l,void *data ); | |
380 | ||
381 | ||
382 | ||
383 | ||
384 | /* Octtree */ | |
385 | ||
386 | struct octt { | |
387 | struct octt *t[8]; | |
388 | int cnt; | |
389 | }; | |
390 | ||
faa9b3e7 | 391 | struct octt *octt_new(void); |
02d1d628 AMH |
392 | int octt_add(struct octt *ct,unsigned char r,unsigned char g,unsigned char b); |
393 | void octt_dump(struct octt *ct); | |
394 | void octt_count(struct octt *ct,int *tot,int max,int *overflow); | |
395 | void octt_delete(struct octt *ct); | |
a60905e4 | 396 | void octt_histo(struct octt *ct, unsigned int **col_usage_it_adr); |
02d1d628 | 397 | |
3799c4d1 TC |
398 | /* font bounding box results */ |
399 | enum bounding_box_index_t { | |
400 | BBOX_NEG_WIDTH, | |
401 | BBOX_GLOBAL_DESCENT, | |
402 | BBOX_POS_WIDTH, | |
403 | BBOX_GLOBAL_ASCENT, | |
404 | BBOX_DESCENT, | |
405 | BBOX_ASCENT, | |
406 | BBOX_ADVANCE_WIDTH, | |
dc35bde9 | 407 | BBOX_RIGHT_BEARING, |
3799c4d1 TC |
408 | BOUNDING_BOX_COUNT |
409 | }; | |
410 | ||
92bda632 TC |
411 | /* Generic fills */ |
412 | struct i_fill_tag; | |
413 | ||
414 | typedef void (*i_fill_with_color_f) | |
415 | (struct i_fill_tag *fill, int x, int y, int width, int channels, | |
416 | i_color *data); | |
417 | typedef void (*i_fill_with_fcolor_f) | |
418 | (struct i_fill_tag *fill, int x, int y, int width, int channels, | |
419 | i_fcolor *data); | |
420 | typedef void (*i_fill_destroy_f)(struct i_fill_tag *fill); | |
9b1ec2b8 TC |
421 | |
422 | /* combine functions modify their target and are permitted to modify | |
423 | the source to prevent having to perform extra copying/memory | |
424 | allocations, etc | |
425 | The out array has I<channels> channels. | |
426 | ||
427 | The in array has I<channels> channels + an alpha channel if one | |
428 | isn't included in I<channels>. | |
429 | */ | |
430 | ||
92bda632 TC |
431 | typedef void (*i_fill_combine_f)(i_color *out, i_color *in, int channels, |
432 | int count); | |
433 | typedef void (*i_fill_combinef_f)(i_fcolor *out, i_fcolor *in, int channels, | |
434 | int count); | |
435 | ||
436 | /* fountain fill types */ | |
437 | typedef enum { | |
438 | i_fst_linear, | |
439 | i_fst_curved, | |
440 | i_fst_sine, | |
441 | i_fst_sphere_up, | |
442 | i_fst_sphere_down, | |
443 | i_fst_end | |
444 | } i_fountain_seg_type; | |
445 | typedef enum { | |
446 | i_fc_direct, | |
447 | i_fc_hue_up, | |
448 | i_fc_hue_down, | |
449 | i_fc_end | |
450 | } i_fountain_color; | |
451 | typedef struct { | |
452 | double start, middle, end; | |
453 | i_fcolor c[2]; | |
454 | i_fountain_seg_type type; | |
455 | i_fountain_color color; | |
456 | } i_fountain_seg; | |
457 | typedef enum { | |
458 | i_fr_none, | |
459 | i_fr_sawtooth, | |
460 | i_fr_triangle, | |
461 | i_fr_saw_both, | |
462 | i_fr_tri_both | |
463 | } i_fountain_repeat; | |
464 | typedef enum { | |
465 | i_ft_linear, | |
466 | i_ft_bilinear, | |
467 | i_ft_radial, | |
468 | i_ft_radial_square, | |
469 | i_ft_revolution, | |
470 | i_ft_conical, | |
471 | i_ft_end | |
472 | } i_fountain_type; | |
473 | typedef enum { | |
474 | i_fts_none, | |
475 | i_fts_grid, | |
476 | i_fts_random, | |
477 | i_fts_circle | |
478 | } i_ft_supersample; | |
479 | ||
6cfee9d1 TC |
480 | /* |
481 | =item i_fill_t | |
482 | =category Data Types | |
483 | =synopsis i_fill_t *fill; | |
484 | ||
485 | This is the "abstract" base type for Imager's fill types. | |
486 | ||
487 | Unless you're implementing a new fill type you'll typically treat this | |
488 | as an opaque type. | |
489 | ||
490 | =cut | |
491 | */ | |
92bda632 TC |
492 | |
493 | typedef struct i_fill_tag | |
494 | { | |
495 | /* called for 8-bit/sample image (and maybe lower) */ | |
496 | /* this may be NULL, if so call fill_with_fcolor */ | |
9b1ec2b8 | 497 | i_fill_with_color_f f_fill_with_color; |
92bda632 TC |
498 | |
499 | /* called for other sample sizes */ | |
500 | /* this must be non-NULL */ | |
9b1ec2b8 | 501 | i_fill_with_fcolor_f f_fill_with_fcolor; |
92bda632 TC |
502 | |
503 | /* called if non-NULL to release any extra resources */ | |
504 | i_fill_destroy_f destroy; | |
505 | ||
506 | /* if non-zero the caller will fill data with the original data | |
507 | from the image */ | |
508 | i_fill_combine_f combine; | |
509 | i_fill_combinef_f combinef; | |
510 | } i_fill_t; | |
511 | ||
512 | typedef enum { | |
513 | ic_none, | |
514 | ic_normal, | |
515 | ic_multiply, | |
516 | ic_dissolve, | |
517 | ic_add, | |
518 | ic_subtract, | |
519 | ic_diff, | |
520 | ic_lighten, | |
521 | ic_darken, | |
522 | ic_hue, | |
523 | ic_sat, | |
524 | ic_value, | |
525 | ic_color | |
526 | } i_combine_t; | |
527 | ||
528 | /* | |
529 | describes an axis of a MM font. | |
530 | Modelled on FT2's FT_MM_Axis. | |
531 | It would be nice to have a default entry too, but FT2 | |
532 | doesn't support it. | |
533 | */ | |
534 | typedef struct i_font_mm_axis_tag { | |
535 | char const *name; | |
536 | int minimum; | |
537 | int maximum; | |
538 | } i_font_mm_axis; | |
539 | ||
540 | #define IM_FONT_MM_MAX_AXES 4 | |
541 | ||
542 | /* | |
543 | multiple master information for a font, if any | |
544 | modelled on FT2's FT_Multi_Master. | |
545 | */ | |
546 | typedef struct i_font_mm_tag { | |
547 | int num_axis; | |
548 | int num_designs; /* provided but not necessarily useful */ | |
549 | i_font_mm_axis axis[IM_FONT_MM_MAX_AXES]; | |
550 | } i_font_mm; | |
551 | ||
552 | #ifdef HAVE_LIBTT | |
553 | ||
554 | struct TT_Fonthandle_; | |
555 | ||
556 | typedef struct TT_Fonthandle_ TT_Fonthandle; | |
557 | ||
558 | #endif | |
559 | ||
560 | #ifdef HAVE_FT2 | |
561 | ||
562 | typedef struct FT2_Fonthandle FT2_Fonthandle; | |
563 | ||
564 | #endif | |
565 | ||
566 | /* transparency handling for quantized output */ | |
567 | typedef enum i_transp_tag { | |
568 | tr_none, /* ignore any alpha channel */ | |
569 | tr_threshold, /* threshold the transparency - uses tr_threshold */ | |
570 | tr_errdiff, /* error diffusion */ | |
571 | tr_ordered /* an ordered dither */ | |
572 | } i_transp; | |
573 | ||
574 | /* controls how we build the colour map */ | |
575 | typedef enum i_make_colors_tag { | |
576 | mc_none, /* user supplied colour map only */ | |
577 | mc_web_map, /* Use the 216 colour web colour map */ | |
578 | mc_addi, /* Addi's algorithm */ | |
579 | mc_median_cut, /* median cut - similar to giflib, hopefully */ | |
9c106321 | 580 | mc_mono, /* fixed mono color map */ |
92bda632 TC |
581 | mc_mask = 0xFF /* (mask for generator) */ |
582 | } i_make_colors; | |
583 | ||
584 | /* controls how we translate the colours */ | |
585 | typedef enum i_translate_tag { | |
586 | pt_giflib, /* get gif lib to do it (ignores make_colours) */ | |
587 | pt_closest, /* just use the closest match within the hashbox */ | |
588 | pt_perturb, /* randomly perturb the data - uses perturb_size*/ | |
589 | pt_errdiff /* error diffusion dither - uses errdiff */ | |
590 | } i_translate; | |
591 | ||
592 | /* Which error diffusion map to use */ | |
593 | typedef enum i_errdiff_tag { | |
594 | ed_floyd, /* floyd-steinberg */ | |
595 | ed_jarvis, /* Jarvis, Judice and Ninke */ | |
596 | ed_stucki, /* Stucki */ | |
597 | ed_custom, /* the map found in ed_map|width|height|orig */ | |
598 | ed_mask = 0xFF, /* mask to get the map */ | |
599 | ed_bidir = 0x100 /* change direction for each row */ | |
600 | } i_errdiff; | |
601 | ||
602 | /* which ordered dither map to use | |
603 | currently only available for transparency | |
604 | I don't know of a way to do ordered dither of an image against some | |
605 | general palette | |
606 | */ | |
607 | typedef enum i_ord_dith_tag | |
608 | { | |
609 | od_random, /* sort of random */ | |
610 | od_dot8, /* large dot */ | |
611 | od_dot4, | |
612 | od_hline, | |
613 | od_vline, | |
614 | od_slashline, /* / line dither */ | |
615 | od_backline, /* \ line dither */ | |
616 | od_tiny, /* small checkerbox */ | |
617 | od_custom /* custom 8x8 map */ | |
618 | } i_ord_dith; | |
619 | ||
620 | typedef struct i_gif_pos_tag { | |
621 | int x, y; | |
622 | } i_gif_pos; | |
623 | ||
624 | /* passed into i_writegif_gen() to control quantization */ | |
625 | typedef struct i_quantize_tag { | |
626 | /* how to handle transparency */ | |
627 | i_transp transp; | |
628 | /* the threshold at which to make pixels opaque */ | |
629 | int tr_threshold; | |
630 | i_errdiff tr_errdiff; | |
631 | i_ord_dith tr_orddith; | |
632 | unsigned char tr_custom[64]; | |
633 | ||
634 | /* how to make the colour map */ | |
635 | i_make_colors make_colors; | |
636 | ||
637 | /* any existing colours | |
638 | mc_existing is an existing colour table | |
639 | mc_count is the number of existing colours | |
640 | mc_size is the total size of the array that mc_existing points | |
641 | at - this must be at least 256 | |
642 | */ | |
643 | i_color *mc_colors; | |
644 | int mc_size; | |
645 | int mc_count; | |
646 | ||
647 | /* how we translate the colours */ | |
648 | i_translate translate; | |
649 | ||
650 | /* the error diffusion map to use if translate is mc_errdiff */ | |
651 | i_errdiff errdiff; | |
652 | /* the following define the error diffusion values to use if | |
653 | errdiff is ed_custom. ed_orig is the column on the top row that | |
654 | represents the current | |
655 | */ | |
656 | int *ed_map; | |
657 | int ed_width, ed_height, ed_orig; | |
658 | ||
659 | /* the amount of perturbation to use for translate is mc_perturb */ | |
660 | int perturb; | |
661 | } i_quantize; | |
662 | ||
663 | typedef struct i_gif_opts { | |
664 | /* each image has a local color map */ | |
665 | int each_palette; | |
666 | ||
667 | /* images are interlaced */ | |
668 | int interlace; | |
669 | ||
670 | /* time for which image is displayed | |
671 | (in 1/100 seconds) | |
672 | default: 0 | |
673 | */ | |
674 | int delay_count; | |
675 | int *delays; | |
676 | ||
677 | /* user input flags | |
678 | default: 0 | |
679 | */ | |
680 | int user_input_count; | |
681 | char *user_input_flags; | |
682 | ||
683 | /* disposal | |
684 | default: 0 */ | |
685 | int disposal_count; | |
686 | char *disposal; | |
687 | ||
688 | /* this is added to the color table when we make an image transparent */ | |
689 | i_color tran_color; | |
690 | ||
691 | /* image positions */ | |
692 | int position_count; | |
693 | i_gif_pos *positions; | |
694 | ||
695 | /* Netscape loop extension - number of loops */ | |
696 | int loop_count; | |
697 | ||
698 | /* should be eliminate unused colors? */ | |
699 | int eliminate_unused; | |
700 | } i_gif_opts; | |
701 | ||
e310e5f9 TC |
702 | /* distance measures used by some filters */ |
703 | enum { | |
704 | i_dmeasure_euclidean = 0, | |
705 | i_dmeasure_euclidean_squared = 1, | |
706 | i_dmeasure_manhatten = 2, | |
707 | i_dmeasure_limit = 2, | |
708 | }; | |
92bda632 | 709 | |
0778adbf | 710 | #include "iolayert.h" |
92bda632 | 711 | |
9c106321 TC |
712 | #include "rendert.h" |
713 | ||
02d1d628 AMH |
714 | #endif |
715 |