File indexing completed on 2025-02-23 04:10:58
0001 /* 0002 * SPDX-License-Identifier: GPL-3.0-or-later 0003 */ 0004 0005 #include "TestColorSpaceRegistry.h" 0006 0007 #include <lcms2.h> 0008 0009 #include <KoColorProfile.h> 0010 #include <KoColorSpace.h> 0011 #include <KoColorSpaceRegistry.h> 0012 #include <simpletest.h> 0013 #include <testpigment.h> 0014 0015 0016 void TestColorSpaceRegistry::testConstruction() 0017 { 0018 KoColorSpaceRegistry *instance = KoColorSpaceRegistry::instance(); 0019 Q_ASSERT(instance); 0020 } 0021 0022 void TestColorSpaceRegistry::testRgbU8() 0023 { 0024 const QString colorSpaceId = KoColorSpaceRegistry::instance()->colorSpaceId(RGBAColorModelID, 0025 Integer8BitsColorDepthID); 0026 0027 const KoColorSpace *colorSpace = KoColorSpaceRegistry::instance()->rgb8(); 0028 QVERIFY(colorSpace != 0); 0029 0030 const KoColorProfile *profile = colorSpace->profile(); 0031 QVERIFY(profile != 0); 0032 0033 QCOMPARE(profile->name(), KoColorSpaceRegistry::instance()->defaultProfileForColorSpace(colorSpaceId)); 0034 0035 cmsHPROFILE lcmsProfile = cmsCreate_sRGBProfile(); 0036 QString testProfileName = "TestRGBU8ProfileName"; 0037 0038 cmsWriteTag(lcmsProfile, cmsSigProfileDescriptionTag, testProfileName.toLatin1().constData()); 0039 cmsWriteTag(lcmsProfile, cmsSigDeviceModelDescTag, testProfileName.toLatin1().constData()); 0040 cmsWriteTag(lcmsProfile, cmsSigDeviceMfgDescTag, ""); 0041 0042 } 0043 0044 void TestColorSpaceRegistry::testRgbU16() 0045 { 0046 const QString colorSpaceId = KoColorSpaceRegistry::instance()->colorSpaceId(RGBAColorModelID, 0047 Integer16BitsColorDepthID); 0048 0049 const KoColorSpace *colorSpace = KoColorSpaceRegistry::instance()->rgb16(); 0050 QVERIFY(colorSpace != 0); 0051 0052 const KoColorProfile *profile = colorSpace->profile(); 0053 QVERIFY(profile != 0); 0054 0055 QCOMPARE(profile->name(), KoColorSpaceRegistry::instance()->defaultProfileForColorSpace(colorSpaceId)); 0056 0057 cmsHPROFILE lcmsProfile = cmsCreate_sRGBProfile(); 0058 QString testProfileName = "TestRGBU16ProfileName"; 0059 0060 cmsWriteTag(lcmsProfile, cmsSigProfileDescriptionTag, testProfileName.toLatin1().constData()); 0061 cmsWriteTag(lcmsProfile, cmsSigDeviceModelDescTag, testProfileName.toLatin1().constData()); 0062 cmsWriteTag(lcmsProfile, cmsSigDeviceMfgDescTag, ""); 0063 0064 } 0065 0066 void TestColorSpaceRegistry::testLab() 0067 { 0068 const QString colorSpaceId = KoColorSpaceRegistry::instance()->colorSpaceId(LABAColorModelID, 0069 Integer16BitsColorDepthID); 0070 0071 const KoColorSpace *colorSpace = KoColorSpaceRegistry::instance()->lab16(); 0072 QVERIFY(colorSpace != 0); 0073 0074 const KoColorProfile *profile = colorSpace->profile(); 0075 QVERIFY(profile != 0); 0076 0077 QCOMPARE(profile->name(), KoColorSpaceRegistry::instance()->defaultProfileForColorSpace(colorSpaceId)); 0078 0079 cmsCIExyY whitepoint; 0080 whitepoint.x = 0.33; 0081 whitepoint.y = 0.33; 0082 whitepoint.Y = 1.0; 0083 0084 cmsHPROFILE lcmsProfile = cmsCreateLab4Profile(&whitepoint); 0085 QString testProfileName = "TestLabProfileName"; 0086 0087 cmsWriteTag(lcmsProfile, cmsSigProfileDescriptionTag, testProfileName.toLatin1().constData()); 0088 cmsWriteTag(lcmsProfile, cmsSigDeviceModelDescTag, testProfileName.toLatin1().constData()); 0089 cmsWriteTag(lcmsProfile, cmsSigDeviceMfgDescTag, ""); 0090 0091 } 0092 0093 KISTEST_MAIN(TestColorSpaceRegistry)