Exemple #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);
        }
Exemple #2
0
        /// <summary>
        /// Writes the ICC profile into a byte array
        /// </summary>
        /// <param name="profile">The ICC profile to write</param>
        /// <returns>The ICC profile as a byte array</returns>
        public byte[] Write(IccProfile profile)
        {
            Guard.NotNull(profile, nameof(profile));

            using (var writer = new IccDataWriter())
            {
                IccTagTableEntry[] tagTable = this.WriteTagData(writer, profile.Entries);
                this.WriteTagTable(writer, tagTable);
                this.WriteHeader(writer, profile.Header);
                return(writer.GetData());
            }
        }