Esempio n. 1
0
 public Tiff(Stream stream)
 {
     using (var tiffStream = new TiffStreamReader(stream))
     {
         LoadImage(tiffStream);
     }
 }
Esempio n. 2
0
        private void LoadImage(TiffStreamReader stream)
        {
            Image image;
            uint  offset;
            var   offsets = new HashSet <uint>(); // keep track of read offsets so we can detect loops

            offset = stream.ReadHeader();

            // set endianness now that the stream header has been validated
            IsBigEndian = stream.IsBigEndian;

            // read all images from file
            while (offset != 0)
            {
                if (offsets.Contains(offset))
                {
                    throw new InvalidDataException("Circular image reference detected in file. Aborting load.");
                }
                else
                {
                    offsets.Add(offset);
                    (image, offset) = stream.ReadImage(offset);
                    Images.Add(image);
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Loads a TIFF file from disk.
 /// </summary>
 /// <param name="fileName"></param>
 public Tiff(string fileName)
 {
     using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
         using (var tiffStream = new TiffStreamReader(stream))
         {
             LoadImage(tiffStream);
         }
 }