Skip to content

Commit

Permalink
Added useful methods and properties
Browse files Browse the repository at this point in the history
  • Loading branch information
fkeglevich committed Jan 27, 2019
1 parent a591111 commit d93a490
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/src/main/java/com/fkeglevich/rawdumper/raw/color/XYCoords.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ public class XYCoords
private final double x;
private final double y;

public static final XYCoords D50 = new XYCoords(0.3457, 0.3585);
public static final XYCoords StA = new XYCoords(0.4476, 0.4074);

public static XYCoords fromXYZ(double[] xyz)
{
double total = xyz[0] + xyz[1] + xyz[2];
if (total > 0)
return new XYCoords(xyz[0] / total, xyz[1] / total);
return D50;
}

public XYCoords(double x, double y)
{
this.x = x;
Expand All @@ -49,4 +60,10 @@ public ColorTemperature toColorTemperature()
{
return Temperature.getColorTemperatureFromXYCoords(this);
}

public double[] toXYZ()
{
double Y = 1;
return new double[] {(x*Y)/y, Y, ((1-x-y)*Y)/y};
}
}

0 comments on commit d93a490

Please sign in to comment.