Exemplo n.º 1
0
                /// <summary>
                /// Read field descriptor from block.
                /// A "property" of the image.
                /// </summary>
                /// <param name="IDBlock">Block containing descriptor, but NOT it's data.</param>
                /// <param name="endianness">Big or little endianness defined by TIFF header.</param>
                /// <param name="dataStream">Full image stream to read descriptor data from.</param>
                public FieldDescriptor(byte[] IDBlock, MyBitConverter.Endianness endianness, Stream dataStream)
                {
                    FieldTag    = (FieldTags)MyBitConverter.ToInt16(IDBlock, 0, endianness);
                    FieldType   = (FieldTypes)MyBitConverter.ToInt16(IDBlock, 2, endianness);
                    FieldLength = MyBitConverter.ToInt32(IDBlock, 4, endianness);
                    DataOffset  = MyBitConverter.ToInt32(IDBlock, 8, endianness);

                    // Read data indicated by descriptor
                    long oldOffset = dataStream.Position;

                    dataStream.Seek(DataOffset, SeekOrigin.Begin);
                    Data = new byte[FieldLength];
                    dataStream.Read(Data, 0, FieldLength);

                    // Reset stream position for next descriptor
                    dataStream.Seek(oldOffset, SeekOrigin.Begin);
                }
Exemplo n.º 2
0
        /// <summary>
        /// Read header of JPG image.
        /// </summary>
        /// <param name="stream">Fully formatted JPG image.</param>
        /// <returns>Length of header.</returns>
        protected override long Load(Stream stream)
        {
            base.Load(stream);
            byte[] temp = stream.ReadBytes(HeaderSize);

            if (!CheckIdentifier(temp))
            {
                throw new FormatException("Stream is not a BMP Image");
            }

            DataSectionLength    = BitConverter.ToInt16(temp, 4);
            Identifier           = BitConverter.ToString(temp, 6, 5);
            Version              = temp[11] + ".0" + temp[12];
            ResolutionUnits      = (UnitsType)temp[13];
            HorizontalResolution = MyBitConverter.ToInt16(temp, 14, MyBitConverter.Endianness.BigEndian);
            VerticalResolution   = MyBitConverter.ToInt16(temp, 16, MyBitConverter.Endianness.BigEndian);
            XThumbnailPixelCount = temp[18];
            YThumbnailPixelCount = temp[19];

            return(HeaderSize);
        }
Exemplo n.º 3
0
 public LasPoint2Long(byte[] rawBytes, int startPosition = 0) : base(rawBytes, startPosition)
 {
     _red   = (ushort)MyBitConverter.ToInt16(rawBytes, startPosition + 20);
     _green = (ushort)MyBitConverter.ToInt16(rawBytes, startPosition + 22);
     _blue  = (ushort)MyBitConverter.ToInt16(rawBytes, startPosition + 24);
 }