diff options
| author | 2018-12-04 20:12:46 +0000 | |
|---|---|---|
| committer | 2018-12-04 20:12:46 +0000 | |
| commit | 37fc6eaaf44b416b142e6b45c62203cc7b8c40ea (patch) | |
| tree | 045f6ed05b15f3f2e181751456ca4bb85e9229bb | |
| parent | 1e1d576b5cda35145eea87b35e989cd2a693b255 (diff) | |
| parent | 1ca52e44ccf2566cd7c33062352a9305d36091e2 (diff) | |
Merge "Add API to ColorSpace to compute chromaticity coordinates from CCT"
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | graphics/java/android/graphics/ColorSpace.java | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index ebf23394bf46..83827ea502fa 100644 --- a/api/current.txt +++ b/api/current.txt @@ -13728,6 +13728,7 @@ package android.graphics { public abstract class ColorSpace { method public static android.graphics.ColorSpace adapt(android.graphics.ColorSpace, float[]); method public static android.graphics.ColorSpace adapt(android.graphics.ColorSpace, float[], android.graphics.ColorSpace.Adaptation); + method public static float[] cctToIlluminantdXyz(int); method public static float[] chromaticAdaptation(android.graphics.ColorSpace.Adaptation, float[], float[]); method public static android.graphics.ColorSpace.Connector connect(android.graphics.ColorSpace, android.graphics.ColorSpace); method public static android.graphics.ColorSpace.Connector connect(android.graphics.ColorSpace, android.graphics.ColorSpace, android.graphics.ColorSpace.RenderIntent); diff --git a/graphics/java/android/graphics/ColorSpace.java b/graphics/java/android/graphics/ColorSpace.java index bf114b969b67..2227cf5ef2e0 100644 --- a/graphics/java/android/graphics/ColorSpace.java +++ b/graphics/java/android/graphics/ColorSpace.java @@ -1779,6 +1779,36 @@ public abstract class ColorSpace { } /** + * <p>Computes the chromaticity coordinates of a CIE series D illuminant + * from the specified correlated color temperature (CCT). The specified CCT + * must be greater than 0. A meaningful CCT range is [4000, 25000].</p> + * + * <p>The transform is computed using the methods referred to in Kang et + * al., <i>Design of Advanced Color - Temperature Control System for HDTV + * Applications</i>, Journal of Korean Physical Society 41, 865-871 + * (2002).</p> + * + * @param cct The correlated color temperature, in Kelvin + * @return Corresponding XYZ values + * @throws IllegalArgumentException If cct is invalid + */ + @NonNull + @Size(3) + public static float[] cctToIlluminantdXyz(@IntRange(from = 1) int cct) { + if (cct < 1) { + throw new IllegalArgumentException("Temperature must be greater than 0"); + } + + final float icct = 1.0f / cct; + final float icct2 = icct * icct; + final float x = cct <= 7000.0f ? + 0.244063f + 0.09911e3f * icct + 2.9678e6f * icct2 - 4.6070e9f * icct2 * icct : + 0.237040f + 0.24748e3f * icct + 1.9018e6f * icct2 - 2.0064e9f * icct2 * icct; + final float y = -3.0f * x * x + 2.87f * x - 0.275f; + return xyYToXyz(new float[] {x, y}); + } + + /** * <p>Computes the chromatic adaptation transform from the specified * source white point to the specified destination white point.</p> * |