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