Esempio n. 1
0
        static void Main(string[] args)
        {
            string   dir = @"C:\TEMP\Copia de TEMP\";
            FileInfo fi  = new FileInfo(dir + "DSCN3462.JPG");

            List <byte> bytes = GetFileBytes(fi, 0, 2048);

            TiffHeader header = new TiffHeader();

            int tiffHeaderIndex;
            int tiffFileMarkIndex = LocateExifFileMarkIndex(bytes, out tiffHeaderIndex);

            header.Index     = tiffHeaderIndex;
            header.ByteOrder = GetEndiannes(bytes, header.Index);

            bool endiannessChecked = CheckEndianness(bytes, header.ByteOrder, header.Index);

            header.IfdOffset  = GetFirstTagOffset(bytes, header.ByteOrder, header.Index);
            header.TagsNumber = GetTagsNumber(bytes, header.ByteOrder, header.Index, header.IfdOffset);

            int firstTagIdx = GetFirstTagIdx(header.Index, header.IfdOffset);

            byte[][] tagsBytes = ExtractTagsBytes(bytes, header.TagsNumber, firstTagIdx);

            TiffTagCollection tags = ParseTagsBytes(header.ByteOrder, tagsBytes);

            LoadTagValues(ref tags, tiffHeaderIndex, bytes);

            foreach (Tag tag in tags.Values)
            {
                Console.WriteLine("{0}: {1}", tag.Id, Encoding.ASCII.GetString(tag.TagValueBytes.ToArray()));
            }
        }
Esempio n. 2
0
        private static TiffTagCollection ParseTagsBytes(Endianness endianness, byte[][] tagsBytes)
        {
            TiffTagCollection result = new TiffTagCollection();
            Tag tag;

            foreach (byte[] bytes in tagsBytes)
            {
                tag = ParseTagBytes(endianness, bytes);
                result.Add(tag.Id, tag);
            }

            return(result);
        }
Esempio n. 3
0
        private static void LoadTagValues(ref TiffTagCollection tags, int headerIndex, List <byte> bytes)
        {
            foreach (Tag tag in tags.Values)
            {
                if (!tag.IsValueOffsetPointer)
                {
                    continue;
                }
                Tag tagReference = tag;

                LoadTagValue(ref tagReference, headerIndex, bytes);
            }
        }