/// <summary> /// Reads curve data /// </summary> /// <param name="count">Number of input channels</param> /// <returns>The curve data</returns> private IccTagDataEntry[] ReadCurves(int count) { var tdata = new IccTagDataEntry[count]; for (int i = 0; i < count; i++) { IccTypeSignature type = this.ReadTagDataEntryHeader(); if (type != IccTypeSignature.Curve && type != IccTypeSignature.ParametricCurve) { throw new InvalidIccProfileException($"Curve has to be either \"{nameof(IccTypeSignature)}.{nameof(IccTypeSignature.Curve)}\" or" + $" \"{nameof(IccTypeSignature)}.{nameof(IccTypeSignature.ParametricCurve)}\" for LutAToB- and LutBToA-TagDataEntries"); } if (type == IccTypeSignature.Curve) { tdata[i] = this.ReadCurveTagDataEntry(); } else if (type == IccTypeSignature.ParametricCurve) { tdata[i] = this.ReadParametricCurveTagDataEntry(); } this.AddPadding(); } return(tdata); }
/// <summary> /// Reads a profile description /// </summary> /// <returns>the profile description</returns> public IccProfileDescription ReadProfileDescription() { uint manufacturer = this.ReadUInt32(); uint model = this.ReadUInt32(); var attributes = (IccDeviceAttribute)this.ReadInt64(); var technologyInfo = (IccProfileTag)this.ReadUInt32(); IccMultiLocalizedUnicodeTagDataEntry manufacturerInfo = ReadText(); IccMultiLocalizedUnicodeTagDataEntry modelInfo = ReadText(); return(new IccProfileDescription( manufacturer, model, attributes, technologyInfo, manufacturerInfo.Texts, modelInfo.Texts)); IccMultiLocalizedUnicodeTagDataEntry ReadText() { IccTypeSignature type = this.ReadTagDataEntryHeader(); switch (type) { case IccTypeSignature.MultiLocalizedUnicode: return(this.ReadMultiLocalizedUnicodeTagDataEntry()); case IccTypeSignature.TextDescription: return((IccMultiLocalizedUnicodeTagDataEntry)this.ReadTextDescriptionTagDataEntry()); default: throw new InvalidIccProfileException("Profile description can only have multi-localized Unicode or text description entries"); } } }
/// <summary> /// Reads the header of a <see cref="IccTagDataEntry"/> and checks if it's the expected value /// </summary> /// <param name="expected">expected value to check against</param> public void ReadCheckTagDataEntryHeader(IccTypeSignature expected) { IccTypeSignature type = this.ReadTagDataEntryHeader(); if (expected != (IccTypeSignature)uint.MaxValue && type != expected) { throw new InvalidIccProfileException($"Read signature {type} is not the expected {expected}"); } }
/// <summary> /// Initializes a new instance of the <see cref="IccTagDataEntry"/> class. /// </summary> /// <param name="signature">Type Signature</param> /// <param name="tagSignature">Tag Signature</param> protected IccTagDataEntry(IccTypeSignature signature, IccProfileTag tagSignature) { this.Signature = signature; this.TagSignature = tagSignature; }
/// <summary> /// Initializes a new instance of the <see cref="IccTagDataEntry"/> class. /// TagSignature will be <see cref="IccProfileTag.Unknown"/> /// </summary> /// <param name="signature">Type Signature</param> protected IccTagDataEntry(IccTypeSignature signature) : this(signature, IccProfileTag.Unknown) { }
/// <summary> /// Writes the header of a <see cref="IccTagDataEntry"/> /// </summary> /// <param name="signature">The signature of the entry</param> /// <returns>The number of bytes written</returns> public int WriteTagDataEntryHeader(IccTypeSignature signature) { return(this.WriteUInt32((uint)signature) + this.WriteEmpty(4)); }
/// <summary> /// Reads a tag data entry /// </summary> /// <param name="info">The table entry with reading information</param> /// <returns>the tag data entry</returns> public IccTagDataEntry ReadTagDataEntry(IccTagTableEntry info) { this.currentIndex = (int)info.Offset; IccTypeSignature type = this.ReadTagDataEntryHeader(); switch (type) { case IccTypeSignature.Chromaticity: return(this.ReadChromaticityTagDataEntry()); case IccTypeSignature.ColorantOrder: return(this.ReadColorantOrderTagDataEntry()); case IccTypeSignature.ColorantTable: return(this.ReadColorantTableTagDataEntry()); case IccTypeSignature.Curve: return(this.ReadCurveTagDataEntry()); case IccTypeSignature.Data: return(this.ReadDataTagDataEntry(info.DataSize)); case IccTypeSignature.DateTime: return(this.ReadDateTimeTagDataEntry()); case IccTypeSignature.Lut16: return(this.ReadLut16TagDataEntry()); case IccTypeSignature.Lut8: return(this.ReadLut8TagDataEntry()); case IccTypeSignature.LutAToB: return(this.ReadLutAtoBTagDataEntry()); case IccTypeSignature.LutBToA: return(this.ReadLutBtoATagDataEntry()); case IccTypeSignature.Measurement: return(this.ReadMeasurementTagDataEntry()); case IccTypeSignature.MultiLocalizedUnicode: return(this.ReadMultiLocalizedUnicodeTagDataEntry()); case IccTypeSignature.MultiProcessElements: return(this.ReadMultiProcessElementsTagDataEntry()); case IccTypeSignature.NamedColor2: return(this.ReadNamedColor2TagDataEntry()); case IccTypeSignature.ParametricCurve: return(this.ReadParametricCurveTagDataEntry()); case IccTypeSignature.ProfileSequenceDesc: return(this.ReadProfileSequenceDescTagDataEntry()); case IccTypeSignature.ProfileSequenceIdentifier: return(this.ReadProfileSequenceIdentifierTagDataEntry()); case IccTypeSignature.ResponseCurveSet16: return(this.ReadResponseCurveSet16TagDataEntry()); case IccTypeSignature.S15Fixed16Array: return(this.ReadFix16ArrayTagDataEntry(info.DataSize)); case IccTypeSignature.Signature: return(this.ReadSignatureTagDataEntry()); case IccTypeSignature.Text: return(this.ReadTextTagDataEntry(info.DataSize)); case IccTypeSignature.U16Fixed16Array: return(this.ReadUFix16ArrayTagDataEntry(info.DataSize)); case IccTypeSignature.UInt16Array: return(this.ReadUInt16ArrayTagDataEntry(info.DataSize)); case IccTypeSignature.UInt32Array: return(this.ReadUInt32ArrayTagDataEntry(info.DataSize)); case IccTypeSignature.UInt64Array: return(this.ReadUInt64ArrayTagDataEntry(info.DataSize)); case IccTypeSignature.UInt8Array: return(this.ReadUInt8ArrayTagDataEntry(info.DataSize)); case IccTypeSignature.ViewingConditions: return(this.ReadViewingConditionsTagDataEntry()); case IccTypeSignature.Xyz: return(this.ReadXyzTagDataEntry(info.DataSize)); // V2 Types: case IccTypeSignature.TextDescription: return(this.ReadTextDescriptionTagDataEntry()); case IccTypeSignature.CrdInfo: return(this.ReadCrdInfoTagDataEntry()); case IccTypeSignature.Screening: return(this.ReadScreeningTagDataEntry()); case IccTypeSignature.UcrBg: return(this.ReadUcrBgTagDataEntry(info.DataSize)); // Unsupported or unknown case IccTypeSignature.DeviceSettings: case IccTypeSignature.NamedColor: case IccTypeSignature.Unknown: default: return(this.ReadUnknownTagDataEntry(info.DataSize)); } }