Exemple #1
0
 public TagInfo(byte[] buffer, BitConvert bit)
 {
     TagId        = bit.ToUInt16(buffer, 0);
     TagType      = (TagType)(bit.ToInt16(buffer, 2));
     Count        = bit.ToUInt32(buffer, 4);
     ValuePointer = bit.ToUInt32(buffer, 8);
 }
Exemple #2
0
        private void ReadHeader(IIoStream stream)
        {
            var marker = new byte[2];

            stream.Read(marker, marker.Length, 0);
            if (!marker.SequenceEqual(HeaderMarker1))
            {
                throw new ImageFormatInvalid();
            }
            stream.Read(marker, marker.Length, 2);
            while (true)
            {
                if (marker.SequenceEqual(HeaderMarker2))
                {
                    break;
                }
                try
                {
                    stream.Read(marker, marker.Length);
                }
                catch (Exception)
                {
                    throw new ImageFormatInvalid();
                }
            }
            stream.Read(marker, marker.Length);
            var app0 = _bit.ToUInt16(marker, 0);

            var header = new byte[8];

            stream.Read(header, 6);
            var p = stream.Position;

            stream.Read(header, header.Length);
            if ((char)header[0] == 'I' && (char)header[1] == 'I')
            {
                _bit = new BitConvert(true);
            }
            else if ((char)header[0] == 'M' && (char)header[1] == 'M')
            {
                _bit = new BitConvert(false);
            }
            else
            {
                throw new ImageFormatInvalid();
            }
            if (_bit.ToInt16(header, 0x0002) != 0x002a)
            {
                throw new ImageFormatInvalid();
            }
            stream.StartOffset = p;
            _tiffOffset        = _bit.ToUInt32(header, 0x0004);
        }
Exemple #3
0
        public override bool Resolve(TagInfo info, IIoStream imageStream, BitConvert bit)
        {
            var r      = new ushort[info.Count];
            var buffer = new byte[info.Count * 2];

            imageStream.Read(buffer, buffer.Length, info.ValuePointer);
            for (var i = 0; i < info.Count; i++)
            {
                r[i] = bit.ToUInt16(buffer, i * 2);
            }
            Value = r;
            return(true);
        }