Warning, file /office/calligra/libs/pigment/KoYcbcrColorSpaceTraits.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_YCbCr_COLORSPACE_TRAITS_H_ 0021 #define _KO_YCbCr_COLORSPACE_TRAITS_H_ 0022 0023 /** 0024 * YCbCr traits, it provides some convenient functions to 0025 * access YCbCr channels through an explicit API. 0026 */ 0027 template<typename _channels_type_> 0028 struct KoYCbCrTraits : public KoColorSpaceTrait<_channels_type_, 4, 3> { 0029 0030 typedef _channels_type_ channels_type; 0031 typedef KoColorSpaceTrait<_channels_type_, 4, 3> parent; 0032 0033 static const qint32 Y_pos = 0; 0034 static const qint32 Cb_pos = 1; 0035 static const qint32 Cr_pos = 2; 0036 0037 /** 0038 * An YCbCr pixel 0039 */ 0040 struct Pixel { 0041 channels_type Y; 0042 channels_type Cb; 0043 channels_type Cr; 0044 channels_type alpha; 0045 }; 0046 0047 /// @return the Y component 0048 inline static channels_type Y(quint8* data) { 0049 channels_type* d = parent::nativeArray(data); 0050 return d[Y_pos]; 0051 } 0052 /// Set the Y component 0053 inline static void setY(quint8* data, channels_type nv) { 0054 channels_type* d = parent::nativeArray(data); 0055 d[Y_pos] = nv; 0056 } 0057 /// @return the Cb component 0058 inline static channels_type Cb(quint8* data) { 0059 channels_type* d = parent::nativeArray(data); 0060 return d[Cb_pos]; 0061 } 0062 /// Set the Cb component 0063 inline static void setCb(quint8* data, channels_type nv) { 0064 channels_type* d = parent::nativeArray(data); 0065 d[Cb_pos] = nv; 0066 } 0067 /// @return the Cr component 0068 inline static channels_type Cr(quint8* data) { 0069 channels_type* d = parent::nativeArray(data); 0070 return d[Cr_pos]; 0071 } 0072 /// Set the Cr component 0073 inline static void setCr(quint8* data, channels_type nv) { 0074 channels_type* d = parent::nativeArray(data); 0075 d[Cr_pos] = nv; 0076 } 0077 }; 0078 0079 struct KoYCbCrU8Traits : public KoYCbCrTraits<quint8> { 0080 }; 0081 0082 struct KoYCbCrU16Traits : public KoYCbCrTraits<quint16> { 0083 }; 0084 0085 #include <KoConfig.h> 0086 #ifdef HAVE_OPENEXR 0087 #include <half.h> 0088 0089 struct KoYCbCrF16Traits : public KoYCbCrTraits<half> { 0090 }; 0091 0092 #endif 0093 0094 struct KoYCbCrF32Traits : public KoYCbCrTraits<float> { 0095 }; 0096 0097 struct KoYCbCrF64Traits : public KoYCbCrTraits<double> { 0098 }; 0099 0100 0101 #endif