]> git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/SplashTypes.h
Load cups into easysw/current.
[thirdparty/cups.git] / pdftops / SplashTypes.h
1 //========================================================================
2 //
3 // SplashTypes.h
4 //
5 //========================================================================
6
7 #ifndef SPLASHTYPES_H
8 #define SPLASHTYPES_H
9
10 #include <config.h>
11 #include "gtypes.h"
12
13 //------------------------------------------------------------------------
14 // coordinates
15 //------------------------------------------------------------------------
16
17 #if USE_FIXEDPOINT
18 #include "FixedPoint.h"
19 typedef FixedPoint SplashCoord;
20 #else
21 typedef double SplashCoord;
22 #endif
23
24 //------------------------------------------------------------------------
25 // colors
26 //------------------------------------------------------------------------
27
28 enum SplashColorMode {
29 splashModeMono1, // 1 bit per component, 8 pixels per byte,
30 // MSbit is on the left
31 splashModeMono8, // 1 byte per component, 1 byte per pixel
32 splashModeAMono8, // 1 byte per component, 2 bytes per pixel:
33 // AMAM...
34 splashModeRGB8, // 1 byte per component, 3 bytes per pixel:
35 // RGBRGB...
36 splashModeBGR8, // 1 byte per component, 3 bytes per pixel:
37 // BGRBGR...
38 splashModeARGB8, // 1 byte per component, 4 bytes per pixel:
39 // ARGBARGB...
40 splashModeBGRA8 // 1 byte per component, 4 bytes per pixel:
41 // BGRABGRA...
42 #if SPLASH_CMYK
43 ,
44 splashModeCMYK8, // 1 byte per component, 4 bytes per pixel:
45 // CMYKCMYK...
46 splashModeACMYK8 // 1 byte per component, 5 bytes per pixel:
47 // ACMYKACMYK
48 #endif
49 };
50
51 // number of components in each color mode
52 // (defined in SplashState.cc)
53 extern int splashColorModeNComps[];
54
55 // max number of components in any SplashColor
56 #if SPLASH_CMYK
57 # define splashMaxColorComps 5
58 #else
59 # define splashMaxColorComps 4
60 #endif
61
62 typedef Guchar SplashColor[splashMaxColorComps];
63 typedef Guchar *SplashColorPtr;
64
65 // AMono8
66 static inline Guchar splashAMono8A(SplashColorPtr am8) { return am8[0]; }
67 static inline Guchar splashAMono8M(SplashColorPtr am8) { return am8[1]; }
68
69 // RGB8
70 static inline Guchar splashRGB8R(SplashColorPtr rgb8) { return rgb8[0]; }
71 static inline Guchar splashRGB8G(SplashColorPtr rgb8) { return rgb8[1]; }
72 static inline Guchar splashRGB8B(SplashColorPtr rgb8) { return rgb8[2]; }
73
74 // BGR8
75 static inline Guchar splashBGR8R(SplashColorPtr bgr8) { return bgr8[2]; }
76 static inline Guchar splashBGR8G(SplashColorPtr bgr8) { return bgr8[1]; }
77 static inline Guchar splashBGR8B(SplashColorPtr bgr8) { return bgr8[0]; }
78
79 // ARGB8
80 static inline Guchar splashARGB8A(SplashColorPtr argb8) { return argb8[0]; }
81 static inline Guchar splashARGB8R(SplashColorPtr argb8) { return argb8[1]; }
82 static inline Guchar splashARGB8G(SplashColorPtr argb8) { return argb8[2]; }
83 static inline Guchar splashARGB8B(SplashColorPtr argb8) { return argb8[3]; }
84
85 // ARGB8
86 static inline Guchar splashBGRA8A(SplashColorPtr bgra8) { return bgra8[3]; }
87 static inline Guchar splashBGRA8R(SplashColorPtr bgra8) { return bgra8[2]; }
88 static inline Guchar splashBGRA8G(SplashColorPtr bgra8) { return bgra8[1]; }
89 static inline Guchar splashBGRA8B(SplashColorPtr bgra8) { return bgra8[0]; }
90
91 #if SPLASH_CMYK
92 // CMYK8
93 static inline Guchar splashCMYK8C(SplashColorPtr cmyk8) { return cmyk8[0]; }
94 static inline Guchar splashCMYK8M(SplashColorPtr cmyk8) { return cmyk8[1]; }
95 static inline Guchar splashCMYK8Y(SplashColorPtr cmyk8) { return cmyk8[2]; }
96 static inline Guchar splashCMYK8K(SplashColorPtr cmyk8) { return cmyk8[3]; }
97
98 // ACMYK8
99 static inline Guchar splashACMYK8A(SplashColorPtr acmyk8) { return acmyk8[0]; }
100 static inline Guchar splashACMYK8C(SplashColorPtr acmyk8) { return acmyk8[1]; }
101 static inline Guchar splashACMYK8M(SplashColorPtr acmyk8) { return acmyk8[2]; }
102 static inline Guchar splashACMYK8Y(SplashColorPtr acmyk8) { return acmyk8[3]; }
103 static inline Guchar splashACMYK8K(SplashColorPtr acmyk8) { return acmyk8[4]; }
104 #endif
105
106 static inline void splashColorCopy(SplashColorPtr dest, SplashColorPtr src) {
107 dest[0] = src[0];
108 dest[1] = src[1];
109 dest[2] = src[2];
110 dest[3] = src[3];
111 #if SPLASH_CMYK
112 dest[4] = src[4];
113 #endif
114 }
115
116 static inline void splashColorXor(SplashColorPtr dest, SplashColorPtr src) {
117 dest[0] ^= src[0];
118 dest[1] ^= src[1];
119 dest[2] ^= src[2];
120 dest[3] ^= src[3];
121 #if SPLASH_CMYK
122 dest[4] ^= src[4];
123 #endif
124 }
125
126 //------------------------------------------------------------------------
127 // blend functions
128 //------------------------------------------------------------------------
129
130 typedef void (*SplashBlendFunc)(SplashColorPtr src, SplashColorPtr dest,
131 SplashColorPtr blend, SplashColorMode cm);
132
133 //------------------------------------------------------------------------
134 // error results
135 //------------------------------------------------------------------------
136
137 typedef int SplashError;
138
139 #endif