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