Warning, file /office/calligra/libs/pigment/KoScaleColorConversionTransformation.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 modify 0005 * it under the terms of the GNU Lesser General Public License as published by 0006 * the Free Software Foundation; either version 2.1 of the License, or 0007 * (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 0012 * GNU 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 program; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #ifndef _KO_SCALE_COLOR_CONVERSION_TRANSFORMATION_H_ 0020 #define _KO_SCALE_COLOR_CONVERSION_TRANSFORMATION_H_ 0021 0022 #include <KoColorConversionTransformation.h> 0023 #include <KoColorConversionTransformationFactory.h> 0024 /** 0025 * This transformation allows to convert between two color spaces with the same 0026 * color model but different channel type. 0027 */ 0028 template<typename _src_CSTraits_, typename _dst_CSTraits_> 0029 class KoScaleColorConversionTransformation : public KoColorConversionTransformation 0030 { 0031 public: 0032 KoScaleColorConversionTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs) : KoColorConversionTransformation(srcCs, dstCs) { 0033 Q_ASSERT(srcCs->colorModelId() == dstCs->colorModelId()); 0034 } 0035 virtual void transform(const quint8 *srcU8, quint8 *dstU8, qint32 nPixels) const { 0036 const typename _src_CSTraits_::channels_type* src = _src_CSTraits_::nativeArray(srcU8); 0037 typename _dst_CSTraits_::channels_type* dst = _dst_CSTraits_::nativeArray(dstU8); 0038 for (quint32 i = 0; i < _src_CSTraits_::channels_nb * nPixels; i++) { 0039 dst[i] = KoColorSpaceMaths<typename _src_CSTraits_::channels_type, typename _dst_CSTraits_::channels_type>::scaleToA(src[i]); 0040 } 0041 } 0042 }; 0043 0044 /** 0045 * Factory to create KoScaleColorConversionTransformation. 0046 */ 0047 template<typename _src_CSTraits_, typename _dst_CSTraits_> 0048 class KoScaleColorConversionTransformationFactory : public KoColorConversionTransformationFactory 0049 { 0050 public: 0051 KoScaleColorConversionTransformationFactory(const QString& _colorModelId, const QString& _profileName, const QString& _srcDepthId, const QString& _dstDepthId) 0052 : KoColorConversionTransformationFactory(_colorModelId, _srcDepthId, _profileName, _colorModelId, _dstDepthId, _profileName), 0053 hdr(((srcColorDepthId() == Float16BitsColorDepthID.id()) && 0054 (dstColorDepthId() == Float32BitsColorDepthID.id())) || 0055 ((srcColorDepthId() == Float32BitsColorDepthID.id()) && 0056 (dstColorDepthId() == Float16BitsColorDepthID.id()))) { 0057 } 0058 virtual KoColorConversionTransformation* createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent()) const { 0059 Q_UNUSED(renderingIntent); 0060 Q_ASSERT(canBeSource(srcColorSpace)); 0061 Q_ASSERT(canBeDestination(dstColorSpace)); 0062 return new KoScaleColorConversionTransformation<_src_CSTraits_, _dst_CSTraits_>(srcColorSpace, dstColorSpace); 0063 } 0064 virtual bool conserveColorInformation() const { 0065 return true; 0066 } 0067 virtual bool conserveDynamicRange() const { 0068 return hdr; 0069 } 0070 private: 0071 bool hdr; 0072 }; 0073 0074 #endif