1//========================================================================
2//
3// GfxState.cc
4//
5// Copyright 1996-2003 Glyph & Cog, LLC
6//
7//========================================================================
8
9//========================================================================
10//
11// Modified under the Poppler project - http://poppler.freedesktop.org
12//
13// All changes made under the Poppler project to this file are licensed
14// under GPL version 2 or later
15//
16// Copyright (C) 2009, 2011, 2018, 2019 Albert Astals Cid <aacid@kde.org>
17// Copyright (C) 2019 Oliver Sander <oliver.sander@tu-dresden.de>
18//
19// To see a description of the changes please see the Changelog file that
20// came with your tarball or type make ChangeLog if you are building from git
21//
22//========================================================================
23
24#ifndef GFXSTATE_HELPERS_H
25#define GFXSTATE_HELPERS_H
26
27#include "GfxState.h"
28
29static inline GfxColorComp clip01(GfxColorComp x)
30{
31 return (x < 0) ? 0 : (x > gfxColorComp1) ? gfxColorComp1 : x;
32}
33
34static inline double clip01(double x)
35{
36 return (x < 0) ? 0 : (x > 1) ? 1 : x;
37}
38
39static 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)
40{
41 double x;
42 // this is a matrix multiplication, unrolled for performance
43 // C M Y K
44 x = c1 * m1 * y1 * k1; // 0 0 0 0
45 r = g = b = x;
46 x = c1 * m1 * y1 * k; // 0 0 0 1
47 r += 0.1373 * x;
48 g += 0.1216 * x;
49 b += 0.1255 * x;
50 x = c1 * m1 * y * k1; // 0 0 1 0
51 r += x;
52 g += 0.9490 * x;
53 x = c1 * m1 * y * k; // 0 0 1 1
54 r += 0.1098 * x;
55 g += 0.1020 * x;
56 x = c1 * m * y1 * k1; // 0 1 0 0
57 r += 0.9255 * x;
58 b += 0.5490 * x;
59 x = c1 * m * y1 * k; // 0 1 0 1
60 r += 0.1412 * x;
61 x = c1 * m * y * k1; // 0 1 1 0
62 r += 0.9294 * x;
63 g += 0.1098 * x;
64 b += 0.1412 * x;
65 x = c1 * m * y * k; // 0 1 1 1
66 r += 0.1333 * x;
67 x = c * m1 * y1 * k1; // 1 0 0 0
68 g += 0.6784 * x;
69 b += 0.9373 * x;
70 x = c * m1 * y1 * k; // 1 0 0 1
71 g += 0.0588 * x;
72 b += 0.1412 * x;
73 x = c * m1 * y * k1; // 1 0 1 0
74 g += 0.6510 * x;
75 b += 0.3137 * x;
76 x = c * m1 * y * k; // 1 0 1 1
77 g += 0.0745 * x;
78 x = c * m * y1 * k1; // 1 1 0 0
79 r += 0.1804 * x;
80 g += 0.1922 * x;
81 b += 0.5725 * x;
82 x = c * m * y1 * k; // 1 1 0 1
83 b += 0.0078 * x;
84 x = c * m * y * k1; // 1 1 1 0
85 r += 0.2118 * x;
86 g += 0.2119 * x;
87 b += 0.2235 * x;
88}
89
90#endif
91

source code of poppler/poppler/GfxState_helpers.h