/// <summary>
        /// Writes a tag data entry
        /// </summary>
        /// <param name="data">The entry to write</param>
        /// <param name="table">The table entry for the written data entry</param>
        /// <returns>The number of bytes written (excluding padding)</returns>
        public int WriteTagDataEntry(IccTagDataEntry data, out IccTagTableEntry table)
        {
            uint offset = (uint)this.dataStream.Position;
            int  count  = this.WriteTagDataEntry(data);

            this.WritePadding();
            table = new IccTagTableEntry(data.TagSignature, offset, (uint)count);
            return(count);
        }
Exemple #2
0
        private IccTagTableEntry[] ReadTagTable(IccDataReader reader)
        {
            reader.SetIndex(128);   // An ICC header is 128 bytes long

            uint tagCount = reader.ReadUInt32();

            IccTagTableEntry[] table = new IccTagTableEntry[tagCount];

            for (int i = 0; i < tagCount; i++)
            {
                uint tagSignature = reader.ReadUInt32();
                uint tagOffset    = reader.ReadUInt32();
                uint tagSize      = reader.ReadUInt32();
                table[i] = new IccTagTableEntry((IccProfileTag)tagSignature, tagOffset, tagSize);
            }

            return(table);
        }
        /// <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));
            }
        }