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); #if !NETSTANDARD1_1 IccProfileId id = IccProfile.CalculateHash(writer.GetData()); writer.WriteProfileId(id); #else writer.WriteProfileId(IccProfileId.Zero); #endif }
/// <summary> /// Initializes a new instance of the <see cref="IccProfile"/> class. /// </summary> /// <param name="header">The profile header</param> /// <param name="entries">The actual profile data</param> internal IccProfile(IccProfileHeader header, IEnumerable <IccTagDataEntry> entries) { Guard.NotNull(header, nameof(header)); Guard.NotNull(entries, nameof(entries)); this.header = header; this.entries = new List <IccTagDataEntry>(entries); }
/// <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)); }