Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37fc6eaa authored by Daniel Solomon's avatar Daniel Solomon Committed by Android (Google) Code Review
Browse files

Merge "Add API to ColorSpace to compute chromaticity coordinates from CCT"

parents 1e1d576b 1ca52e44
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -13728,6 +13728,7 @@ package android.graphics {
  public abstract class ColorSpace {
  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[]);
    method public static android.graphics.ColorSpace adapt(android.graphics.ColorSpace, float[], android.graphics.ColorSpace.Adaptation);
    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 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);
    method public static android.graphics.ColorSpace.Connector connect(android.graphics.ColorSpace, android.graphics.ColorSpace, android.graphics.ColorSpace.RenderIntent);
    method public static android.graphics.ColorSpace.Connector connect(android.graphics.ColorSpace, android.graphics.ColorSpace, android.graphics.ColorSpace.RenderIntent);
+30 −0
Original line number Original line Diff line number Diff line
@@ -1778,6 +1778,36 @@ public abstract class ColorSpace {
        return mul3x3(inverse3x3(matrix), mul3x3Diag(LMS, matrix));
        return mul3x3(inverse3x3(matrix), mul3x3Diag(LMS, matrix));
    }
    }


    /**
     * <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
     * <p>Computes the chromatic adaptation transform from the specified
     * source white point to the specified destination white point.</p>
     * source white point to the specified destination white point.</p>