10#include <klocalizedstring.h>
62 void transform(
const quint8 *src, quint8 *dst, qint32 numPixels)
const override
66 cmsDoTransform(
m_transform,
const_cast<quint8 *
>(src), dst, numPixels);
81 bool bpcFirstTransform,
83 ConversionFlags displayConversionFlags
92 bool doBPC1 = bpcFirstTransform;
106 quint16 alarm[cmsMAXCHANNELS];
107 alarm[0] = (cmsUInt16Number)gamutWarning[2]*256;
108 alarm[1] = (cmsUInt16Number)gamutWarning[1]*256;
109 alarm[2] = (cmsUInt16Number)gamutWarning[0]*256;
110 cmsSetAlarmCodes(alarm);
117 cmsHPROFILE profiles[] = {srcProfile->
lcmsProfile(),
121 cmsBool bpc[] = {doBPC1, doBPC1, doBPC2, doBPC2};
124 cmsFloat64Number adaptation[] = {adaptationState, adaptationState, adaptationState, adaptationState};
125 m_transform = cmsCreateExtendedTransform(cmsGetProfileContextID(srcProfile->
lcmsProfile()), 4, profiles, bpc, intents, adaptation, proof, 1, srcColorSpaceType, dstColorSpaceType, displayConversionFlags);
137 void transform(
const quint8 *src, quint8 *dst, qint32 numPixels)
const override
141 cmsDoTransform(
m_transform,
const_cast<quint8 *
>(src), dst, numPixels);
165 Q_CHECK_PTR(profile);
172 if (!profile->
valid()) {
173 cmsHPROFILE cmsp = cmsOpenProfileFromFile(filename.toLatin1(),
"r");
179 if (profile->
valid()) {
196 Q_CHECK_PTR(profile);
198 if (profile->
valid()) {
229 Q_CHECK_PTR(profile);
231 if (profile->
valid()) {
248 Q_CHECK_PTR(profile);
259 KoColorConversionTransformation::ConversionFlags conversionFlags)
const
277 bool firstTransformBPC,
278 quint8 *gamutWarning,
279 KoColorConversionTransformation::ConversionFlags displayConversionFlags)
const
289 dynamic_cast<const IccColorProfile *
>(dstColorSpace->
profile())->
asLcms(), proofingSpace, renderingIntent, proofingIntent, firstTransformBPC, gamutWarning,
290 displayConversionFlags
299 return lcmsInfo->colorSpaceType();
307 depthType = BYTES_SH(1);
309 depthType = BYTES_SH(2);
311 depthType = BYTES_SH(2) | FLOAT_SH(1);
313 depthType = BYTES_SH(4) | FLOAT_SH(1);
315 depthType = BYTES_SH(0) | FLOAT_SH(1);
317 qWarning() <<
"Unknown bit depth";
321 quint32 modelType = 0;
324 if (depthId.startsWith(QLatin1Char(
'U'))) {
325 modelType = (COLORSPACE_SH(PT_RGB) | EXTRA_SH(1) | CHANNELS_SH(3) | DOSWAP_SH(1) | SWAPFIRST_SH(1));
326 }
else if (depthId.startsWith(QLatin1Char(
'F'))) {
327 modelType = (COLORSPACE_SH(PT_RGB) | EXTRA_SH(1) | CHANNELS_SH(3));
330 modelType = (COLORSPACE_SH(PT_XYZ) | EXTRA_SH(1) | CHANNELS_SH(3));
332 modelType = (COLORSPACE_SH(PT_Lab) | EXTRA_SH(1) | CHANNELS_SH(3));
334 modelType = (COLORSPACE_SH(PT_CMYK) | EXTRA_SH(1) | CHANNELS_SH(4));
336 modelType = (COLORSPACE_SH(PT_GRAY) | EXTRA_SH(1) | CHANNELS_SH(1));
338 modelType = (COLORSPACE_SH(PT_GRAY) | CHANNELS_SH(1));
340 modelType = (COLORSPACE_SH(PT_YCbCr) | EXTRA_SH(1) | CHANNELS_SH(3));
342 qWarning() <<
"Cannot convert colorspace to lcms modeltype";
345 return depthType | modelType;
351 Q_UNUSED(colorDepthId);
355 profile->
name() !=
"High Dynamic Range UHDTV Wide Color Gamut Display (Rec. 2020) - SMPTE ST 2084 PQ EOTF");
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID YCbCrAColorModelID("YCbCrA", ki18n("YCbCr/Alpha"))
const KoID Float64BitsColorDepthID("F64", ki18n("64-bit float/channel"))
const KoID GrayAColorModelID("GRAYA", ki18n("Grayscale/Alpha"))
const KoID XYZAColorModelID("XYZA", ki18n("XYZ/Alpha"))
const KoID Float16BitsColorDepthID("F16", ki18n("16-bit float/channel"))
const KoID Integer8BitsColorDepthID("U8", ki18n("8-bit integer/channel"))
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
const KoID CMYKAColorModelID("CMYKA", ki18n("CMYK/Alpha"))
const KoID LABAColorModelID("LABA", ki18n("L*a*b*/Alpha"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
const KoID GrayColorModelID("GRAY", ki18n("Grayscale (without transparency)"))
@ PRIMARIES_ITU_R_BT_2020_2_AND_2100_0
@ PRIMARIES_ITU_R_BT_709_5
LcmsColorProfileContainer * asLcms() const
const KoColorProfile * getProfile(const KoColorProfileQuery &query) override
getProfile This tries to generate a profile with the given characteristics and add it to the registry...
~IccColorSpaceEngine() override
KoColorConversionTransformation * createColorTransformation(const KoColorSpace *srcColorSpace, const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const override
void removeProfile(const QString &filename) override
KoColorProofingConversionTransformation * createColorProofingTransformation(const KoColorSpace *srcColorSpace, const KoColorSpace *dstColorSpace, const KoColorSpace *proofingSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::Intent proofingIntent, bool firstTransformBPC, quint8 *gamutWarning, KoColorConversionTransformation::ConversionFlags displayConversionFlags) const override
bool supportsColorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile) const override
quint32 computeColorSpaceType(const KoColorSpace *cs) const
const KoColorProfile * addProfile(const QString &filename) override
virtual KoID colorModelId() const =0
virtual KoID colorDepthId() const =0
virtual const KoColorProfile * profile() const =0
cmsHPROFILE lcmsProfile() const
static IccColorProfile * createFromLcmsProfile(const cmsHPROFILE profile)
#define KIS_SAFE_ASSERT_RECOVER(cond)
#define INTENT_RELATIVE_COLORIMETRIC
The KoColorProfileQuery struct.
TransferCharacteristics transfer
CICP-compatible enum value representing the white point and primaries.
ColorPrimaries primaries
Rgb Primaries of the profile. When empty, this is a query for a greyscale profile.
bool isValid() const
Used for PQ profiles.
virtual bool valid() const =0
virtual TransferCharacteristics getTransferCharacteristics() const
getTransferCharacteristics This function should be subclassed at some point so we can get the value f...
const KoColorProfile * profileByName(const QString &name) const
static KoColorSpaceRegistry * instance()
void removeProfile(KoColorProfile *profile)
void addProfile(KoColorProfile *profile)