BitmapDecoder Class

BitmapDecoder Class

 

Represents a container for bitmap frames. Each bitmap frame is a BitmapSource. This abstract class provides a base set of functionality for all derived decoder objects.

Namespace:   System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)


public abstract class BitmapDecoder : DispatcherObject

NameDescription
System_CAPS_protmethodBitmapDecoder()

Initializes a new instance of BitmapDecoder.

NameDescription
System_CAPS_pubpropertyCodecInfo

Gets information that describes this codec.

System_CAPS_pubpropertyColorContexts

Gets a value that represents the color profile associated with a bitmap, if one is defined.

System_CAPS_pubpropertyDispatcher

Gets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)

System_CAPS_pubpropertyFrames

Gets the content of an individual frame within a bitmap.

System_CAPS_pubpropertyIsDownloading

Gets a value that indicates if the decoder is currently downloading content.

System_CAPS_pubpropertyMetadata

Gets an instance of BitmapMetadata that represents the global metadata associated with this bitmap, if metadata is defined.

System_CAPS_pubpropertyPalette

Gets the BitmapPalette associated with this decoder.

System_CAPS_pubpropertyPreview

Gets a BitmapSource that represents the global preview of this bitmap, if one is defined.

System_CAPS_pubpropertyThumbnail

Gets a BitmapSource that represents the thumbnail of the bitmap, if one is defined.

NameDescription
System_CAPS_pubmethodCheckAccess()

Determines whether the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.)

System_CAPS_pubmethodSystem_CAPS_staticCreate(Stream, BitmapCreateOptions, BitmapCacheOption)

Creates a BitmapDecoder from a Stream by using the specified BitmapCreateOptions and BitmapCacheOption.

System_CAPS_pubmethodSystem_CAPS_staticCreate(Uri, BitmapCreateOptions, BitmapCacheOption)

Creates a BitmapDecoder from a Uri by using the specified BitmapCreateOptions and BitmapCacheOption.

System_CAPS_pubmethodSystem_CAPS_staticCreate(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)

Creates a BitmapDecoder from a Uri by using the specified BitmapCreateOptions, BitmapCacheOption and RequestCachePolicy.

System_CAPS_pubmethodCreateInPlaceBitmapMetadataWriter()

Creates an instance of InPlaceBitmapMetadataWriter, which can be used to update the metadata of a bitmap.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Frees resources and performs other cleanup operations before the BitmapDecoder is reclaimed by garbage collection. (Overrides Object.Finalize().)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Converts the current value of a BitmapDecoder to a String.(Overrides Object.ToString().)

System_CAPS_pubmethodVerifyAccess()

Enforces that the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.)

NameDescription
System_CAPS_pubeventDownloadCompleted

Occurs when a BitmapDecoder has finished downloading bitmap content.

System_CAPS_pubeventDownloadFailed

Occurs when bitmap content failed to download.

System_CAPS_pubeventDownloadProgress

Occurs when a BitmapDecoder has made progress downloading bitmap content.

BitmapDecoder is not a BitmapFrame itself; rather, it is a container for BitmapFrame objects. Each BitmapFrame in the container can potentially have different attributes, including different sizes, resolutions, or palettes.

Unless a specific codec is selected, Windows Presentation Foundation (WPF) uses automatic run-time discovery to identify the format of an image and match it with the appropriate codec. This discovery process allows a codec developed by an independent software vendor (ISV) to be automatically discoverable by the system. To select a specific codec, the derived BitmapDecoder or BitmapEncoder, such as the TiffBitmapDecoder class, should be used.

Tagged Image File Format (TIFF) and Graphics Interchange Format (GIF) are the only implemented image formats that support multiple frames.

The following example demonstrates how to use the Create(Uri, BitmapCreateOptions, BitmapCacheOption) method to create a decoder for a given image. The first BitmapFrame of the image is used as the source of an Image control.

BitmapDecoder uriBitmap = BitmapDecoder.Create(
   new Uri("sampleImages/waterlilies.jpg", UriKind.Relative),
   BitmapCreateOptions.None,
   BitmapCacheOption.Default);

// Create an image element;
Image uriImage = new Image();
uriImage.Width = 200;
// Set image source.
uriImage.Source = uriBitmap.Frames[0];

The following code example demonstrates how to use the built in TiffBitmapDecoder to open and decode a Tagged Image File Format (TIFF) bitmap. The resulting BitmapSource is used as the Source of an Image element.


// Open a Stream and decode a TIFF image
Stream imageStreamSource = new FileStream("tulipfarm.tif", FileMode.Open, FileAccess.Read, FileShare.Read);
TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource bitmapSource = decoder.Frames[0];

// Draw the Image
Image myImage1 = new Image();
myImage1.Source = bitmapSource;
myImage1.Stretch = Stretch.None;
myImage1.Margin = new Thickness(20);

.NET Framework
Available since 3.0

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

Return to top
Show:
© 2016 Microsoft