Warning, file /office/calligra/libs/pigment/KoColorConversionTransformation.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) 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_COLOR_CONVERSION_TRANSFORMATION_H_ 0021 #define _KO_COLOR_CONVERSION_TRANSFORMATION_H_ 0022 0023 #include "KoColorTransformation.h" 0024 0025 #include "pigment_export.h" 0026 0027 class KoColorSpace; 0028 class KoColorConversionCache; 0029 0030 /** 0031 * This is the base class of all color transform that convert the color of a pixel 0032 */ 0033 class PIGMENTCMS_EXPORT KoColorConversionTransformation : public KoColorTransformation 0034 { 0035 friend class KoColorConversionCache; 0036 struct Private; 0037 public: 0038 0039 /** 0040 * Possible value for the intent of a color conversion (useful only for ICC 0041 * transformations) 0042 */ 0043 enum Intent { 0044 IntentPerceptual = 0, 0045 IntentRelativeColorimetric = 1, 0046 IntentSaturation = 2, 0047 IntentAbsoluteColorimetric = 3 0048 }; 0049 0050 /** 0051 * Flags for the color conversion, see lcms2 documentation for more information 0052 */ 0053 enum ConversionFlag { 0054 Empty = 0x0, 0055 NoOptimization = 0x0100, 0056 GamutCheck = 0x1000, // Out of Gamut alarm 0057 SoftProofing = 0x4000, // Do softproofing 0058 BlackpointCompensation = 0x2000, 0059 NoWhiteOnWhiteFixup = 0x0004, // Don't fix scum dot 0060 HighQuality = 0x0400, // Use more memory to give better accuracy 0061 LowQuality = 0x0800 // Use less memory to minimize resources 0062 }; 0063 Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag) 0064 0065 /** 0066 * We have numerous places where we need to convert color spaces. 0067 * 0068 * In several cases the user asks us about the conversion 0069 * explicitly, e.g. when changing the image type or converting 0070 * pixel data to the monitor profile. Doing this explicitly the 0071 * user can choose what rendering intent and conversion flags to 0072 * use. 0073 * 0074 * But there are also cases when we have to do a conversion 0075 * internally (transparently for the user), for example, when 0076 * merging heterogeneous images, creating thumbnails, converting 0077 * data to/from QImage or while doing some adjustments. We cannot 0078 * ask the user about parameters for every single 0079 * conversion. That's why in all these non-critical cases the 0080 * following default values should be used. 0081 */ 0082 0083 static Intent internalRenderingIntent() { return IntentPerceptual; } 0084 static ConversionFlags internalConversionFlags() { return BlackpointCompensation; } 0085 0086 static Intent adjustmentRenderingIntent() { return IntentPerceptual; } 0087 static ConversionFlags adjustmentConversionFlags() { return ConversionFlags(BlackpointCompensation | NoWhiteOnWhiteFixup); } 0088 0089 public: 0090 KoColorConversionTransformation(const KoColorSpace* srcCs, 0091 const KoColorSpace* dstCs, 0092 Intent renderingIntent, 0093 ConversionFlags conversionFlags); 0094 ~KoColorConversionTransformation() override; 0095 public: 0096 0097 /** 0098 * @return the source color space for this transformation. 0099 */ 0100 const KoColorSpace* srcColorSpace() const; 0101 0102 /** 0103 * @return the destination color space for this transformation. 0104 */ 0105 const KoColorSpace* dstColorSpace() const; 0106 0107 /** 0108 * @return the rendering intent of this transformation (this is only useful 0109 * for ICC transformations) 0110 */ 0111 Intent renderingIntent() const; 0112 0113 /** 0114 * @return the conversion flags 0115 */ 0116 ConversionFlags conversionFlags() const; 0117 0118 /** 0119 * perform the color conversion between two buffers. 0120 * @param nPixels the number of pixels in the buffers. 0121 */ 0122 void transform(const quint8 *src, quint8 *dst, qint32 nPixels) const override = 0; 0123 0124 /** 0125 * @return false if the transformation is not valid 0126 */ 0127 bool isValid() const override { return true; } 0128 0129 private: 0130 0131 void setSrcColorSpace(const KoColorSpace*) const; 0132 void setDstColorSpace(const KoColorSpace*) const; 0133 0134 Private * const d; 0135 }; 0136 0137 Q_DECLARE_OPERATORS_FOR_FLAGS(KoColorConversionTransformation::ConversionFlags) 0138 0139 #endif