Beispiel #1
0
        /// <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));
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IccLutAToBTagDataEntry"/> class.
 /// </summary>
 /// <param name="curveB">B Curve</param>
 /// <param name="matrix3x3">Two dimensional conversion matrix (3x3)</param>
 /// <param name="matrix3x1">One dimensional conversion matrix (3x1)</param>
 /// <param name="curveM">M Curve</param>
 /// <param name="clutValues">CLUT</param>
 /// <param name="curveA">A Curve</param>
 public IccLutAToBTagDataEntry(
     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));

            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       = CreateMatrix(matrix);
            this.InputValues  = inputValues ?? throw new ArgumentNullException(nameof(inputValues));
            this.ClutValues   = clutValues ?? throw new ArgumentNullException(nameof(clutValues));
            this.OutputValues = outputValues ?? throw new ArgumentNullException(nameof(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");
        }
Beispiel #4
0
        /// <summary>
        /// Reads a <see cref="IccLut16TagDataEntry"/>
        /// </summary>
        /// <returns>The read entry</returns>
        public IccLut16TagDataEntry ReadLut16TagDataEntry()
        {
            byte inChCount      = this.data[this.AddIndex(1)];
            byte outChCount     = this.data[this.AddIndex(1)];
            byte clutPointCount = this.data[this.AddIndex(1)];

            this.AddIndex(1);   // 1 byte reserved

            float[,] matrix = this.ReadMatrix(3, 3, false);

            ushort inTableCount  = this.ReadUInt16();
            ushort outTableCount = this.ReadUInt16();

            // Input LUT
            var inValues = new IccLut[inChCount];

            byte[] gridPointCount = new byte[inChCount];
            for (int i = 0; i < inChCount; i++)
            {
                inValues[i]       = this.ReadLut16(inTableCount);
                gridPointCount[i] = clutPointCount;
            }

            // CLUT
            IccClut clut = this.ReadClut16(inChCount, outChCount, gridPointCount);

            // Output LUT
            var outValues = new IccLut[outChCount];

            for (int i = 0; i < outChCount; i++)
            {
                outValues[i] = this.ReadLut16(outTableCount);
            }

            return(new IccLut16TagDataEntry(matrix, inValues, clut, outValues));
        }
 /// <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)
 {
 }
Beispiel #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IccLutAToBTagDataEntry"/> class.
        /// </summary>
        /// <param name="curveB">B Curve</param>
        /// <param name="matrix3x3">Two dimensional conversion matrix (3x3)</param>
        /// <param name="matrix3x1">One dimensional conversion matrix (3x1)</param>
        /// <param name="curveM">M Curve</param>
        /// <param name="clutValues">CLUT</param>
        /// <param name="curveA">A Curve</param>
        /// <param name="tagSignature">Tag Signature</param>
        public IccLutAToBTagDataEntry(
            IccTagDataEntry[] curveB,
            float[,] matrix3x3,
            float[] matrix3x1,
            IccTagDataEntry[] curveM,
            IccClut clutValues,
            IccTagDataEntry[] curveA,
            IccProfileTag tagSignature)
            : base(IccTypeSignature.LutAToB, 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.IsAClutMMatrixB())
            {
                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  = curveA.Length;
                this.OutputChannelCount = 3;

                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.IsMMatrixB())
            {
                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.IsAClutB())
            {
                Guard.MustBeBetweenOrEqualTo(this.CurveA.Length, 1, 15, nameof(this.CurveA));
                Guard.MustBeBetweenOrEqualTo(this.CurveB.Length, 1, 15, nameof(this.CurveB));

                this.InputChannelCount  = curveA.Length;
                this.OutputChannelCount = curveB.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");
            }
        }
Beispiel #9
0
 /// <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)
 {
     this.ClutValue = clutValue ?? throw new ArgumentNullException(nameof(clutValue));
 }