diff options
author | Mattias Andrée <maandree@kth.se> | 2017-06-21 21:23:23 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2017-06-21 21:23:23 +0200 |
commit | 1a7dd13eaac67a0d840da9ce1d39586c2ee9389a (patch) | |
tree | 3d602f5a51aa051ac8e694852cf823259d22e7e0 /conversions.h | |
parent | m (diff) | |
download | libcolour-1a7dd13eaac67a0d840da9ce1d39586c2ee9389a.tar.gz libcolour-1a7dd13eaac67a0d840da9ce1d39586c2ee9389a.tar.bz2 libcolour-1a7dd13eaac67a0d840da9ce1d39586c2ee9389a.tar.xz |
CIEXYZ_TO_CIE1960UCS: set u and v to the limit if conversion results in division by zero
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'conversions.h')
-rw-r--r-- | conversions.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/conversions.h b/conversions.h index 25b3ba7..6a3ad68 100644 --- a/conversions.h +++ b/conversions.h @@ -179,10 +179,16 @@ #define CIEXYZ_TO_CIE1960UCS(FROM_X, FROM_Y, FROM_Z, TO_U, TO_V, TO_Y)\ do {\ - TYPE X__ = (FROM_X), Y__ = (FROM_Y), w__;\ - w__ = X__ + 15 * Y__ + 3 * (FROM_Z);\ - (TO_U) = 4 * X__ / w__;\ - (TO_V) = 6 * Y__ / w__;\ + TYPE X__ = (FROM_X), Y__ = (FROM_Y), u__, v__;\ + v__ = X__ + 15 * Y__ + 3 * (FROM_Z);\ + u__ = 4 * X__ / v__;\ + v__ = 6 * Y__ / v__;\ + if (WASDIV0(u__) || WASDIV0(v__)) {\ + u__ = D(0.19783997438029748971999310924729797989130020141602);\ + v__ = D(0.31222425446887241973215054713364224880933761596680);\ + }\ + (TO_U) = u__;\ + (TO_V) = v__;\ (TO_Y) = Y__;\ } while (0) |