Warning, file /office/calligra/libs/pigment/KoGrayColorSpaceTraits.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_GRAY_COLORSPACE_TRAITS_H_ 0021 #define _KO_GRAY_COLORSPACE_TRAITS_H_ 0022 0023 /** 0024 * Base class for graya traits, it provides some convenient functions to 0025 * access gray channels through an explicit API. 0026 */ 0027 template<typename _channels_type_> 0028 struct KoGrayTraits : public KoColorSpaceTrait<_channels_type_, 2, 1> { 0029 0030 typedef _channels_type_ channels_type; 0031 typedef KoColorSpaceTrait<_channels_type_, 2, 1> parent; 0032 0033 static const qint32 gray_pos = 0; 0034 0035 /** 0036 * An grayscale pixel 0037 */ 0038 struct Pixel { 0039 channels_type gray; 0040 channels_type alpha; 0041 }; 0042 0043 /// @return the gray component 0044 inline static channels_type gray(quint8* data) { 0045 channels_type* d = parent::nativeArray(data); 0046 return d[gray_pos]; 0047 } 0048 0049 /// Set the gray component 0050 inline static void setGray(quint8* data, channels_type nv) { 0051 channels_type* d = parent::nativeArray(data); 0052 d[gray_pos] = nv; 0053 } 0054 }; 0055 0056 0057 struct KoGrayU8Traits : public KoGrayTraits<quint8> { 0058 }; 0059 0060 struct KoGrayU16Traits : public KoGrayTraits<quint16> { 0061 }; 0062 0063 struct KoGrayU32Traits : public KoGrayTraits<quint32> { 0064 }; 0065 0066 0067 #include <KoConfig.h> 0068 #ifdef HAVE_OPENEXR 0069 #include <half.h> 0070 0071 struct KoGrayF16Traits : public KoGrayTraits<half> { 0072 }; 0073 0074 #endif 0075 0076 struct KoGrayF32Traits : public KoGrayTraits<float> { 0077 }; 0078 0079 struct KoGrayF64Traits : public KoGrayTraits<double> { 0080 }; 0081 0082 #endif