File indexing completed on 2024-12-22 04:11:38
0001 /* 0002 * SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org> 0003 * SPDX-FileCopyrightText: 2005-2006 C. Boemann <cbo@boemann.dk> 0004 * SPDX-FileCopyrightText: 2004, 2006-2007 Cyrille Berger <cberger@cberger.net> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.1-or-later 0007 */ 0008 0009 #ifndef KOSIMPLECOLORSPACEFACTORY_H_ 0010 #define KOSIMPLECOLORSPACEFACTORY_H_ 0011 0012 #include "KoColorConversionTransformationFactory.h" 0013 #include <colorprofiles/KoDummyColorProfile.h> 0014 0015 #include <KoColorModelStandardIds.h> 0016 0017 class KoSimpleColorSpaceFactory : public KoColorSpaceFactory 0018 { 0019 0020 public: 0021 0022 KoSimpleColorSpaceFactory(const QString& id, 0023 const QString& name, 0024 bool userVisible, 0025 const KoID& colorModelId, 0026 const KoID& colorDepthId, 0027 int referenceDepth = -1, 0028 int crossingCost = 1) 0029 : m_id(id) 0030 , m_name(name) 0031 , m_userVisible(userVisible) 0032 , m_colorModelId(colorModelId) 0033 , m_colorDepthId(colorDepthId) 0034 , m_referenceDepth(referenceDepth) 0035 , m_crossingCost(crossingCost) 0036 { 0037 if (m_referenceDepth >= 0) { 0038 // noop, already initialized! 0039 } else if (colorDepthId == Integer8BitsColorDepthID) { 0040 m_referenceDepth = 1 * 8; 0041 } else if (colorDepthId == Integer16BitsColorDepthID) { 0042 m_referenceDepth = 2 * 8; 0043 } else if (colorDepthId == Float16BitsColorDepthID) { 0044 m_referenceDepth = 2 * 8; 0045 } else if (colorDepthId == Float32BitsColorDepthID) { 0046 m_referenceDepth = 4 * 8; 0047 } else if (colorDepthId == Float64BitsColorDepthID) { 0048 m_referenceDepth = 8 * 8; 0049 } 0050 } 0051 0052 0053 QString id() const override { 0054 return m_id; 0055 } 0056 0057 QString name() const override { 0058 return m_name; 0059 } 0060 0061 bool userVisible() const override { 0062 return m_userVisible; 0063 } 0064 0065 KoID colorModelId() const override { 0066 return m_colorModelId; 0067 } 0068 0069 KoID colorDepthId() const override { 0070 return m_colorDepthId; 0071 } 0072 0073 bool profileIsCompatible(const KoColorProfile* profile) const override { 0074 return dynamic_cast<const KoDummyColorProfile*>(profile); 0075 } 0076 0077 QString colorSpaceEngine() const override { 0078 return "simple"; 0079 } 0080 0081 bool isHdr() const override { 0082 return false; 0083 } 0084 0085 int referenceDepth() const override { 0086 return m_referenceDepth; 0087 } 0088 0089 int crossingCost() const override { 0090 return m_crossingCost; 0091 } 0092 0093 QList<KoColorConversionTransformationFactory*> colorConversionLinks() const override { 0094 return QList<KoColorConversionTransformationFactory*>(); 0095 } 0096 0097 QString defaultProfile() const override { 0098 return QString("default"); 0099 } 0100 protected: 0101 KoColorProfile* createColorProfile(const QByteArray& /*rawData*/) const override { 0102 return 0; 0103 } 0104 private: 0105 0106 QString m_id; 0107 QString m_name; 0108 bool m_userVisible; 0109 KoID m_colorModelId; 0110 KoID m_colorDepthId; 0111 int m_referenceDepth; 0112 int m_crossingCost; 0113 0114 }; 0115 0116 #endif