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