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