File indexing completed on 2024-05-12 15:59:03
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef sRGBProfileCheck_H 0008 #define sRGBProfileCheck_H 0009 0010 #include "KisExportCheckRegistry.h" 0011 #include <KoID.h> 0012 #include <klocalizedstring.h> 0013 #include <kis_image.h> 0014 #include <KoColorSpace.h> 0015 #include <KoColorProfile.h> 0016 0017 /** 0018 * Check whether the image is sRGB, so the loss of the profile is not a problem 0019 */ 0020 class sRGBProfileCheck : public KisExportCheckBase 0021 { 0022 public: 0023 0024 sRGBProfileCheck(const QString &id, Level level, const QString &customWarning = QString()) 0025 : KisExportCheckBase(id, level, customWarning) 0026 { 0027 if (customWarning.isEmpty()) { 0028 m_warning = i18nc("image conversion warning", "The image is not tagged as <b>non-linear gamma sRGB</b>. The image will be converted to sRGB."); 0029 } 0030 } 0031 0032 bool checkNeeded(KisImageSP image) const override 0033 { 0034 bool sRGB = image->colorSpace()->profile()->name().contains(QLatin1String("srgb"), Qt::CaseInsensitive); 0035 0036 // XXX: add an isLinear function to KoColorProfile that uses the information already available through lcms 0037 bool linear = image->colorSpace()->profile()->name().contains(QLatin1String("g10"), Qt::CaseInsensitive); 0038 0039 return (!sRGB || linear); 0040 } 0041 0042 Level check(KisImageSP /*image*/) const override 0043 { 0044 return m_level; 0045 } 0046 0047 }; 0048 0049 class sRGBProfileCheckFactory : public KisExportCheckFactory 0050 { 0051 public: 0052 0053 sRGBProfileCheckFactory() 0054 { 0055 } 0056 0057 ~sRGBProfileCheckFactory() override {} 0058 0059 KisExportCheckBase *create(KisExportCheckBase::Level level, const QString &customWarning) override 0060 { 0061 return new sRGBProfileCheck(id(), level, customWarning); 0062 } 0063 0064 QString id() const override { 0065 return "sRGBProfileCheck"; 0066 } 0067 }; 0068 0069 #endif // sRGBProfileCheck_H