/// <summary>
        /// Reads a <see cref="IccLut8TagDataEntry"/>
        /// </summary>
        /// <returns>The read entry</returns>
        public IccLut8TagDataEntry ReadLut8TagDataEntry()
        {
            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);

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

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

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

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

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

            return(new IccLut8TagDataEntry(matrix, inValues, clut, outValues));
        }
Esempio n. 2
0
        /// <summary>
        /// Writes an 16bit lookup table
        /// </summary>
        /// <param name="value">The LUT to write</param>
        /// <returns>The number of bytes written</returns>
        public int WriteLut16(IccLut value)
        {
            foreach (float item in value.Values)
            {
                this.WriteUInt16((ushort)Numeric.Clamp((item * ushort.MaxValue) + 0.5F, 0, ushort.MaxValue));
            }

            return(value.Values.Length * 2);
        }
Esempio n. 3
0
        /// <summary>
        /// Writes an 8bit lookup table
        /// </summary>
        /// <param name="value">The LUT to write</param>
        /// <returns>The number of bytes written</returns>
        public int WriteLut8(IccLut value)
        {
            foreach (float item in value.Values)
            {
                this.WriteByte((byte)Numeric.Clamp((item * byte.MaxValue) + 0.5F, 0, byte.MaxValue));
            }

            return(value.Values.Length);
        }