Ejemplo n.º 1
0
        private IccProfileHeader ReadHeader(IccDataReader reader)
        {
            reader.SetIndex(0);

            return(new IccProfileHeader
            {
                Size = reader.ReadUInt32(),
                CmmType = reader.ReadAsciiString(4),
                Version = reader.ReadVersionNumber(),
                Class = (IccProfileClass)reader.ReadUInt32(),
                DataColorSpace = (IccColorSpaceType)reader.ReadUInt32(),
                ProfileConnectionSpace = (IccColorSpaceType)reader.ReadUInt32(),
                CreationDate = reader.ReadDateTime(),
                FileSignature = reader.ReadAsciiString(4),
                PrimaryPlatformSignature = (IccPrimaryPlatformType)reader.ReadUInt32(),
                Flags = (IccProfileFlag)reader.ReadInt32(),
                DeviceManufacturer = reader.ReadUInt32(),
                DeviceModel = reader.ReadUInt32(),
                DeviceAttributes = (IccDeviceAttribute)reader.ReadInt64(),
                RenderingIntent = (IccRenderingIntent)reader.ReadUInt32(),
                PcsIlluminant = reader.ReadXyzNumber(),
                CreatorSignature = reader.ReadAsciiString(4),
                Id = reader.ReadProfileId(),
            });
        }
Ejemplo n.º 2
0
        private IccTagTableEntry[] ReadTagTable(IccDataReader reader)
        {
            reader.SetIndex(128);   // An ICC header is 128 bytes long

            uint tagCount = reader.ReadUInt32();

            // Prevent creating huge arrays because of corrupt profiles.
            // A normal profile usually has 5-15 entries
            if (tagCount > 100)
            {
                return(Array.Empty <IccTagTableEntry>());
            }

            var table = new List <IccTagTableEntry>((int)tagCount);

            for (int i = 0; i < tagCount; i++)
            {
                uint tagSignature = reader.ReadUInt32();
                uint tagOffset    = reader.ReadUInt32();
                uint tagSize      = reader.ReadUInt32();

                // Exclude entries that have nonsense values and could cause exceptions further on
                if (tagOffset < reader.DataLength && tagSize < reader.DataLength - 128)
                {
                    table.Add(new IccTagTableEntry((IccProfileTag)tagSignature, tagOffset, tagSize));
                }
            }

            return(table.ToArray());
        }