This documentation is archived and is not being maintained.

TiffBitmapEncoder Class

Defines an encoder that is used to encode Tagged Image File Format (TIFF) format images.

Namespace:  System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

'Declaration
Public NotInheritable Class TiffBitmapEncoder _
	Inherits BitmapEncoder
'Usage
Dim instance As TiffBitmapEncoder
This managed class is not typically used in XAML.

The Tagged Image File Format (TIFF) bitmap format supports frame level thumbnails, multiple frames, and frame level metadata. It does not support global preview, global thumbnails, or global metadata.

Encoding does not work in partial trust. See Windows Presentation Foundation Partial Trust Security for information on partial trust.

The following examples show how to decode and encode a Tagged Image File Format (TIFF) image using the specific TiffBitmapDecoder and TiffBitmapEncoder objects. For the complete sample, see TIFF Encoder and Decoder Sample

This example demonstrates how to decode a TIFF image using a TiffBitmapDecoder from a Uri.

' Open a Stream and decode a TIFF image 
Dim imageStreamSource As New FileStream("tulipfarm.tif", FileMode.Open, FileAccess.Read, FileShare.Read)
Dim decoder As New TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default)
Dim bitmapSource As BitmapSource = decoder.Frames(0)

' Draw the Image 
Dim myImage As New Image()
myImage.Source = bitmapSource
myImage.Stretch = Stretch.None
myImage.Margin = New Thickness(20)

This example demonstrates how to encode a BitmapSource into a TIFF image using a TiffBitmapEncoder.

Dim width As Integer = 128
Dim height As Integer = width
Dim stride As Integer = CType(width / 8, Integer)
Dim pixels(height * stride) As Byte

' Define the image palette 
Dim myPalette As BitmapPalette = BitmapPalettes.WebPalette

' Creates a new empty image with the pre-defined palette 
Dim image As BitmapSource = System.Windows.Media.Imaging.BitmapSource.Create( _
    width, height, 96, 96, PixelFormats.Indexed1, myPalette, pixels, stride)
Dim stream As New FileStream("new.tif", FileMode.Create)
Dim encoder As New TiffBitmapEncoder()
Dim myTextBlock As New TextBlock()
myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString()
encoder.Compression = TiffCompressOption.Zip
encoder.Frames.Add(BitmapFrame.Create(image))
encoder.Save(stream)

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Show: