Warning, file /office/calligra/libs/pigment/KoBgrColorSpaceTraits.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_BGR_COLORSPACE_TRAITS_H_
0021 #define _KO_BGR_COLORSPACE_TRAITS_H_
0022 
0023 /** 
0024  * Base class for bgr traits, it provides some convenient functions to
0025  * access BGR channels through an explicit API.
0026  */
0027 template<typename _channels_type_>
0028 struct KoBgrTraits : public KoColorSpaceTrait<_channels_type_, 4, 3> {
0029     typedef _channels_type_ channels_type;
0030     typedef KoColorSpaceTrait<_channels_type_, 4, 3> parent;
0031     static const qint32 red_pos = 2;
0032     static const qint32 green_pos = 1;
0033     static const qint32 blue_pos = 0;
0034     /**
0035      * An BGR pixel
0036      */
0037     struct Pixel {
0038         channels_type blue;
0039         channels_type green;
0040         channels_type red;
0041         channels_type alpha;
0042     };
0043 
0044     /// @return the red component
0045     inline static channels_type red(quint8* data) {
0046         channels_type* d = parent::nativeArray(data);
0047         return d[red_pos];
0048     }
0049     /// Set the red component
0050     inline static void setRed(quint8* data, channels_type nv) {
0051         channels_type* d = parent::nativeArray(data);
0052         d[red_pos] = nv;
0053     }
0054     /// @return the green component
0055     inline static channels_type green(quint8* data) {
0056         channels_type* d = parent::nativeArray(data);
0057         return d[green_pos];
0058     }
0059     /// Set the green component
0060     inline static void setGreen(quint8* data, channels_type nv) {
0061         channels_type* d = parent::nativeArray(data);
0062         d[green_pos] = nv;
0063     }
0064     /// @return the blue component
0065     inline static channels_type blue(quint8* data) {
0066         channels_type* d = parent::nativeArray(data);
0067         return d[blue_pos];
0068     }
0069     /// Set the blue component
0070     inline static void setBlue(quint8* data, channels_type nv) {
0071         channels_type* d = parent::nativeArray(data);
0072         d[blue_pos] = nv;
0073     }
0074 };
0075 
0076 
0077 struct KoBgrU8Traits : public KoBgrTraits<quint8> {
0078 };
0079 
0080 struct KoBgrU16Traits : public KoBgrTraits<quint16> {
0081 };
0082 
0083 struct KoBgrU32Traits : public KoBgrTraits<quint32> {
0084 };
0085 
0086 #include <KoConfig.h>
0087 #ifdef HAVE_OPENEXR
0088 #include <half.h>
0089 
0090 struct KoBgrF16Traits : public KoBgrTraits<half> {
0091 };
0092 
0093 #endif
0094 
0095 struct KoBgrF32Traits : public KoBgrTraits<float> {
0096 };
0097 
0098 struct KoBgrF64Traits : public KoBgrTraits<double> {
0099 };
0100 
0101 
0102 #endif