/// <summary> /// Writes a <see cref="IccProfileSequenceIdentifierTagDataEntry"/> /// </summary> /// <param name="value">The entry to write</param> /// <returns>The number of bytes written</returns> public int WriteProfileSequenceIdentifierTagDataEntry(IccProfileSequenceIdentifierTagDataEntry value) { long start = this.dataStream.Position - 8; // 8 is the tag header size int length = value.Data.Length; int count = this.WriteUInt32((uint)length); // Jump over position table long tablePosition = this.dataStream.Position; this.dataStream.Position += length * 8; IccPositionNumber[] table = new IccPositionNumber[length]; for (int i = 0; i < length; i++) { uint offset = (uint)(this.dataStream.Position - start); int size = this.WriteProfileId(value.Data[i].Id); size += this.WriteTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.Data[i].Description)); size += this.WritePadding(); table[i] = new IccPositionNumber(offset, (uint)size); count += size; } // Write position table long lpos = this.dataStream.Position; this.dataStream.Position = tablePosition; foreach (IccPositionNumber pos in table) { count += this.WritePositionNumber(pos); } this.dataStream.Position = lpos; return(count); }
internal void ReadPositionNumber(byte[] data, IccPositionNumber expected) { IccDataReader reader = CreateReader(data); IccPositionNumber output = reader.ReadPositionNumber(); Assert.Equal(expected, output); }
internal void WritePositionNumber(byte[] expected, IccPositionNumber data) { IccDataWriter writer = this.CreateWriter(); writer.WritePositionNumber(data); byte[] output = writer.GetData(); Assert.Equal(expected, output); }
/// <summary> /// Writes a <see cref="IccMultiProcessElementsTagDataEntry"/> /// </summary> /// <param name="value">The entry to write</param> /// <returns>The number of bytes written</returns> public int WriteMultiProcessElementsTagDataEntry(IccMultiProcessElementsTagDataEntry value) { long start = this.dataStream.Position - 8; // 8 is the tag header size int count = this.WriteUInt16((ushort)value.InputChannelCount); count += this.WriteUInt16((ushort)value.OutputChannelCount); count += this.WriteUInt32((uint)value.Data.Length); // Jump over position table long tpos = this.dataStream.Position; this.dataStream.Position += value.Data.Length * 8; IccPositionNumber[] posTable = new IccPositionNumber[value.Data.Length]; for (int i = 0; i < value.Data.Length; i++) { uint offset = (uint)(this.dataStream.Position - start); int size = this.WriteMultiProcessElement(value.Data[i]); count += this.WritePadding(); posTable[i] = new IccPositionNumber(offset, (uint)size); count += size; } // Write position table long lpos = this.dataStream.Position; this.dataStream.Position = tpos; foreach (IccPositionNumber pos in posTable) { count += this.WritePositionNumber(pos); } this.dataStream.Position = lpos; return(count); }