Warning, file /office/calligra/libs/pigment/KoLabColorSpaceTraits.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_LAB_COLORSPACE_TRAITS_H_ 0021 #define _KO_LAB_COLORSPACE_TRAITS_H_ 0022 0023 0024 /** 0025 * LAB traits, it provides some convenient functions to 0026 * access LAB channels through an explicit API. 0027 * 0028 * Use this class in conjonction with KoColorSpace::toLabA16 and 0029 * KoColorSpace::fromLabA16 data. 0030 * 0031 * Example: 0032 * quint8* p = KoLabU16Traits::allocate(1); 0033 * oneKoColorSpace->toLabA16(somepointertodata, p, 1); 0034 * KoLabU16Traits::setL( p, KoLabU16Traits::L(p) / 10 ); 0035 * oneKoColorSpace->fromLabA16(p, somepointertodata, 1); 0036 */ 0037 template<typename _channels_type_> 0038 struct KoLabTraits : public KoColorSpaceTrait<_channels_type_, 4, 3> { 0039 typedef _channels_type_ channels_type; 0040 typedef KoColorSpaceTrait<_channels_type_, 4, 3> parent; 0041 static const qint32 L_pos = 0; 0042 static const qint32 a_pos = 1; 0043 static const qint32 b_pos = 2; 0044 0045 /** 0046 * An Lab pixel 0047 */ 0048 struct Pixel { 0049 channels_type L; 0050 channels_type a; 0051 channels_type b; 0052 channels_type alpha; 0053 }; 0054 0055 /// @return the L component 0056 inline static channels_type L(quint8* data) { 0057 channels_type* d = parent::nativeArray(data); 0058 return d[L_pos]; 0059 } 0060 /// Set the L component 0061 inline static void setL(quint8* data, channels_type nv) { 0062 channels_type* d = parent::nativeArray(data); 0063 d[L_pos] = nv; 0064 } 0065 /// @return the a component 0066 inline static channels_type a(quint8* data) { 0067 channels_type* d = parent::nativeArray(data); 0068 return d[a_pos]; 0069 } 0070 /// Set the a component 0071 inline static void setA(quint8* data, channels_type nv) { 0072 channels_type* d = parent::nativeArray(data); 0073 d[a_pos] = nv; 0074 } 0075 /// @return the b component 0076 inline static channels_type b(quint8* data) { 0077 channels_type* d = parent::nativeArray(data); 0078 return d[b_pos]; 0079 } 0080 /// Set the a component 0081 inline static void setB(quint8* data, channels_type nv) { 0082 channels_type* d = parent::nativeArray(data); 0083 d[b_pos] = nv; 0084 } 0085 }; 0086 0087 0088 struct KoLabU8Traits : public KoLabTraits<quint8> { 0089 }; 0090 0091 struct KoLabU16Traits : public KoLabTraits<quint16> { 0092 }; 0093 0094 #include <KoConfig.h> 0095 #ifdef HAVE_OPENEXR 0096 #include <half.h> 0097 0098 struct KoLabF16Traits : public KoLabTraits<half> { 0099 }; 0100 0101 #endif 0102 0103 struct KoLabF32Traits : public KoLabTraits<float> { 0104 }; 0105 0106 struct KoLabF64Traits : public KoLabTraits<double> { 0107 }; 0108 0109 #endif