labFromArgb static method
- int argb
Converts a color from ARGB representation to Lab* representation.
argb
the ARGB representation of a color
Returns a Lab object representing the color
Implementation
static List<double> labFromArgb(int argb) {
final linearR = linearized(redFromArgb(argb));
final linearG = linearized(greenFromArgb(argb));
final linearB = linearized(blueFromArgb(argb));
final matrix = _srgbToXyz;
final x = matrix[0][0] * linearR +
matrix[0][1] * linearG +
matrix[0][2] * linearB;
final y = matrix[1][0] * linearR +
matrix[1][1] * linearG +
matrix[1][2] * linearB;
final z = matrix[2][0] * linearR +
matrix[2][1] * linearG +
matrix[2][2] * linearB;
final whitePoint = _whitePointD65;
final xNormalized = x / whitePoint[0];
final yNormalized = y / whitePoint[1];
final zNormalized = z / whitePoint[2];
final fx = _labF(xNormalized);
final fy = _labF(yNormalized);
final fz = _labF(zNormalized);
final l = 116.0 * fy - 16;
final a = 500.0 * (fx - fy);
final b = 200.0 * (fy - fz);
return [l, a, b];
}