Exemple #1
0
 /// <summary>
 /// Construct an instance of empty (to be filled with the setContent() method) TIFFdata given type id and counts of data.
 /// </summary>
 /// <param name="id">Type id</param>
 /// <param name="count">Counts of data.</param>
 public TiffData(TIFFdataType type, int count)
 {
     this.type = type;
     getDataTypeInfo(type, out nBytes, out dataType);
     this.count = count;
     content    = Array.CreateInstance(dataType, 0);
 }
Exemple #2
0
        /// <summary>
        /// Find number of byete and underlying C# data type
        /// </summary>
        /// <param name="type">TIFF data type</param>
        /// <param name="nBytes">Size of TIFF data type in bytes</param>
        /// <param name="dataType">Underlying C# data type</param>
        public static void getDataTypeInfo(TIFFdataType type, out int nBytes, out Type dataType)
        {
            switch (type)
            {
            case TIFFdataType.Byte:
                nBytes   = 1;
                dataType = typeof(byte);
                break;

            case TIFFdataType.Ascii:
                nBytes   = 1;
                dataType = typeof(char);
                break;

            case TIFFdataType.Short:
                nBytes   = 2;
                dataType = typeof(ushort);
                break;

            case TIFFdataType.Long:
                nBytes   = 4;
                dataType = typeof(uint);
                break;

            case TIFFdataType.Rational:
                nBytes   = 8;
                dataType = typeof(uint);
                break;

            case TIFFdataType.SignedByte:
                nBytes   = 1;
                dataType = typeof(sbyte);
                break;

            case TIFFdataType.SignedShort:
                nBytes   = 2;
                dataType = typeof(short);
                break;

            case TIFFdataType.SignedLong:
                nBytes   = 4;
                dataType = typeof(int);
                break;

            case TIFFdataType.SignedRational:
                nBytes   = 8;
                dataType = typeof(int);
                break;

            case TIFFdataType.Float:
                nBytes   = 4;
                dataType = typeof(float);
                break;

            case TIFFdataType.Double:
                nBytes   = 8;
                dataType = typeof(double);
                break;

            default:
                type     = TIFFdataType.Undefined;
                nBytes   = 1;
                dataType = typeof(byte);
                break;
            }
        }