aboutsummaryrefslogtreecommitdiffstats
path: root/src/convert.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-12-20 23:02:33 +0100
committerMattias Andrée <maandree@kth.se>2016-12-20 23:02:33 +0100
commitc6b8b1185c9f6bbb540d9a3f2c3b04e51da01844 (patch)
tree47afe82ac21bf5a3437232b3ba4c7fd5d09d8b89 /src/convert.c
parentfix errors and add tests (diff)
downloadlibcolour-c6b8b1185c9f6bbb540d9a3f2c3b04e51da01844.tar.gz
libcolour-c6b8b1185c9f6bbb540d9a3f2c3b04e51da01844.tar.bz2
libcolour-c6b8b1185c9f6bbb540d9a3f2c3b04e51da01844.tar.xz
add tests and fix erros + hue should always be positive
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/convert.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/convert.c b/src/convert.c
index a998d66..6d9be16 100644
--- a/src/convert.c
+++ b/src/convert.c
@@ -443,8 +443,8 @@ static void cielab_to_ciexyz(const libcolour_cielab_t* restrict from, libcolour_
to->X = to->Y + a / 500;
to->Z = to->Y - b / 200;
to->X = cielab_finv(to->X) * 0.95047;
- to->Y = cielab_finv(to->Y) * 1.08883;
- to->Z = cielab_finv(to->Z);
+ to->Y = cielab_finv(to->Y);
+ to->Z = cielab_finv(to->Z) * 1.08883;
}
static void cieluv_to_ciexyz(const libcolour_cieluv_t* restrict from, libcolour_ciexyz_t* restrict to)
@@ -604,7 +604,7 @@ static void ciexyz_to_cielab(const libcolour_ciexyz_t* restrict from, libcolour_
{
double X = from->X, Y = from->Y, Z = from->Z;
X /= 0.95047;
- Y /= 1.08883;
+ Z /= 1.08883;
Y = cielab_f(Y);
to->L = 116 * Y - 16;
to->a = 500 * (cielab_f(X) - Y);
@@ -721,6 +721,8 @@ static void cieluv_to_cielchuv(const libcolour_cieluv_t* restrict from, libcolou
to->L = L;
to->C = sqrt(u * u + v * v);
to->h = atan2(v, u) / PI2 * to->one_revolution;
+ if (!isnan(to->h) && !isinf(to->h) && (to->h < 0))
+ to->h += to->one_revolution;
}
static void other_to_cielchuv(const libcolour_colour_t* restrict from, libcolour_cielchuv_t* restrict to)