Exemplo n.º 1
0
        private IccTagTableEntry[] WriteTagData(IccDataWriter writer, IccTagDataEntry[] entries)
        {
            // TODO: Investigate cost of Linq GroupBy
            IEnumerable <IGrouping <IccTagDataEntry, IccTagDataEntry> > grouped = entries.GroupBy(t => t);

            // (Header size) + (entry count) + (nr of entries) * (size of table entry)
            writer.SetIndex(128 + 4 + (entries.Length * 12));

            var table = new List <IccTagTableEntry>();

            foreach (IGrouping <IccTagDataEntry, IccTagDataEntry> group in grouped)
            {
                writer.WriteTagDataEntry(group.Key, out IccTagTableEntry tableEntry);
                foreach (IccTagDataEntry item in group)
                {
                    table.Add(new IccTagTableEntry(item.TagSignature, tableEntry.Offset, tableEntry.DataSize));
                }
            }

            return(table.ToArray());
        }