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