コード例 #1
0
ファイル: TiffDirData.cs プロジェクト: rfimor/TiffCSharp
        public void read(System.IO.BinaryReader reader)
        {
            tag = reader.ReadUInt16();
            int typeID = reader.ReadUInt16();
            int count  = reader.ReadInt32();

            TiffData.TIFFdataType tifType;
            if (Enum.IsDefined(typeof(TiffData.TIFFdataType), typeID))
            {
                tifType = (TiffData.TIFFdataType)typeID;
            }
            else
            {
                tifType = TiffData.TIFFdataType.Undefined;
            }

            data = new TiffData(tifType, count);

            if (data.dataLength() <= 4)
            {
                readData(reader);
                offset = -1;
            }
            else
            {
                offset = reader.ReadUInt32();
            }
        }
コード例 #2
0
        /// <summary>
        /// Does deep copy.
        /// </summary>
        /// <returns>A deep copy of this instance.</returns>
        public object Clone()
        {
            TiffData temp = new TiffData(this.type, this.count);

            temp.setContent(content);
            return(temp);
        }
コード例 #3
0
 /// <summary>
 /// Construct an instance of TIFFinfo that contains a 16-bit integer. Type ID is 8.
 /// </summary>
 /// <param name="tag">Tag of info.</param>
 /// <param name="name">Name the info.</param>
 /// <param name="data">A 16-bit integer to be boxed in the info.</param>
 public TiffInfo(ushort tag, string name, short data)
 {
     this.tag  = tag;
     this.name = string.Copy(name);
     this.data = new TiffData(TiffData.TIFFdataType.SignedShort, 1);
     this.data.setContent(new short[1] {
         data
     });
 }
コード例 #4
0
 /// <summary>
 /// Construct an instance of TIFFinfo that contains a double data. Type ID is 12.
 /// </summary>
 /// <param name="tag">Tag of info.</param>
 /// <param name="name">Name the info.</param>
 /// <param name="data">A double data to be boxed in the info.</param>
 public TiffInfo(ushort tag, string name, double data)
 {
     this.tag  = tag;
     this.name = string.Copy(name);
     this.data = new TiffData(TiffData.TIFFdataType.Double, 1);
     this.data.setContent(new double[1] {
         data
     });
 }
コード例 #5
0
 /// <summary>
 /// Construct an instance of TIFFinfo that contains an unsigned rational number Type ID is 5.
 /// </summary>
 /// <param name="tag">Tag of info.</param>
 /// <param name="name">Name the info.</param>
 /// <param name="numerator">Numberator of the rational number.</param>
 /// <param name="denominator">Denominator of the rational number.</param>
 public TiffInfo(ushort tag, string name, uint numerator, uint denominator)
 {
     this.tag  = tag;
     this.name = string.Copy(name);
     this.data = new TiffData(TiffData.TIFFdataType.Rational, 1);
     this.data.setContent(new uint[2] {
         numerator, denominator
     });
 }
コード例 #6
0
 /// <summary>
 /// Construct an instance of TIFFinfo that contains a 32-bit unsigned integer. Type ID is 4.
 /// </summary>
 /// <param name="tag">Tag of info.</param>
 /// <param name="name">Name the info.</param>
 /// <param name="data">A 32-bit unsigned integer to be boxed in the info.</param>
 public TiffInfo(ushort tag, string name, uint data)
 {
     this.tag  = tag;
     this.name = string.Copy(name);
     this.data = new TiffData(TiffData.TIFFdataType.Long, 1);
     this.data.setContent(new uint[1] {
         data
     });
 }
コード例 #7
0
 /// <summary>
 /// Construct an instance of TIFFinfo that contains a given instance of TIFFdata.
 /// </summary>
 /// <param name="tag">Tag of info.</param>
 /// <param name="name">Name the info.</param>
 /// <param name="data">Data to be wrapped into the info.</param>
 internal TiffInfo(ushort tag, string name, TiffData data)
 {
     if (data == null)
     {
         return;
     }
     this.tag  = tag;
     this.name = string.Copy(name);
     this.data = data.Clone() as TiffData;
 }
コード例 #8
0
 /// <summary>
 /// Construct an instance of TIFFinfo that contains a signed byte array. Type ID is 6.
 /// </summary>
 /// <param name="tag">Tag of info.</param>
 /// <param name="name">Name the info.</param>
 /// <param name="data">A byte array tobe wrapped into the info.</param>
 public TiffInfo(ushort tag, string name, sbyte[] data)
 {
     this.tag  = tag;
     this.name = string.Copy(name);
     if (data == null)
     {
         this.data = new TiffData(TiffData.TIFFdataType.SignedByte);
         return;
     }
     this.data = new TiffData(TiffData.TIFFdataType.SignedByte);
     this.data.setContent(data);
 }
コード例 #9
0
 /// <summary>
 /// Construct an instance of TIFFinfo that contains a string. Type ID is 2.
 /// </summary>
 /// <param name="tag">Tag of info.</param>
 /// <param name="name">Name the info.</param>
 /// <param name="data">A string tobe stored into the info.</param>
 public TiffInfo(ushort tag, string name, string data)
 {
     this.tag  = tag;
     this.name = string.Copy(name);
     if (data == null || data.Length == 0)
     {
         this.data = new TiffData(TiffData.TIFFdataType.Ascii);
         return;
     }
     char[] temp1 = data.ToCharArray();
     char[] temp2 = new char[data.Length + 1];
     Array.Copy(temp1, temp2, data.Length);
     temp2[data.Length] = '\0';
     this.data          = new TiffData(TiffData.TIFFdataType.Ascii);
     this.data.setContent(temp2);
 }
コード例 #10
0
        /// <summary>
        /// Construct an instance of TIFFinfo that contains an unsigned rational array. Type ID is 5.
        /// </summary>
        /// <param name="tag">Tag of info.</param>
        /// <param name="name">Name the info.</param>
        /// <param name="numerator">Numberators.</param>
        /// <param name="denominator">Denominators.</param>
        public TiffInfo(ushort tag, string name, uint[] numerator, uint[] denominator)
        {
            this.tag  = tag;
            this.name = string.Copy(name);

            if (numerator == null || denominator == null)
            {
                this.data = new TiffData(TiffData.TIFFdataType.Rational);
                return;
            }

            int length = System.Math.Min(numerator.Length, denominator.Length);

            uint[] temp = new uint[length * 2];
            for (int i = 0; i < length; i++)
            {
                temp[2 * i]     = numerator[i];
                temp[2 * i + 1] = denominator[i];
            }

            this.data = new TiffData(TiffData.TIFFdataType.Rational);
            this.data.setContent(temp);
        }