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>
        /// Initializes a new instance of the <see cref="IccProfile"/> class
        /// by making a copy from another ICC profile.
        /// </summary>
        /// <param name="other">The other ICC profile, where the clone should be made from.</param>
        /// <exception cref="System.ArgumentNullException"><paramref name="other"/> is null.</exception>>
        public IccProfile(IccProfile other)
        {
            Guard.NotNull(other, nameof(other));

            // TODO: Do we need to copy anything else?
            if (other.data != null)
            {
                this.data = new byte[other.data.Length];
                Buffer.BlockCopy(other.data, 0, this.data, 0, other.data.Length);
            }
        }
Exemple #3
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());
            }
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IccProfile"/> class
        /// by making a copy from another ICC profile.
        /// </summary>
        /// <param name="other">The other ICC profile, where the clone should be made from.</param>
        /// <exception cref="ArgumentNullException"><paramref name="other"/> is null.</exception>>
        public IccProfile(IccProfile other)
        {
            Guard.NotNull(other, nameof(other));

            this.data = other.ToByteArray();
        }