Click or drag to resize

TiffDecoder Class

An ImageDecoder used to read Tagged Image File Format (TIFF) images from an image Stream.

Inheritance Hierarchy
SystemObject
  Atalasoft.Imaging.CodecImageDecoder
    Atalasoft.Imaging.CodecMultiFramedImageDecoder
      Atalasoft.Imaging.CodecTiffDecoder

Namespace:  Atalasoft.Imaging.Codec
Assembly:  Atalasoft.dotImage (in Atalasoft.dotImage.dll) Version: 11.4.0.9.0.377 (.NET 4.5.2, x86)
Syntax
public class TiffDecoder : MultiFramedImageDecoder, 
	IRegionReadable, IScaledDecoder

The TiffDecoder type exposes the following members.

Constructors
  NameDescription
Public methodTiffDecoder
Initializes a new instance of a %TiffDecoder%.
Top
Properties
  NameDescription
Public propertyCorrectOrientation
Gets or sets a value that when true (the default) will automatically correct the image orientation by rotating and/or flipping based on the TIFF_ORIENTATION tag setting.
Public propertyScaledResampleMethod
Gets or sets the resampling method to use for ReadScaled.
Public propertySupportedImageType Obsolete.
Returns the ImageType that the implemented decoder class supports.
(Overrides ImageDecoderSupportedImageType.)
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetBestScale
Gets the most effiicient image scale stored within the codec.
Public methodGetFrameCount
Returns the number of pages in an Encoded Tiff file.
(Overrides MultiFramedImageDecoderGetFrameCount(Stream).)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetImageInfo(Stream)
Retreive information from a Tiff image stored in a Stream without decoding the image data.
(Overrides ImageDecoderGetImageInfo(Stream).)
Public methodGetImageInfo(Stream, Int32)
Retreive information from a Tiff image stored in a Stream without decoding the image data.
(Overrides MultiFramedImageDecoderGetImageInfo(Stream, Int32).)
Public methodStatic memberGetTiffTag(Int32, Stream, Int32)
Gets a TIFF Tag from a TIFF image stream.
Public methodStatic memberCode exampleGetTiffTag(Int32, String, Int32)
Gets a TIFF Tag from a TIFF file.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsValidFormat

Returns true if the specified Stream contains an TIFF image.

(Overrides ImageDecoderIsValidFormat(Stream).)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodCode exampleRead(Stream, ProgressEventHandler)
Decodes an image from a supplied TIFF image Stream.
(Overrides ImageDecoderRead(Stream, ProgressEventHandler).)
Public methodCode exampleRead(Stream, Int32, ProgressEventHandler)
Decodes an image from a supplied TIFF image Stream specifying a frame index.
(Overrides MultiFramedImageDecoderRead(Stream, Int32, ProgressEventHandler).)
Public methodReadRegion
Decodes a specified region of a TIFF image given a source Stream.
Public methodReadScaled
Decodes an image to a specified scale.
Public methodReadStrip
Decodes a specified strip from a TIFF image stream that is encoded with strips.
Public methodReadTile
Decodes a specified tile from a TIFF image stream that is encoded with strips.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks

By default, when opening a TIFF image using the AtalaImage or Workspace objects, this decoder will automatically be selected from the Decoders collection and does not have to be explicitly set.

TIFF images can contain multiple pages in one file. You may wish to specify which page to read or get information about by specifying the frameindex in the associated Read methods.

TIFF images can store metadata such as EXIF, IPTC, XMP, and other TIFF tags. See the %Atalasoft.Imaging.Metadata% namespace for more information on reading this information.

Examples

Split a multi-page TIFF into individual pages

[New Example] (C#)
//initialize an instance of a TiffDecoder
TiffDecoder tiffReader = new TiffDecoder();
//open the file stream
FileStream fs = File.OpenRead(@"C:\Development\Image Database\Tiff\1_multi.tif");
//get the number of pages in the TIFF
int pageCount = tiffReader.GetFrameCount(fs);
//loop through each page in the TIFF
for (int i = 0; i < pageCount; i++)
{
    //seek to the beginning of the file
    fs.Seek(0, SeekOrigin.Begin); 
    //read the specified frameindex
    AtalaImage page = tiffReader.Read(fs, i, null);
    //save the page as a standalone TIFF in the working directory
    page.Save(Path.GetFileNameWithoutExtension(fs.Name) + "_" + i + ".tif", new TiffEncoder(), null);
    //dispose of uneeded image
    page.Dispose();
}
[New Example] (Visual Basic)
'initialize an instance of a TiffDecoder
Dim tiffReader As TiffDecoder = New TiffDecoder() 
'open the file stream
Dim fs As FileStream =  File.OpenRead("C:\Development\Image Database\Tiff\1_multi.tif") 
'get the number of pages in the TIFF
Dim pageCount As Integer =  tiffReader.GetFrameCount(fs) 
'loop through each page in the TIFF
Dim i As Integer
For  i = 0 To pageCount - 1
    'seek to the beginning of the file
    fs.Seek(0, SeekOrigin.Begin) 
    'read the specified frameindex
    Dim page As AtalaImage = tiffReader.Read(fs, i, Nothing) 
    'save the page as a standalone TIFF in the working directory
    page.Save(Path.GetFileNameWithoutExtension(fs.Name) & "_" & i & ".tif", New TiffEncoder(), Nothing)
    'dispose of uneeded image
    page.Dispose()
Next
See Also