File indexing completed on 2024-05-12 15:59:34
0001 /* 0002 * SPDX-FileCopyrightText: 2005 Boudewijn Rempt <boud@valdyas.org> 0003 * SPDX-FileCopyrightText: 2006-2007 Cyrille Berger <cberger@cberger.net> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.1-or-later 0006 */ 0007 #ifndef KOCOLORSPACEFACTORY_H 0008 #define KOCOLORSPACEFACTORY_H 0009 0010 #include "KoColorSpaceConstants.h" 0011 #include "KoColorConversionTransformation.h" 0012 #include <KoID.h> 0013 #include "kritapigment_export.h" 0014 0015 class KoColorProfile; 0016 class KoColorConversionTransformationFactory; 0017 0018 /** 0019 * This class is used to create color spaces. 0020 */ 0021 class KRITAPIGMENT_EXPORT KoColorSpaceFactory 0022 { 0023 protected: 0024 KoColorSpaceFactory(); 0025 public: 0026 virtual ~KoColorSpaceFactory(); 0027 /** 0028 * Return the unchanging name of this color space 0029 */ 0030 virtual QString id() const = 0; 0031 0032 /** 0033 * return the i18n'able description. 0034 */ 0035 virtual QString name() const = 0; 0036 0037 /** 0038 * @return true if the color space should be shown in a User Interface, or false 0039 * other wise. 0040 */ 0041 virtual bool userVisible() const = 0; 0042 0043 /** 0044 * @return a string that identify the color model (for instance "RGB" or "CMYK" ...) 0045 * @see KoColorModelStandardIds.h 0046 */ 0047 virtual KoID colorModelId() const = 0; 0048 0049 /** 0050 * @return a string that identify the bit depth (for instance "U8" or "F16" ...) 0051 * @see KoColorModelStandardIds.h 0052 */ 0053 virtual KoID colorDepthId() const = 0; 0054 0055 /** 0056 * @param profile a pointer to a color profile 0057 * @return true if the color profile can be used by a color space created by 0058 * this factory 0059 */ 0060 virtual bool profileIsCompatible(const KoColorProfile* profile) const = 0; 0061 0062 /** 0063 * @return the name of the color space engine for this color space, or "" if none 0064 */ 0065 virtual QString colorSpaceEngine() const = 0; 0066 0067 /** 0068 * @return true if the color space supports High-Dynamic Range. 0069 */ 0070 virtual bool isHdr() const = 0; 0071 0072 /** 0073 * @return the reference depth, that is for a color space where all channels have the same 0074 * depth, this is the depth of one channel, for a color space with different bit depth for 0075 * each channel, it's usually the highest bit depth. This value is used by the Color 0076 * Conversion System to check if a lost of bit depth during a color conversion is 0077 * acceptable, for instance when converting from RGB32bit to XYZ16bit, it's acceptable to go 0078 * through a conversion to RGB16bit, while it's not the case for RGB32bit to XYZ32bit. 0079 */ 0080 virtual int referenceDepth() const = 0; 0081 0082 /** 0083 * @return the list of color conversion provided by this colorspace, the factories 0084 * constructed by this functions are owned by the caller of the function 0085 */ 0086 virtual QList<KoColorConversionTransformationFactory*> colorConversionLinks() const = 0; 0087 0088 /** 0089 * @return the cost of the usage of the colorspace in the conversion graph. The higher the cost, 0090 * the less probably the color space will be chosen for the conversion. 0091 */ 0092 virtual int crossingCost() const = 0; 0093 0094 /** 0095 * Returns the default icc profile for use with this colorspace. This may be "" 0096 * 0097 * @return the default icc profile name 0098 */ 0099 virtual QString defaultProfile() const = 0; 0100 0101 struct ProfileRegistrationInterface 0102 { 0103 virtual ~ProfileRegistrationInterface() {} 0104 virtual const KoColorProfile* profileByName(const QString &profileName) const = 0; 0105 virtual void registerNewProfile(KoColorProfile *profile) = 0; 0106 }; 0107 0108 /** 0109 * Create a color profile from a memory array, if possible, otherwise return 0. 0110 * This will replace the existing profile with the name in the KoColorSpaceRegistry 0111 * 0112 * This will call the decendant's createColorProfile() 0113 */ 0114 const KoColorProfile* colorProfile(const QByteArray& rawData, ProfileRegistrationInterface *registrationInterface) const; 0115 0116 /** 0117 * Create or reuse the existing colorspace for the given profile. 0118 * 0119 * This will call the decendant's createColorSpace 0120 */ 0121 const KoColorSpace *grabColorSpace(const KoColorProfile *profile); 0122 0123 protected: 0124 /** 0125 * creates a color space using the given profile. 0126 */ 0127 virtual KoColorSpace *createColorSpace(const KoColorProfile *) const = 0; 0128 virtual KoColorProfile* createColorProfile(const QByteArray& rawData) const = 0; 0129 private: 0130 struct Private; 0131 Private* const d; 0132 }; 0133 0134 #endif // KOCOLORSPACEFACTORY_H