/// <summary> /// Reads a <see cref="IccLutBToATagDataEntry"/> /// </summary> /// <returns>The read entry</returns> public IccLutBToATagDataEntry ReadLutBtoATagDataEntry() { int start = this.currentIndex - 8; // 8 is the tag header size byte inChCount = this.data[this.AddIndex(1)]; byte outChCount = this.data[this.AddIndex(1)]; this.AddIndex(2); // 2 bytes reserved uint bCurveOffset = this.ReadUInt32(); uint matrixOffset = this.ReadUInt32(); uint mCurveOffset = this.ReadUInt32(); uint clutOffset = this.ReadUInt32(); uint aCurveOffset = this.ReadUInt32(); IccTagDataEntry[] bCurve = null; IccTagDataEntry[] mCurve = null; IccTagDataEntry[] aCurve = null; IccClut clut = null; float[,] matrix3x3 = null; float[] matrix3x1 = null; if (bCurveOffset != 0) { this.currentIndex = (int)bCurveOffset + start; bCurve = this.ReadCurves(inChCount); } if (mCurveOffset != 0) { this.currentIndex = (int)mCurveOffset + start; mCurve = this.ReadCurves(inChCount); } if (aCurveOffset != 0) { this.currentIndex = (int)aCurveOffset + start; aCurve = this.ReadCurves(outChCount); } if (clutOffset != 0) { this.currentIndex = (int)clutOffset + start; clut = this.ReadClut(inChCount, outChCount, false); } if (matrixOffset != 0) { this.currentIndex = (int)matrixOffset + start; matrix3x3 = this.ReadMatrix(3, 3, false); matrix3x1 = this.ReadMatrix(3, false); } return(new IccLutBToATagDataEntry(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve)); }
/// <summary> /// Initializes a new instance of the <see cref="IccLutBToATagDataEntry"/> class. /// </summary> /// <param name="curveA">A Curve</param> /// <param name="clutValues">CLUT</param> /// <param name="curveM">M Curve</param> /// <param name="matrix3x3">Two dimensional conversion matrix (3x3)</param> /// <param name="matrix3x1">One dimensional conversion matrix (3x1)</param> /// <param name="curveB">B Curve</param> public IccLutBToATagDataEntry( IccTagDataEntry[] curveB, float[,] matrix3x3, float[] matrix3x1, IccTagDataEntry[] curveM, IccClut clutValues, IccTagDataEntry[] curveA) : this(curveB, matrix3x3, matrix3x1, curveM, clutValues, curveA, IccProfileTag.Unknown) { }
/// <summary> /// Initializes a new instance of the <see cref="IccLut16TagDataEntry"/> class. /// </summary> /// <param name="matrix">Conversion matrix (must be 3x3)</param> /// <param name="inputValues">Input LUT</param> /// <param name="clutValues">CLUT</param> /// <param name="outputValues">Output LUT</param> /// <param name="tagSignature">Tag Signature</param> public IccLut16TagDataEntry(float[,] matrix, IccLut[] inputValues, IccClut clutValues, IccLut[] outputValues, IccProfileTag tagSignature) : base(IccTypeSignature.Lut16, tagSignature) { Guard.NotNull(matrix, nameof(matrix)); Guard.NotNull(inputValues, nameof(inputValues)); Guard.NotNull(clutValues, nameof(clutValues)); Guard.NotNull(outputValues, nameof(outputValues)); bool is3By3 = matrix.GetLength(0) == 3 && matrix.GetLength(1) == 3; Guard.IsTrue(is3By3, nameof(matrix), "Matrix must have a size of three by three"); this.Matrix = this.CreateMatrix(matrix); this.InputValues = inputValues; this.ClutValues = clutValues; this.OutputValues = outputValues; Guard.IsTrue(this.InputChannelCount == clutValues.InputChannelCount, nameof(clutValues), "Input channel count does not match the CLUT size"); Guard.IsTrue(this.OutputChannelCount == clutValues.OutputChannelCount, nameof(clutValues), "Output channel count does not match the CLUT size"); }
/// <summary> /// Initializes a new instance of the <see cref="IccLut16TagDataEntry"/> class. /// </summary> /// <param name="matrix">Conversion matrix (must be 3x3)</param> /// <param name="inputValues">Input LUT</param> /// <param name="clutValues">CLUT</param> /// <param name="outputValues">Output LUT</param> public IccLut16TagDataEntry(float[,] matrix, IccLut[] inputValues, IccClut clutValues, IccLut[] outputValues) : this(matrix, inputValues, clutValues, outputValues, IccProfileTag.Unknown) { }
/// <summary> /// Initializes a new instance of the <see cref="IccLut16TagDataEntry"/> class. /// </summary> /// <param name="inputValues">Input LUT</param> /// <param name="clutValues">CLUT</param> /// <param name="outputValues">Output LUT</param> /// <param name="tagSignature">Tag Signature</param> public IccLut16TagDataEntry(IccLut[] inputValues, IccClut clutValues, IccLut[] outputValues, IccProfileTag tagSignature) : this(IdentityMatrix, inputValues, clutValues, outputValues, tagSignature) { }
/// <summary> /// Initializes a new instance of the <see cref="IccLut16TagDataEntry"/> class. /// </summary> /// <param name="inputValues">Input LUT</param> /// <param name="clutValues">CLUT</param> /// <param name="outputValues">Output LUT</param> public IccLut16TagDataEntry(IccLut[] inputValues, IccClut clutValues, IccLut[] outputValues) : this(IdentityMatrix, inputValues, clutValues, outputValues, IccProfileTag.Unknown) { }
/// <summary> /// Initializes a new instance of the <see cref="IccLutBToATagDataEntry"/> class. /// </summary> /// <param name="curveA">A Curve</param> /// <param name="clutValues">CLUT</param> /// <param name="curveM">M Curve</param> /// <param name="matrix3x3">Two dimensional conversion matrix (3x3)</param> /// <param name="matrix3x1">One dimensional conversion matrix (3x1)</param> /// <param name="curveB">B Curve</param> /// <param name="tagSignature">Tag Signature</param> public IccLutBToATagDataEntry( IccTagDataEntry[] curveB, float[,] matrix3x3, float[] matrix3x1, IccTagDataEntry[] curveM, IccClut clutValues, IccTagDataEntry[] curveA, IccProfileTag tagSignature) : base(IccTypeSignature.LutBToA, tagSignature) { this.VerifyMatrix(matrix3x3, matrix3x1); this.VerifyCurve(curveA, nameof(curveA)); this.VerifyCurve(curveB, nameof(curveB)); this.VerifyCurve(curveM, nameof(curveM)); this.Matrix3x3 = this.CreateMatrix3x3(matrix3x3); this.Matrix3x1 = this.CreateMatrix3x1(matrix3x1); this.CurveA = curveA; this.CurveB = curveB; this.CurveM = curveM; this.ClutValues = clutValues; if (this.IsBMatrixMClutA()) { Guard.IsTrue(this.CurveB.Length == 3, nameof(this.CurveB), $"{nameof(this.CurveB)} must have a length of three"); Guard.IsTrue(this.CurveM.Length == 3, nameof(this.CurveM), $"{nameof(this.CurveM)} must have a length of three"); Guard.MustBeBetweenOrEqualTo(this.CurveA.Length, 1, 15, nameof(this.CurveA)); this.InputChannelCount = 3; this.OutputChannelCount = curveA.Length; Guard.IsTrue(this.InputChannelCount == clutValues.InputChannelCount, nameof(clutValues), "Input channel count does not match the CLUT size"); Guard.IsTrue(this.OutputChannelCount == clutValues.OutputChannelCount, nameof(clutValues), "Output channel count does not match the CLUT size"); } else if (this.IsBMatrixM()) { Guard.IsTrue(this.CurveB.Length == 3, nameof(this.CurveB), $"{nameof(this.CurveB)} must have a length of three"); Guard.IsTrue(this.CurveM.Length == 3, nameof(this.CurveM), $"{nameof(this.CurveM)} must have a length of three"); this.InputChannelCount = this.OutputChannelCount = 3; } else if (this.IsBClutA()) { Guard.MustBeBetweenOrEqualTo(this.CurveA.Length, 1, 15, nameof(this.CurveA)); Guard.MustBeBetweenOrEqualTo(this.CurveB.Length, 1, 15, nameof(this.CurveB)); this.InputChannelCount = curveB.Length; this.OutputChannelCount = curveA.Length; Guard.IsTrue(this.InputChannelCount == clutValues.InputChannelCount, nameof(clutValues), "Input channel count does not match the CLUT size"); Guard.IsTrue(this.OutputChannelCount == clutValues.OutputChannelCount, nameof(clutValues), "Output channel count does not match the CLUT size"); } else if (this.IsB()) { this.InputChannelCount = this.OutputChannelCount = this.CurveB.Length; } else { throw new ArgumentException("Invalid combination of values given"); } }
/// <summary> /// Initializes a new instance of the <see cref="IccClutProcessElement"/> class. /// </summary> /// <param name="clutValue">The color lookup table of this element</param> public IccClutProcessElement(IccClut clutValue) : base(IccMultiProcessElementSignature.Clut, clutValue?.InputChannelCount ?? 1, clutValue?.OutputChannelCount ?? 1) { Guard.NotNull(clutValue, nameof(clutValue)); this.ClutValue = clutValue; }