File indexing completed on 2024-05-12 15:59:34

0001 /*
0002  *  SPDX-FileCopyrightText: 2008 Cyrille Berger <cberger@cberger.net>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #ifndef _KO_COLOR_SPACE_ENGINE_H_
0008 #define _KO_COLOR_SPACE_ENGINE_H_
0009 
0010 #include <KoColorConversionTransformationAbstractFactory.h>
0011 #include <KoGenericRegistry.h>
0012 #include <KoColorProfileConstants.h>
0013 
0014 class KoColorProfile;
0015 
0016 /**
0017  * A KoColorSpaceEngine is a class use to create color conversion
0018  * transformation between color spaces, for which all profiles can
0019  * output to all profiles.
0020  *
0021  * Typically, when you have an ICC color space and color profile, you
0022  * can convert to any other ICC color space and color profile. While
0023  * creating a KoColorTransformationFactory for each of this transformation
0024  * is possible, the number of links will make the Color Conversion explode
0025  * System. KoColorSpaceEngine provides a virtual node in the Color
0026  * Conversion System that can convert to any other node supported by the
0027  * engine.
0028  */
0029 class KRITAPIGMENT_EXPORT KoColorSpaceEngine : public KoColorConversionTransformationAbstractFactory
0030 {
0031 public:
0032     KoColorSpaceEngine(const QString& id, const QString& name);
0033     ~KoColorSpaceEngine() override;
0034     const QString& id() const;
0035     const QString& name() const;
0036     virtual const KoColorProfile* addProfile(const QString &filename) = 0;
0037     virtual const KoColorProfile* addProfile(const QByteArray &data) = 0;
0038     /**
0039      * @brief getProfile
0040      * This tries to generate a profile with the given characteristics and add it to the registry.
0041      * @param colorants a double of xy (for xyY) values, this expects the first two as the white point,
0042      * then the red, green and blue. Will only be used if primaries is unspecified.
0043      * If there's only a whitepoint, a grayscale profile will be returned.
0044      * @param colorPrimaries the color primaries type as defined in KoColorProfile.
0045      * @param transferFunction the transfer function, as defined in KoColorProfile.
0046      * @return a profile that matches these characteristics.
0047      */
0048     virtual const KoColorProfile* getProfile(const QVector<double> &colorants, ColorPrimaries colorPrimaries, TransferCharacteristics transferFunction) = 0;
0049     virtual void removeProfile(const QString &filename) = 0;
0050 
0051     /**
0052      * \return true if the color space can be converted via this engine
0053      */
0054     virtual bool supportsColorSpace(const QString& colorModelId, const QString& colorDepthId, const KoColorProfile *profile) const;
0055 
0056 private:
0057     struct Private;
0058     Private* const d;
0059 };
0060 
0061 class KRITAPIGMENT_EXPORT KoColorSpaceEngineRegistry : public KoGenericRegistry< KoColorSpaceEngine* >
0062 {
0063 public:
0064     KoColorSpaceEngineRegistry();
0065     ~KoColorSpaceEngineRegistry() override;
0066     static KoColorSpaceEngineRegistry* instance();
0067 };
0068 
0069 #endif