Code

moving trunk for module inkscape
[inkscape.git] / src / libnr / nr-pixops.h
1 #ifndef __NR_PIXOPS_H__
2 #define __NR_PIXOPS_H__
4 /*
5  * Pixel buffer rendering library
6  *
7  * Authors:
8  *   Lauris Kaplinski <lauris@kaplinski.com>
9  *   bulia byak <buliabyak@users.sf.net>
10  *
11  * This code is in public domain
12  */
14 #define NR_RGBA32_R(v) (unsigned char) (((v) >> 24) & 0xff)
15 #define NR_RGBA32_G(v) (unsigned char) (((v) >> 16) & 0xff)
16 #define NR_RGBA32_B(v) (unsigned char) (((v) >> 8) & 0xff)
17 #define NR_RGBA32_A(v) (unsigned char) ((v) & 0xff)
19 #define FAST_DIVIDE_BY_255(v) ((((v) << 8) + (v) + 257) >> 16)
20 #define NR_PREMUL(c,a) (FAST_DIVIDE_BY_255(((c) * (a) + 127)))
21 #define NR_PREMUL_SINGLE(c) (FAST_DIVIDE_BY_255((c) + 127))
22 #define NR_A7(fa,ba) (65025 - (255 - fa) * (255 - ba))
23 #define NR_A7_NORMALIZED(fa,ba) (FAST_DIVIDE_BY_255((65025 - (255 - (fa)) * (255 - (ba))) + 127))
24 #define NR_COMPOSENNN_A7(fc,fa,bc,ba,a) (((255 - (fa)) * (bc) * (ba) + (fa) * (fc) * 255 + 127) / a)
25 #define NR_COMPOSEPNN_A7(fc,fa,bc,ba,a) (((255 - (fa)) * (bc) * (ba) + (fc) * 65025 + 127) / a)
26 #define NR_COMPOSENNP(fc,fa,bc,ba) (((255 - (fa)) * (bc) * (ba) + (fa) * (fc) * 255 + 32512) / 65025)
27 #define NR_COMPOSEPNP(fc,fa,bc,ba) (((255 - (fa)) * (bc) * (ba) + (fc) * 65025 + 32512) / 65025)
28 #define NR_COMPOSENPP(fc,fa,bc,ba) (FAST_DIVIDE_BY_255((255 - (fa)) * (bc) + (fa) * (fc) + 127))
29 #define NR_COMPOSEPPP(fc,fa,bc,ba) (FAST_DIVIDE_BY_255((255 - (fa)) * (bc) + (fc) * 255 + 127))
30 #define NR_COMPOSEP11(fc,fa,bc) (FAST_DIVIDE_BY_255((255 - (fa)) * (bc) + (fc) * 255 + 127))
31 #define NR_COMPOSEN11(fc,fa,bc) (FAST_DIVIDE_BY_255((255 - (fa)) * (bc) + (fc) * (fa) + 127))
33 #define INK_COMPOSE(f,a,b) ( ( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) ((b ^ ~f) + b/4 - (b>127? 63 : 0))) * ((guchar) a) ) >>8)
35 #endif
37 /*
38   Local Variables:
39   mode:c++
40   c-file-style:"stroustrup"
41   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
42   indent-tabs-mode:nil
43   fill-column:99
44   End:
45 */
46 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :