beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / poppler / GfxState_helpers.h
blobbc0024edd791283761cd130023ac9d6d6d991aac
1 //========================================================================
2 //
3 // GfxState.cc
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
9 //========================================================================
11 // Modified under the Poppler project - http://poppler.freedesktop.org
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
16 // Copyright (C) 2009, 2011 Albert Astals Cid <aacid@kde.org>
18 // To see a description of the changes please see the Changelog file that
19 // came with your tarball or type make ChangeLog if you are building from git
21 //========================================================================
23 #include "GfxState.h"
25 static inline GfxColorComp clip01(GfxColorComp x) {
26 return (x < 0) ? 0 : (x > gfxColorComp1) ? gfxColorComp1 : x;
29 static inline double clip01(double x) {
30 return (x < 0) ? 0 : (x > 1) ? 1 : x;
33 static inline void cmykToRGBMatrixMultiplication(const double &c, const double &m, const double &y, const double &k, const double &c1, const double &m1, const double &y1, const double &k1, double &r, double &g, double &b)
35 double x;
36 // this is a matrix multiplication, unrolled for performance
37 // C M Y K
38 x = c1 * m1 * y1 * k1; // 0 0 0 0
39 r = g = b = x;
40 x = c1 * m1 * y1 * k; // 0 0 0 1
41 r += 0.1373 * x;
42 g += 0.1216 * x;
43 b += 0.1255 * x;
44 x = c1 * m1 * y * k1; // 0 0 1 0
45 r += x;
46 g += 0.9490 * x;
47 x = c1 * m1 * y * k; // 0 0 1 1
48 r += 0.1098 * x;
49 g += 0.1020 * x;
50 x = c1 * m * y1 * k1; // 0 1 0 0
51 r += 0.9255 * x;
52 b += 0.5490 * x;
53 x = c1 * m * y1 * k; // 0 1 0 1
54 r += 0.1412 * x;
55 x = c1 * m * y * k1; // 0 1 1 0
56 r += 0.9294 * x;
57 g += 0.1098 * x;
58 b += 0.1412 * x;
59 x = c1 * m * y * k; // 0 1 1 1
60 r += 0.1333 * x;
61 x = c * m1 * y1 * k1; // 1 0 0 0
62 g += 0.6784 * x;
63 b += 0.9373 * x;
64 x = c * m1 * y1 * k; // 1 0 0 1
65 g += 0.0588 * x;
66 b += 0.1412 * x;
67 x = c * m1 * y * k1; // 1 0 1 0
68 g += 0.6510 * x;
69 b += 0.3137 * x;
70 x = c * m1 * y * k; // 1 0 1 1
71 g += 0.0745 * x;
72 x = c * m * y1 * k1; // 1 1 0 0
73 r += 0.1804 * x;
74 g += 0.1922 * x;
75 b += 0.5725 * x;
76 x = c * m * y1 * k; // 1 1 0 1
77 b += 0.0078 * x;
78 x = c * m * y * k1; // 1 1 1 0
79 r += 0.2118 * x;
80 g += 0.2119 * x;
81 b += 0.2235 * x;