1 /* 2 For general Scribus (>=1.3.2) copyright and licensing information please refer 3 to the COPYING file provided with the program. Following this notice may exist 4 a copyright and/or license notice that predates the release of Scribus 1.3.2 5 for which a new license (GPL+exception) is in place. 6 */ 7 8 #ifndef SCLCMS2COLORMGMTENGINEIMPL_H 9 #define SCLCMS2COLORMGMTENGINEIMPL_H 10 11 #include <stdexcept> 12 13 #include "lcms2.h" 14 #include "sccolormgmtenginedata.h" 15 #include "sccolorprofilecache.h" 16 17 class ScLcms2ColorMgmtEngineImpl : public ScColorMgmtEngineData 18 { 19 friend class ScLcms2ColorProfileImpl; 20 friend class ScLcms2ColorTransformImpl; 21 22 public: 23 ScLcms2ColorMgmtEngineImpl(); 24 25 // Setter, only for color management strategy 26 void setStrategy(const ScColorMgmtStrategy& strategy) override; 27 28 // function for getting available profile in a directory 29 QList<ScColorProfileInfo> getAvailableProfileInfo(const QString& directory, bool recursive) override; 30 31 // functions for opening icc profiles 32 ScColorProfile openProfileFromFile(ScColorMgmtEngine& engine, const QString& filePath) override; 33 ScColorProfile openProfileFromMem (ScColorMgmtEngine& engine, const QByteArray& data) override; 34 35 // functions for creating profiles 36 ScColorProfile createProfile_sRGB(ScColorMgmtEngine& engine) override; 37 ScColorProfile createProfile_Lab (ScColorMgmtEngine& engine) override; 38 39 // functions for creating transforms 40 ScColorTransform createTransform(ScColorMgmtEngine& colorManagementEngine, 41 const ScColorProfile& inputProfile , eColorFormat inputFormat, 42 const ScColorProfile& outputProfile, eColorFormat outputFormat, 43 eRenderIntent renderIntent, long transformFlags) override; 44 ScColorTransform createProofingTransform(ScColorMgmtEngine& engine, 45 const ScColorProfile& inputProfile , eColorFormat inputFormat, 46 const ScColorProfile& outputProfile, eColorFormat outputFormat, 47 const ScColorProfile& proofProfile , eRenderIntent renderIntent, 48 eRenderIntent proofingIntent, long transformFlags) override; 49 50 protected: 51 52 // Color profile cache 53 static QSharedPointer<ScColorProfileCache> m_profileCache; 54 55 // Color transform cache 56 static QSharedPointer<ScColorTransformPool> m_transformPool; 57 58 static cmsUInt32Number translateFlagsToLcmsFlags(long flags); 59 static cmsUInt32Number translateFormatToLcmsFormat(eColorFormat format); 60 static int translateIntentToLcmsIntent(eRenderIntent intent, eRenderIntent defIntent = Intent_Relative_Colorimetric); 61 static eColorSpaceType translateLcmsColorSpaceType(cmsColorSpaceSignature); 62 static eProfileClass translateLcmsProfileClass(cmsProfileClassSignature); 63 64 // Exception class thrown by cmsErrorHandler 65 class lcmsException : public std::runtime_error 66 { 67 public : lcmsException(const char * msg)68 lcmsException(const char* msg) : std::runtime_error(msg) {} 69 }; 70 71 /*! 72 \brief Simple error handler for use in conjunction with littlecms 73 \param ErrorCode error code issued by little cms 74 \param ErrorText error message corresponding to the error code 75 */ 76 static void cmsErrorHandler(cmsContext contextID, cmsUInt32Number ErrorCode, const char *ErrorText); 77 }; 78 79 #endif 80