File indexing completed on 2025-01-26 04:11:07
0001 /* 0002 * SPDX-FileCopyrightText: 2007 Cyrille Berger <cberger@cberger.net> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kis_tiff_test.h" 0008 0009 0010 #include <simpletest.h> 0011 #include <QCoreApplication> 0012 0013 #include "filestest.h" 0014 0015 #include <KoColorModelStandardIds.h> 0016 #include <KoColor.h> 0017 0018 #include <KoColorModelStandardIdsUtils.h> 0019 #include <kis_meta_data_backend_registry.h> 0020 #include <testui.h> 0021 0022 #include <config-jpeg.h> 0023 0024 #include <KoConfig.h> 0025 0026 #ifndef FILES_DATA_DIR 0027 #error "FILES_DATA_DIR not set. A directory with the data used for testing the importing of files in krita" 0028 #endif 0029 0030 0031 const QString TiffMimetype = "image/tiff"; 0032 0033 void KisTiffTest::testFiles() 0034 { 0035 KisMetadataBackendRegistry::instance(); 0036 0037 QStringList excludes; 0038 0039 #ifdef HAVE_LCMS2 0040 excludes << "flower-separated-contig-08.tif" 0041 << "flower-separated-contig-16.tif" 0042 << "flower-separated-planar-08.tif" 0043 << "flower-separated-planar-16.tif" 0044 << "flower-minisblack-02.tif" 0045 << "flower-minisblack-04.tif" 0046 << "flower-minisblack-08.tif" 0047 << "flower-minisblack-10.tif" 0048 << "flower-minisblack-12.tif" 0049 << "flower-minisblack-14.tif" 0050 << "flower-minisblack-16.tif" 0051 << "flower-minisblack-24.tif" 0052 << "flower-minisblack-32.tif" 0053 << "jim___dg.tif" 0054 << "jim___gg.tif" 0055 << "strike.tif"; 0056 #endif 0057 0058 #ifndef HAVE_JPEG_TURBO 0059 excludes << "quad-strip-jpeg.tif" 0060 << "quad-tile-jpeg.tif"; 0061 #endif 0062 0063 TestUtil::testFiles(QString(FILES_DATA_DIR) + "/sources", excludes, QString(), 1); 0064 } 0065 0066 void KisTiffTest::testSaveTiffColorSpace(QString colorModel, QString colorDepth, QString colorProfile) 0067 { 0068 const KoColorSpace *space = KoColorSpaceRegistry::instance()->colorSpace(colorModel, colorDepth, colorProfile); 0069 if (space) { 0070 TestUtil::testExportToColorSpace(TiffMimetype, space, ImportExportCodes::OK); 0071 } 0072 } 0073 0074 void KisTiffTest::testSaveTiffRgbaColorSpace() 0075 { 0076 QString profile = "sRGB-elle-V2-srgbtrc"; 0077 testSaveTiffColorSpace(RGBAColorModelID.id(), Integer8BitsColorDepthID.id(), profile); 0078 profile = "sRGB-elle-V2-g10"; 0079 testSaveTiffColorSpace(RGBAColorModelID.id(), Integer16BitsColorDepthID.id(), profile); 0080 testSaveTiffColorSpace(RGBAColorModelID.id(), Float16BitsColorDepthID.id(), profile); 0081 testSaveTiffColorSpace(RGBAColorModelID.id(), Float32BitsColorDepthID.id(), profile); 0082 } 0083 0084 void KisTiffTest::testSaveTiffGreyAColorSpace() 0085 { 0086 QString profile = "Gray-D50-elle-V2-srgbtrc"; 0087 testSaveTiffColorSpace(GrayAColorModelID.id(), Integer8BitsColorDepthID.id(), profile); 0088 profile = "Gray-D50-elle-V2-g10"; 0089 testSaveTiffColorSpace(GrayAColorModelID.id(), Integer16BitsColorDepthID.id(), profile); 0090 testSaveTiffColorSpace(GrayAColorModelID.id(), Float16BitsColorDepthID.id(), profile); 0091 testSaveTiffColorSpace(GrayAColorModelID.id(), Float32BitsColorDepthID.id(), profile); 0092 0093 } 0094 0095 0096 void KisTiffTest::testSaveTiffCmykColorSpace() 0097 { 0098 QString profile = "Chemical proof"; 0099 testSaveTiffColorSpace(CMYKAColorModelID.id(), Integer8BitsColorDepthID.id(), profile); 0100 testSaveTiffColorSpace(CMYKAColorModelID.id(), Integer16BitsColorDepthID.id(), profile); 0101 testSaveTiffColorSpace(CMYKAColorModelID.id(), Float32BitsColorDepthID.id(), profile); 0102 } 0103 0104 void KisTiffTest::testSaveTiffLabColorSpace() 0105 { 0106 const QString profile = "Lab identity build-in"; 0107 testSaveTiffColorSpace(LABAColorModelID.id(), Integer8BitsColorDepthID.id(), profile); 0108 testSaveTiffColorSpace(LABAColorModelID.id(), Integer16BitsColorDepthID.id(), profile); 0109 testSaveTiffColorSpace(LABAColorModelID.id(), Float32BitsColorDepthID.id(), profile); 0110 } 0111 0112 0113 void KisTiffTest::testSaveTiffYCbCrAColorSpace() 0114 { 0115 const QString profile = "ITU-R BT.709-6 + BT.1886 YCbCr ICC V4 profile"; 0116 testSaveTiffColorSpace(YCbCrAColorModelID.id(), Integer8BitsColorDepthID.id(), profile); 0117 testSaveTiffColorSpace(YCbCrAColorModelID.id(), Integer16BitsColorDepthID.id(), profile); 0118 testSaveTiffColorSpace(YCbCrAColorModelID.id(), 0119 Float32BitsColorDepthID.id(), 0120 profile); 0121 } 0122 0123 void KisTiffTest::testImportFromWriteonly() 0124 { 0125 TestUtil::testImportFromWriteonly(TiffMimetype); 0126 } 0127 0128 0129 void KisTiffTest::testExportToReadonly() 0130 { 0131 TestUtil::testExportToReadonly(TiffMimetype); 0132 } 0133 0134 0135 void KisTiffTest::testImportIncorrectFormat() 0136 { 0137 TestUtil::testImportIncorrectFormat(TiffMimetype); 0138 } 0139 0140 0141 0142 KISTEST_MAIN(KisTiffTest) 0143