Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-10 10:23:47

0001 //========================================================================
0002 //
0003 // GfxState.cc
0004 //
0005 // Copyright 1996-2003 Glyph & Cog, LLC
0006 //
0007 //========================================================================
0008 
0009 //========================================================================
0010 //
0011 // Modified under the Poppler project - http://poppler.freedesktop.org
0012 //
0013 // All changes made under the Poppler project to this file are licensed
0014 // under GPL version 2 or later
0015 //
0016 // Copyright (C) 2009, 2011, 2018, 2019 Albert Astals Cid <aacid@kde.org>
0017 // Copyright (C) 2019 Oliver Sander <oliver.sander@tu-dresden.de>
0018 //
0019 // To see a description of the changes please see the Changelog file that
0020 // came with your tarball or type make ChangeLog if you are building from git
0021 //
0022 //========================================================================
0023 
0024 #ifndef GFXSTATE_HELPERS_H
0025 #define GFXSTATE_HELPERS_H
0026 
0027 #include "GfxState.h"
0028 
0029 static inline GfxColorComp clip01(GfxColorComp x)
0030 {
0031     return (x < 0) ? 0 : (x > gfxColorComp1) ? gfxColorComp1 : x;
0032 }
0033 
0034 static inline double clip01(double x)
0035 {
0036     return (x < 0) ? 0 : (x > 1) ? 1 : x;
0037 }
0038 
0039 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)
0040 {
0041     double x;
0042     // this is a matrix multiplication, unrolled for performance
0043     //                        C M Y K
0044     x = c1 * m1 * y1 * k1; // 0 0 0 0
0045     r = g = b = x;
0046     x = c1 * m1 * y1 * k; // 0 0 0 1
0047     r += 0.1373 * x;
0048     g += 0.1216 * x;
0049     b += 0.1255 * x;
0050     x = c1 * m1 * y * k1; // 0 0 1 0
0051     r += x;
0052     g += 0.9490 * x;
0053     x = c1 * m1 * y * k; // 0 0 1 1
0054     r += 0.1098 * x;
0055     g += 0.1020 * x;
0056     x = c1 * m * y1 * k1; // 0 1 0 0
0057     r += 0.9255 * x;
0058     b += 0.5490 * x;
0059     x = c1 * m * y1 * k; // 0 1 0 1
0060     r += 0.1412 * x;
0061     x = c1 * m * y * k1; // 0 1 1 0
0062     r += 0.9294 * x;
0063     g += 0.1098 * x;
0064     b += 0.1412 * x;
0065     x = c1 * m * y * k; // 0 1 1 1
0066     r += 0.1333 * x;
0067     x = c * m1 * y1 * k1; // 1 0 0 0
0068     g += 0.6784 * x;
0069     b += 0.9373 * x;
0070     x = c * m1 * y1 * k; // 1 0 0 1
0071     g += 0.0588 * x;
0072     b += 0.1412 * x;
0073     x = c * m1 * y * k1; // 1 0 1 0
0074     g += 0.6510 * x;
0075     b += 0.3137 * x;
0076     x = c * m1 * y * k; // 1 0 1 1
0077     g += 0.0745 * x;
0078     x = c * m * y1 * k1; // 1 1 0 0
0079     r += 0.1804 * x;
0080     g += 0.1922 * x;
0081     b += 0.5725 * x;
0082     x = c * m * y1 * k; // 1 1 0 1
0083     b += 0.0078 * x;
0084     x = c * m * y * k1; // 1 1 1 0
0085     r += 0.2118 * x;
0086     g += 0.2119 * x;
0087     b += 0.2235 * x;
0088 }
0089 
0090 #endif