/// <summary> /// Create a new <see cref="CalGrayColorSpaceDetails"/>. /// </summary> public CalGrayColorSpaceDetails([NotNull] IReadOnlyList <decimal> whitePoint, [CanBeNull] IReadOnlyList <decimal> blackPoint, decimal?gamma) : base(ColorSpace.CalGray) { WhitePoint = whitePoint ?? throw new ArgumentNullException(nameof(whitePoint)); if (WhitePoint.Count != 3) { throw new ArgumentOutOfRangeException(nameof(whitePoint), whitePoint, $"Must consist of exactly three numbers, but was passed {whitePoint.Count}."); } BlackPoint = blackPoint ?? new[] { 0m, 0, 0 }.ToList(); if (BlackPoint.Count != 3) { throw new ArgumentOutOfRangeException(nameof(blackPoint), blackPoint, $"Must consist of exactly three numbers, but was passed {blackPoint.Count}."); } Gamma = gamma ?? 1m; colorSpaceTransformer = new CIEBasedColorSpaceTransformer(((double)WhitePoint[0], (double)WhitePoint[1], (double)WhitePoint[2]), RGBWorkingSpace.sRGB) { DecoderABC = color => ( Math.Pow(color.A, (double)Gamma), Math.Pow(color.B, (double)Gamma), Math.Pow(color.C, (double)Gamma)), MatrixABC = new Matrix3x3( (double)WhitePoint[0], 0, 0, 0, (double)WhitePoint[1], 0, 0, 0, (double)WhitePoint[2]) }; }
/// <summary> /// Create a new <see cref="CalRGBColorSpaceDetails"/>. /// </summary> public CalRGBColorSpaceDetails([NotNull] IReadOnlyList <decimal> whitePoint, [CanBeNull] IReadOnlyList <decimal> blackPoint, [CanBeNull] IReadOnlyList <decimal> gamma, [CanBeNull] IReadOnlyList <decimal> matrix) : base(ColorSpace.CalRGB) { WhitePoint = whitePoint ?? throw new ArgumentNullException(nameof(whitePoint)); if (WhitePoint.Count != 3) { throw new ArgumentOutOfRangeException(nameof(whitePoint), whitePoint, $"Must consist of exactly three numbers, but was passed {whitePoint.Count}."); } BlackPoint = blackPoint ?? new[] { 0m, 0, 0 }.ToList(); if (BlackPoint.Count != 3) { throw new ArgumentOutOfRangeException(nameof(blackPoint), blackPoint, $"Must consist of exactly three numbers, but was passed {blackPoint.Count}."); } Gamma = gamma ?? new[] { 1m, 1, 1 }.ToList(); if (Gamma.Count != 3) { throw new ArgumentOutOfRangeException(nameof(gamma), gamma, $"Must consist of exactly three numbers, but was passed {gamma.Count}."); } Matrix = matrix ?? new[] { 1m, 0, 0, 0, 1, 0, 0, 0, 1 }.ToList(); if (Matrix.Count != 9) { throw new ArgumentOutOfRangeException(nameof(matrix), matrix, $"Must consist of exactly nine numbers, but was passed {matrix.Count}."); } colorSpaceTransformer = new CIEBasedColorSpaceTransformer(((double)WhitePoint[0], (double)WhitePoint[1], (double)WhitePoint[2]), RGBWorkingSpace.sRGB) { DecoderABC = color => ( Math.Pow(color.A, (double)Gamma[0]), Math.Pow(color.B, (double)Gamma[1]), Math.Pow(color.C, (double)Gamma[2])), MatrixABC = new Matrix3x3( (double)Matrix[0], (double)Matrix[3], (double)Matrix[6], (double)Matrix[1], (double)Matrix[4], (double)Matrix[7], (double)Matrix[2], (double)Matrix[5], (double)Matrix[8]) }; }