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