/// <summary>
        /// Writes a <see cref="IccCurveTagDataEntry"/>
        /// </summary>
        /// <param name="value">The entry to write</param>
        /// <returns>The number of bytes written</returns>
        public int WriteCurveTagDataEntry(IccCurveTagDataEntry value)
        {
            int count = 0;

            if (value.IsIdentityResponse)
            {
                count += this.WriteUInt32(0);
            }
            else if (value.IsGamma)
            {
                count += this.WriteUInt32(1);
                count += this.WriteUFix8(value.Gamma);
            }
            else
            {
                count += this.WriteUInt32((uint)value.CurveData.Length);
                for (int i = 0; i < value.CurveData.Length; i++)
                {
                    count += this.WriteUInt16((ushort)((value.CurveData[i] * ushort.MaxValue) + 0.5f).Clamp(0, ushort.MaxValue));
                }
            }

            return(count);

            // TODO: Page 48: If the input is PCSXYZ, 1+(32 767/32 768) shall be mapped to the value 1,0. If the output is PCSXYZ, the value 1,0 shall be mapped to 1+(32 767/32 768).
        }
Beispiel #2
0
        internal void ReadCurveTagDataEntry(byte[] data, IccCurveTagDataEntry expected)
        {
            IccDataReader reader = CreateReader(data);

            IccCurveTagDataEntry output = reader.ReadCurveTagDataEntry();

            Assert.Equal(expected, output);
        }
        internal void WriteCurveTagDataEntry(byte[] expected, IccCurveTagDataEntry data)
        {
            IccDataWriter writer = CreateWriter();

            writer.WriteCurveTagDataEntry(data);
            byte[] output = writer.GetData();

            Assert.Equal(expected, output);
        }