@@ -75,7 +75,8 @@ class KoLcmsColorProofingConversionTransformation : public KoColorProofingConver
75
75
Intent proofingIntent,
76
76
ConversionFlags conversionFlags,
77
77
quint8 *gamutWarning,
78
- double adaptationState
78
+ double adaptationState,
79
+ ConversionFlags displayConversionFlags
79
80
)
80
81
: KoColorProofingConversionTransformation(srcCs, dstCs, proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning, adaptationState)
81
82
, m_transform(0 )
@@ -84,14 +85,10 @@ class KoLcmsColorProofingConversionTransformation : public KoColorProofingConver
84
85
Q_ASSERT (dstCs);
85
86
Q_ASSERT (renderingIntent < 4 );
86
87
87
- if (srcCs-> colorDepthId () == Integer8BitsColorDepthID
88
- || srcCs-> colorDepthId () == Integer16BitsColorDepthID ) {
88
+ if ((srcProfile-> isLinear () || dstProfile-> isLinear ()) &&
89
+ !conversionFlags. testFlag (KoColorConversionTransformation::NoOptimization) ) {
89
90
90
- if ((srcProfile->name ().contains (QLatin1String (" linear" ), Qt::CaseInsensitive) ||
91
- dstProfile->name ().contains (QLatin1String (" linear" ), Qt::CaseInsensitive)) &&
92
- !conversionFlags.testFlag (KoColorConversionTransformation::NoOptimization)) {
93
- conversionFlags |= KoColorConversionTransformation::NoOptimization;
94
- }
91
+ conversionFlags |= KoColorConversionTransformation::NoOptimization;
95
92
}
96
93
conversionFlags |= KoColorConversionTransformation::CopyAlpha;
97
94
@@ -100,18 +97,37 @@ class KoLcmsColorProofingConversionTransformation : public KoColorProofingConver
100
97
alarm[1 ] = (cmsUInt16Number)gamutWarning[1 ]*256 ;
101
98
alarm[2 ] = (cmsUInt16Number)gamutWarning[0 ]*256 ;
102
99
cmsSetAlarmCodes (alarm);
103
- cmsSetAdaptationState (adaptationState);
100
+
104
101
105
102
KIS_ASSERT (dynamic_cast <const IccColorProfile *>(proofingSpace->profile ()));
106
- m_transform = cmsCreateProofingTransform (srcProfile->lcmsProfile (),
107
- srcColorSpaceType,
108
- dstProfile->lcmsProfile (),
109
- dstColorSpaceType,
110
- dynamic_cast <const IccColorProfile *>(proofingSpace->profile ())->asLcms ()->lcmsProfile (),
111
- renderingIntent,
112
- proofingIntent,
113
- conversionFlags);
114
- cmsSetAdaptationState (1 );
103
+
104
+ if (displayConversionFlags.testFlag (KoColorConversionTransformation::BlackpointCompensation)) {
105
+ // This more or less does the same thing as cmsCreateProofingTransform in LCMS' cmsxform.c file,
106
+ // except we try to enable blackpoint compentation on the second bcp too.
107
+ cmsHPROFILE proof = dynamic_cast <const IccColorProfile *>(proofingSpace->profile ())->asLcms ()->lcmsProfile ();
108
+ cmsHPROFILE profiles[] = {srcProfile->lcmsProfile (),
109
+ proof,
110
+ proof,
111
+ dstProfile->lcmsProfile ()};
112
+ bool doBCP1 = conversionFlags.testFlag (KoColorConversionTransformation::BlackpointCompensation);
113
+ bool doBCP2 = true ; // displayConversionFlags.testFlag(KoColorConversionTransformation::BlackpointCompensation);
114
+ cmsBool bcp[] = {doBCP1, doBCP1, doBCP2, doBCP2};
115
+ cmsUInt32Number intents[] = {renderingIntent, renderingIntent, INTENT_RELATIVE_COLORIMETRIC, proofingIntent};
116
+ cmsFloat64Number adaptation[] = {adaptationState, adaptationState, adaptationState, adaptationState};
117
+ m_transform = cmsCreateExtendedTransform (cmsGetProfileContextID (srcProfile->lcmsProfile ()), 4 , profiles, bcp, intents, adaptation, proof, 1 , srcColorSpaceType, dstColorSpaceType, conversionFlags);
118
+ } else {
119
+ cmsSetAdaptationState (adaptationState);
120
+ m_transform = cmsCreateProofingTransform (srcProfile->lcmsProfile (),
121
+ srcColorSpaceType,
122
+ dstProfile->lcmsProfile (),
123
+ dstColorSpaceType,
124
+ dynamic_cast <const IccColorProfile *>(proofingSpace->profile ())->asLcms ()->lcmsProfile (),
125
+ renderingIntent,
126
+ proofingIntent,
127
+ conversionFlags);
128
+ cmsSetAdaptationState (1 );
129
+ }
130
+
115
131
116
132
Q_ASSERT (m_transform);
117
133
}
@@ -266,7 +282,8 @@ KoColorProofingConversionTransformation *IccColorSpaceEngine::createColorProofin
266
282
KoColorConversionTransformation::Intent proofingIntent,
267
283
KoColorConversionTransformation::ConversionFlags conversionFlags,
268
284
quint8 *gamutWarning,
269
- double adaptationState) const
285
+ double adaptationState,
286
+ KoColorConversionTransformation::ConversionFlags displayConversionFlags) const
270
287
{
271
288
KIS_ASSERT (srcColorSpace);
272
289
KIS_ASSERT (dstColorSpace);
@@ -277,7 +294,7 @@ KoColorProofingConversionTransformation *IccColorSpaceEngine::createColorProofin
277
294
srcColorSpace, computeColorSpaceType (srcColorSpace),
278
295
dynamic_cast <const IccColorProfile *>(srcColorSpace->profile ())->asLcms (), dstColorSpace, computeColorSpaceType (dstColorSpace),
279
296
dynamic_cast <const IccColorProfile *>(dstColorSpace->profile ())->asLcms (), proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning,
280
- adaptationState
297
+ adaptationState, displayConversionFlags
281
298
);
282
299
}
283
300
0 commit comments