summaryrefslogtreecommitdiff
path: root/MagickCore/gem-private.h
diff options
context:
space:
mode:
Diffstat (limited to 'MagickCore/gem-private.h')
-rw-r--r--MagickCore/gem-private.h127
1 files changed, 125 insertions, 2 deletions
diff --git a/MagickCore/gem-private.h b/MagickCore/gem-private.h
index 68439caa7..0396b37d1 100644
--- a/MagickCore/gem-private.h
+++ b/MagickCore/gem-private.h
@@ -1,5 +1,5 @@
/*
- Copyright 1999-2020 ImageMagick Studio LLC, a non-profit organization
+ Copyright 1999-2021 ImageMagick Studio LLC, a non-profit organization
dedicated to making software imaging solutions freely available.
You may not use this file except in compliance with the License. You may
@@ -76,6 +76,50 @@ extern MagickPrivate void
ConvertRGBToLCHuv(const double,const double,const double,double *,double *,
double *);
+static inline void ConvertAdobe98ToXYZ(const double red,const double green,
+ const double blue,double *X,double *Y,double *Z)
+{
+ double
+ b,
+ g,
+ r;
+
+ /*
+ Convert Adobe '98 to XYZ colorspace.
+ */
+ assert(X != (double *) NULL);
+ assert(Y != (double *) NULL);
+ assert(Z != (double *) NULL);
+ r=QuantumScale*DecodePixelGamma(red);
+ g=QuantumScale*DecodePixelGamma(green);
+ b=QuantumScale*DecodePixelGamma(blue);
+ *X=0.57666904291013050*r+0.18555823790654630*g+0.18822864623499470*b;
+ *Y=0.29734497525053605*r+0.62736356625546610*g+0.07529145849399788*b;
+ *Z=0.02703136138641234*r+0.07068885253582723*g+0.99133753683763880*b;
+}
+
+static inline void ConvertDisplayP3ToXYZ(const double red,const double green,
+ const double blue,double *X,double *Y,double *Z)
+{
+ double
+ b,
+ g,
+ r;
+
+ /*
+ Convert Display P3 to XYZ colorspace.
+ */
+ assert(X != (double *) NULL);
+ assert(Y != (double *) NULL);
+ assert(Z != (double *) NULL);
+ r=QuantumScale*DecodePixelGamma(red);
+ g=QuantumScale*DecodePixelGamma(green);
+ b=QuantumScale*DecodePixelGamma(blue);
+ *X=0.4865709486482162*r+0.26566769316909306*g+0.1982172852343625*b;
+ *Y=0.2289745640697488*r+0.69173852183650640*g+0.0792869140937450*b;
+ *Z=0.0000000000000000*r+0.04511338185890264*g+1.0439443689009760*b;
+}
+
static inline void ConvertLabToXYZ(const double L,const double a,const double b,
double *X,double *Y,double *Z)
{
@@ -94,7 +138,7 @@ static inline void ConvertLabToXYZ(const double L,const double a,const double b,
x=(x*x*x);
else
x=(116.0*x-16.0)/CIEK;
- if ((y*y*y) > CIEEpsilon)
+ if (L > (CIEK*CIEEpsilon))
y=(y*y*y);
else
y=L/CIEK;
@@ -128,6 +172,28 @@ static inline void ConvertLuvToXYZ(const double L,const double u,const double v,
5.0*(*Y);
}
+static inline void ConvertProPhotoToXYZ(const double red,const double green,
+ const double blue,double *X,double *Y,double *Z)
+{
+ double
+ b,
+ g,
+ r;
+
+ /*
+ Convert ProPhoto to XYZ colorspace.
+ */
+ assert(X != (double *) NULL);
+ assert(Y != (double *) NULL);
+ assert(Z != (double *) NULL);
+ r=QuantumScale*DecodePixelGamma(red);
+ g=QuantumScale*DecodePixelGamma(green);
+ b=QuantumScale*DecodePixelGamma(blue);
+ *X=0.7977604896723027*r+0.13518583717574031*g+0.03134934958152480000*b;
+ *Y=0.2880711282292934*r+0.71184321781010140*g+0.00008565396060525902*b;
+ *Z=0.0000000000000000*r+0.00000000000000000*g+0.82510460251046010000*b;
+}
+
static inline void ConvertRGBToXYZ(const double red,const double green,
const double blue,double *X,double *Y,double *Z)
{
@@ -150,6 +216,44 @@ static inline void ConvertRGBToXYZ(const double red,const double green,
*Z=0.0193339*r+0.1191920*g+0.9503041*b;
}
+static inline void ConvertXYZToAdobe98(const double X,const double Y,
+ const double Z,double *red,double *green,double *blue)
+{
+ double
+ b,
+ g,
+ r;
+
+ assert(red != (double *) NULL);
+ assert(green != (double *) NULL);
+ assert(blue != (double *) NULL);
+ r=2.041587903810746500*X-0.56500697427885960*Y-0.34473135077832956*Z;
+ g=(-0.969243636280879500)*X+1.87596750150772020*Y+0.04155505740717557*Z;
+ b=0.013444280632031142*X-0.11836239223101838*Y+1.01517499439120540*Z;
+ *red=EncodePixelGamma(QuantumRange*r);
+ *green=EncodePixelGamma(QuantumRange*g);
+ *blue=EncodePixelGamma(QuantumRange*b);
+}
+
+static inline void ConvertXYZToDisplayP3(const double X,const double Y,
+ const double Z,double *red,double *green,double *blue)
+{
+ double
+ b,
+ g,
+ r;
+
+ assert(red != (double *) NULL);
+ assert(green != (double *) NULL);
+ assert(blue != (double *) NULL);
+ r=2.49349691194142500*X-0.93138361791912390*Y-0.402710784450716840*Z;
+ g=(-0.82948896956157470)*X+1.76266406031834630*Y+0.023624685841943577*Z;
+ b=0.03584583024378447*X-0.07617238926804182*Y+0.956884524007687200*Z;
+ *red=EncodePixelGamma(QuantumRange*r);
+ *green=EncodePixelGamma(QuantumRange*g);
+ *blue=EncodePixelGamma(QuantumRange*b);
+}
+
static inline void ConvertXYZToLab(const double X,const double Y,const double Z,
double *L,double *a,double *b)
{
@@ -199,6 +303,25 @@ static inline void ConvertXYZToLuv(const double X,const double Y,const double Z,
*v=(*v+140.0)/262.0;
}
+static inline void ConvertXYZToProPhoto(const double X,const double Y,
+ const double Z,double *red,double *green,double *blue)
+{
+ double
+ b,
+ g,
+ r;
+
+ assert(red != (double *) NULL);
+ assert(green != (double *) NULL);
+ assert(blue != (double *) NULL);
+ r=1.3457989731028281*X-0.25558010007997534*Y-0.05110628506753401*Z;
+ g=(-0.5446224939028347)*X+1.50823274131327810*Y+0.02053603239147973*Z;
+ b=0.0000000000000000*X+0.0000000000000000*Y+1.21196754563894540*Z;
+ *red=EncodePixelGamma(QuantumRange*r);
+ *green=EncodePixelGamma(QuantumRange*g);
+ *blue=EncodePixelGamma(QuantumRange*b);
+}
+
static inline void ConvertXYZToRGB(const double X,const double Y,const double Z,
double *red,double *green,double *blue)
{