Пример #1
0
        private void WriteHeader(IccDataWriter writer, IccProfileHeader header)
        {
            writer.SetIndex(0);

            writer.WriteUInt32(writer.Length);
            writer.WriteAsciiString(header.CmmType, 4, false);
            writer.WriteVersionNumber(header.Version);
            writer.WriteUInt32((uint)header.Class);
            writer.WriteUInt32((uint)header.DataColorSpace);
            writer.WriteUInt32((uint)header.ProfileConnectionSpace);
            writer.WriteDateTime(header.CreationDate);
            writer.WriteAsciiString("acsp");
            writer.WriteUInt32((uint)header.PrimaryPlatformSignature);
            writer.WriteInt32((int)header.Flags);
            writer.WriteUInt32(header.DeviceManufacturer);
            writer.WriteUInt32(header.DeviceModel);
            writer.WriteInt64((long)header.DeviceAttributes);
            writer.WriteUInt32((uint)header.RenderingIntent);
            writer.WriteXyzNumber(header.PcsIlluminant);
            writer.WriteAsciiString(header.CreatorSignature, 4, false);

            IccProfileId id = IccProfile.CalculateHash(writer.GetData());

            writer.WriteProfileId(id);
        }
Пример #2
0
        /// <summary>
        /// Reads an ICC profile
        /// </summary>
        /// <param name="data">The raw ICC data</param>
        /// <returns>The read ICC profile</returns>
        public IccProfile Read(byte[] data)
        {
            Guard.NotNull(data, nameof(data));
            Guard.IsTrue(data.Length >= 128, nameof(data), "Data length must be at least 128 to be a valid ICC profile");

            var reader = new IccDataReader(data);
            IccProfileHeader header = this.ReadHeader(reader);

            IccTagDataEntry[] tagData = this.ReadTagData(reader);

            return(new IccProfile(header, tagData));
        }