Warning, file /office/calligra/libs/pigment/KoCmykColorSpaceTraits.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  *  Copyright (c) 2006-2007 Cyrille Berger <cberger@cberger.net>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Lesser General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Lesser General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef _KO_CMYK_COLORSPACE_TRAITS_H_
0021 #define _KO_CMYK_COLORSPACE_TRAITS_H_
0022 
0023 #include <QVector>
0024 
0025 #include "KoColorSpaceConstants.h"
0026 #include "KoColorSpaceMaths.h"
0027 #include "DebugPigment.h"
0028 
0029 
0030 /** 
0031  * Base class for CMYK traits, it provides some convenient functions to
0032  * access CMYK channels through an explicit API.
0033  */
0034 template<typename _channels_type_>
0035 struct KoCmykTraits : public KoColorSpaceTrait<_channels_type_, 5, 4> {
0036     typedef _channels_type_ channels_type;
0037     typedef KoColorSpaceTrait<_channels_type_, 5, 4> parent;
0038 
0039     static const qint32 c_pos = 0;
0040     static const qint32 m_pos = 1;
0041     static const qint32 y_pos = 2;
0042     static const qint32 k_pos = 3;
0043 
0044     /**
0045      * An CMYK pixel
0046      */
0047     struct Pixel {
0048         channels_type cyan;
0049         channels_type magenta;
0050         channels_type yellow;
0051         channels_type black;
0052         channels_type alpha;
0053     };
0054     /// @return the Cyan component
0055     inline static channels_type C(quint8* data) {
0056         channels_type* d = parent::nativeArray(data);
0057         return d[c_pos];
0058     }
0059     /// Set the Cyan component
0060     inline static void setC(quint8* data, channels_type nv) {
0061         channels_type* d = parent::nativeArray(data);
0062         d[c_pos] = nv;
0063     }
0064     /// @return the Magenta component
0065     inline static channels_type M(quint8* data) {
0066         channels_type* d = parent::nativeArray(data);
0067         return d[m_pos];
0068     }
0069     /// Set the Magenta component
0070     inline static void setM(quint8* data, channels_type nv) {
0071         channels_type* d = parent::nativeArray(data);
0072         d[m_pos] = nv;
0073     }
0074     /// @return the Yellow component
0075     inline static channels_type Y(quint8* data) {
0076         channels_type* d = parent::nativeArray(data);
0077         return d[y_pos];
0078     }
0079     /// Set the Yellow component
0080     inline static void setY(quint8* data, channels_type nv) {
0081         channels_type* d = parent::nativeArray(data);
0082         d[y_pos] = nv;
0083     }
0084     /// @return the Key component
0085     inline static channels_type k(quint8* data) {
0086         channels_type* d = parent::nativeArray(data);
0087         return d[k_pos];
0088     }
0089     /// Set the Key component
0090     inline static void setK(quint8* data, channels_type nv) {
0091         channels_type* d = parent::nativeArray(data);
0092         d[k_pos] = nv;
0093     }
0094 };
0095 
0096 struct KoCmykU8Traits : public KoCmykTraits<quint8> {
0097 };
0098 
0099 struct KoCmykU16Traits : public KoCmykTraits<quint16> {
0100 };
0101 
0102 #include <KoConfig.h>
0103 #ifdef HAVE_OPENEXR
0104 #include <half.h>
0105 
0106 struct KoCmykF16Traits : public KoCmykTraits<half> {
0107 };
0108 
0109 #endif
0110 
0111 struct KoCmykF32Traits : public KoCmykTraits<float> {
0112 };
0113 
0114 struct KoCmykF64Traits : public KoCmykTraits<double> {
0115 };
0116 
0117 
0118 
0119 #endif
0120