Commit f1f556e3 authored by Mathias Wein's avatar Mathias Wein

Add isLinear() query function to KoColorProfile

Returns true if a color profile has only linear transfer response curves.
This implies that that it has transfer response curves.

Hint: The abstract class IccColorProfile::Profile doesn't really seem
to server any really purpose anymore (if it ever did), so I didn't touch
its interface. It might be time to remove it and use non-virtual functions.
parent 9dbde0d0
......@@ -156,6 +156,10 @@ public:
* @return if the profile has a TRC(required for linearisation).
*/
virtual bool hasTRC() const = 0;
/**
* @return if the profile's TRCs are linear.
*/
virtual bool isLinear() const = 0;
/**
* Linearizes first 3 values of QVector, leaving other values unchanged.
* Returns the same QVector if it is not possible to linearize.
......
......@@ -79,6 +79,10 @@ bool KoDummyColorProfile::hasTRC() const
{
return true;
}
bool KoDummyColorProfile::isLinear() const
{
return true;
}
QVector<double> KoDummyColorProfile::getColorantsXYZ() const
{
QVector<double> d50Dummy(3);
......
......@@ -39,6 +39,7 @@ public:
bool supportsRelative() const override;
bool hasColorants() const override;
bool hasTRC() const override;
bool isLinear() const override;
QVector <double> getColorantsXYZ() const override;
QVector <double> getColorantsxyY() const override;
QVector <double> getWhitePointXYZ() const override;
......
......@@ -199,6 +199,12 @@ bool IccColorProfile::hasTRC() const
return d->shared->lcmsProfile->hasTRC();
return false;
}
bool IccColorProfile::isLinear() const
{
if (d->shared->lcmsProfile)
return d->shared->lcmsProfile->isLinear();
return false;
}
QVector <qreal> IccColorProfile::getColorantsXYZ() const
{
if (d->shared->lcmsProfile) {
......
......@@ -103,6 +103,7 @@ public:
bool supportsRelative() const override;
bool hasColorants() const override;
bool hasTRC() const override;
bool isLinear() const override;
QVector <qreal> getColorantsXYZ() const override;
QVector <qreal> getColorantsxyY() const override;
QVector <qreal> getWhitePointXYZ() const override;
......
......@@ -50,6 +50,7 @@ public:
bool suitableForOutput {false};
bool hasColorants;
bool hasTRC;
bool isLinear {false};
bool adaptedFromD50;
cmsCIEXYZ mediaWhitePoint;
cmsCIExyY whitePoint;
......@@ -215,11 +216,15 @@ bool LcmsColorProfileContainer::init()
if (d->greenTRC) d->greenTRCReverse = cmsReverseToneCurve(d->greenTRC);
if (d->blueTRC) d->blueTRCReverse = cmsReverseToneCurve(d->blueTRC);
d->hasTRC = (d->redTRC && d->greenTRC && d->blueTRC && d->redTRCReverse && d->greenTRCReverse && d->blueTRCReverse);
if (d->hasTRC) d->isLinear = cmsIsToneCurveLinear(d->redTRC)
&& cmsIsToneCurveLinear(d->greenTRC)
&& cmsIsToneCurveLinear(d->blueTRC);
} else if (cmsIsTag(d->profile, cmsSigGrayTRCTag)) {
d->grayTRC = ((cmsToneCurve *)cmsReadTag (d->profile, cmsSigGrayTRCTag));
if (d->grayTRC) d->grayTRCReverse = cmsReverseToneCurve(d->grayTRC);
d->hasTRC = (d->grayTRC && d->grayTRCReverse);
if (d->hasTRC) d->isLinear = cmsIsToneCurveLinear(d->grayTRC);
} else {
d->hasTRC = false;
}
......@@ -320,6 +325,10 @@ bool LcmsColorProfileContainer::hasTRC() const
{
return d->hasTRC;
}
bool LcmsColorProfileContainer::isLinear() const
{
return d->isLinear;
}
QVector <double> LcmsColorProfileContainer::getColorantsXYZ() const
{
QVector <double> colorants(9);
......
......@@ -92,6 +92,7 @@ public:
bool hasColorants() const override;
virtual bool hasTRC() const;
bool isLinear() const;
QVector <double> getColorantsXYZ() const override;
QVector <double> getColorantsxyY() const override;
QVector <double> getWhitePointXYZ() const override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment