/// <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); }
/// <summary> /// Reads a <see cref="IccMultiProcessElementsTagDataEntry"/> /// </summary> /// <returns>The read entry</returns> public IccMultiProcessElementsTagDataEntry ReadMultiProcessElementsTagDataEntry() { int start = this.currentIndex - 8; // TODO: Why are we storing variable ushort inChannelCount = this.ReadUInt16(); ushort outChannelCount = this.ReadUInt16(); uint elementCount = this.ReadUInt32(); var positionTable = new IccPositionNumber[elementCount]; for (int i = 0; i < elementCount; i++) { positionTable[i] = this.ReadPositionNumber(); } var elements = new IccMultiProcessElement[elementCount]; for (int i = 0; i < elementCount; i++) { this.currentIndex = (int)positionTable[i].Offset + start; elements[i] = this.ReadMultiProcessElement(); } return(new IccMultiProcessElementsTagDataEntry(elements)); }
/// <summary> /// Reads a <see cref="IccProfileSequenceIdentifierTagDataEntry"/> /// </summary> /// <returns>The read entry</returns> public IccProfileSequenceIdentifierTagDataEntry ReadProfileSequenceIdentifierTagDataEntry() { int start = this.currentIndex - 8; // 8 is the tag header size uint count = this.ReadUInt32(); IccPositionNumber[] table = new IccPositionNumber[count]; for (int i = 0; i < count; i++) { table[i] = this.ReadPositionNumber(); } IccProfileSequenceIdentifier[] entries = new IccProfileSequenceIdentifier[count]; for (int i = 0; i < count; i++) { this.currentIndex = (int)(start + table[i].Offset); IccProfileId id = this.ReadProfileId(); this.ReadCheckTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode); IccMultiLocalizedUnicodeTagDataEntry description = this.ReadMultiLocalizedUnicodeTagDataEntry(); entries[i] = new IccProfileSequenceIdentifier(id, description.Texts); } return(new IccProfileSequenceIdentifierTagDataEntry(entries)); }
/// <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); }
/// <summary> /// Writes a position number /// </summary> /// <param name="value">The value to write</param> /// <returns>the number of bytes written</returns> public int WritePositionNumber(IccPositionNumber value) { return(this.WriteUInt32(value.Offset) + this.WriteUInt32(value.Size)); }