Debian Codegraph @

immacros.h

raw
1 /*
2 Imager "functions" implemented as macros
3
4 I suppose these could go in imdatatypes, but they aren't types.
5 */
6 #ifndef IMAGER_IMMACROS_H_
7 #define IMAGER_IMMACROS_H_
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 /*
14 =item i_img_has_alpha(C<im>)
15
16 =category Image Information
17
18 Return true if the image has an alpha channel.
19
20 =cut
21 */
22
23 #define i_img_has_alpha(im) (i_img_alpha_channel((im), NULL))
24
25 /*
26 =item i_psamp(im, left, right, y, samples, channels, channel_count)
27 =category Drawing
28
29 Writes sample values from C<samples> to C<im> for the horizontal line
30 (left, y) to (right-1, y) inclusive for the channels specified by
31 C<channels>, an array of C<int> with C<channel_count> elements.
32
33 If C<channels> is C<NULL> then the first C<channels_count> channels
34 are written to for each pixel.
35
36 Returns the number of samples written, which should be (right - left)
37 * channel_count. If a channel not in the image is in channels, left
38 is negative, left is outside the image or y is outside the image,
39 returns -1 and pushes an error.
40
41 =cut
42 */
43
44 #define i_psamp(im, l, r, y, samps, chans, count) \
45 (((im)->i_f_psamp)((im), (l), (r), (y), (samps), (chans), (count)))
46
47 /*
48 =item i_psampf(im, left, right, y, samples, channels, channel_count)
49 =category Drawing
50
51 Writes floating point sample values from C<samples> to C<im> for the
52 horizontal line (left, y) to (right-1, y) inclusive for the channels
53 specified by C<channels>, an array of C<int> with C<channel_count>
54 elements.
55
56 If C<channels> is C<NULL> then the first C<channels_count> channels
57 are written to for each pixel.
58
59 Returns the number of samples written, which should be (right - left)
60 * channel_count. If a channel not in the image is in channels, left
61 is negative, left is outside the image or y is outside the image,
62 returns -1 and pushes an error.
63
64 =cut
65 */
66
67 #define i_psampf(im, l, r, y, samps, chans, count) \
68 (((im)->i_f_psampf)((im), (l), (r), (y), (samps), (chans), (count)))
69
70 #ifndef IMAGER_DIRECT_IMAGE_CALLS
71 #define IMAGER_DIRECT_IMAGE_CALLS 1
72 #endif
73
74 #if IMAGER_DIRECT_IMAGE_CALLS
75
76 #define i_ppix(im, x, y, val) (((im)->i_f_ppix)((im), (x), (y), (val)))
77 #define i_gpix(im, x, y, val) (((im)->i_f_gpix)((im), (x), (y), (val)))
78 #define i_ppixf(im, x, y, val) (((im)->i_f_ppixf)((im), (x), (y), (val)))
79 #define i_gpixf(im, x, y, val) (((im)->i_f_gpixf)((im), (x), (y), (val)))
80 #define i_plin(im, l, r, y, val) (((im)->i_f_plin)(im, l, r, y, val))
81 #define i_glin(im, l, r, y, val) (((im)->i_f_glin)(im, l, r, y, val))
82 #define i_plinf(im, l, r, y, val) (((im)->i_f_plinf)(im, l, r, y, val))
83 #define i_glinf(im, l, r, y, val) (((im)->i_f_glinf)(im, l, r, y, val))
84
85 #define i_gsamp(im, l, r, y, samps, chans, count) \
86 (((im)->i_f_gsamp)((im), (l), (r), (y), (samps), (chans), (count)))
87 #define i_gsampf(im, l, r, y, samps, chans, count) \
88 (((im)->i_f_gsampf)((im), (l), (r), (y), (samps), (chans), (count)))
89
90 #endif
91
92 #define i_gsamp_bits(im, l, r, y, samps, chans, count, bits) \
93 (((im)->i_f_gsamp_bits) ? ((im)->i_f_gsamp_bits)((im), (l), (r), (y), (samps), (chans), (count), (bits)) : -1)
94 #define i_psamp_bits(im, l, r, y, samps, chans, count, bits) \
95 (((im)->i_f_psamp_bits) ? ((im)->i_f_psamp_bits)((im), (l), (r), (y), (samps), (chans), (count), (bits)) : -1)
96
97 #define i_findcolor(im, color, entry) \
98 (((im)->i_f_findcolor) ? ((im)->i_f_findcolor)((im), (color), (entry)) : 0)
99
100 #define i_gpal(im, l, r, y, vals) \
101 (((im)->i_f_gpal) ? ((im)->i_f_gpal)((im), (l), (r), (y), (vals)) : 0)
102 #define i_ppal(im, l, r, y, vals) \
103 (((im)->i_f_ppal) ? ((im)->i_f_ppal)((im), (l), (r), (y), (vals)) : 0)
104 #define i_addcolors(im, colors, count) \
105 (((im)->i_f_addcolors) ? ((im)->i_f_addcolors)((im), (colors), (count)) : -1)
106 #define i_getcolors(im, index, color, count) \
107 (((im)->i_f_getcolors) ? \
108 ((im)->i_f_getcolors)((im), (index), (color), (count)) : 0)
109 #define i_setcolors(im, index, color, count) \
110 (((im)->i_f_setcolors) ? \
111 ((im)->i_f_setcolors)((im), (index), (color), (count)) : 0)
112 #define i_colorcount(im) \
113 (((im)->i_f_colorcount) ? ((im)->i_f_colorcount)(im) : -1)
114 #define i_maxcolors(im) \
115 (((im)->i_f_maxcolors) ? ((im)->i_f_maxcolors)(im) : -1)
116 #define i_findcolor(im, color, entry) \
117 (((im)->i_f_findcolor) ? ((im)->i_f_findcolor)((im), (color), (entry)) : 0)
118
119 #define i_img_virtual(im) ((im)->isvirtual)
120 #define i_img_type(im) ((im)->type)
121 #define i_img_bits(im) ((im)->bits)
122
123 #define pIMCTX im_context_t my_im_ctx
124
125 #ifdef IMAGER_NO_CONTEXT
126 #define dIMCTXctx(ctx) pIMCTX = (ctx)
127 #define dIMCTX dIMCTXctx(im_get_context())
128 #define dIMCTXim(im) dIMCTXctx((im)->context)
129 #define dIMCTXio(io) dIMCTXctx((io)->context)
130 #define aIMCTX my_im_ctx
131 #else
132 #define aIMCTX im_get_context()
133 #endif
134
135 #define i_img_8_new(xsize, ysize, channels) im_img_8_new(aIMCTX, (xsize), (ysize), (channels))
136 #define i_img_16_new(xsize, ysize, channels) im_img_16_new(aIMCTX, (xsize), (ysize), (channels))
137 #define i_img_double_new(xsize, ysize, channels) im_img_double_new(aIMCTX, (xsize), (ysize), (channels))
138 #define i_img_pal_new(xsize, ysize, channels, maxpal) im_img_pal_new(aIMCTX, (xsize), (ysize), (channels), (maxpal))
139
140 #define i_img_alloc() im_img_alloc(aIMCTX)
141 #define i_img_init(im) im_img_init(aIMCTX, im)
142
143 #define i_set_image_file_limits(width, height, bytes) im_set_image_file_limits(aIMCTX, width, height, bytes)
144 #define i_get_image_file_limits(width, height, bytes) im_get_image_file_limits(aIMCTX, width, height, bytes)
145 #define i_int_check_image_file_limits(width, height, channels, sample_size) im_int_check_image_file_limits(aIMCTX, width, height, channels, sample_size)
146
147 #define i_clear_error() im_clear_error(aIMCTX)
148 #define i_push_errorvf(code, fmt, args) im_push_errorvf(aIMCTX, code, fmt, args)
149 #define i_push_error(code, msg) im_push_error(aIMCTX, code, msg)
150 #define i_errors() im_errors(aIMCTX)
151
152 #define io_new_fd(fd) im_io_new_fd(aIMCTX, (fd))
153 #define io_new_bufchain() im_io_new_bufchain(aIMCTX)
154 #define io_new_buffer(data, len, closecb, closectx) im_io_new_buffer(aIMCTX, (data), (len), (closecb), (closectx))
155 #define io_new_cb(p, readcb, writecb, seekcb, closecb, destroycb) \
156 im_io_new_cb(aIMCTX, (p), (readcb), (writecb), (seekcb), (closecb), (destroycb))
157
158 #ifdef __cplusplus
159 }
160 #endif
161
162 #endif