Επεξεργασία

Κοινή χρήση μέσω


LateBoundBitmapDecoder.Frames Property

Definition

Gets the content of an individual frame within a bitmap.

public:
 virtual property System::Collections::ObjectModel::ReadOnlyCollection<System::Windows::Media::Imaging::BitmapFrame ^> ^ Frames { System::Collections::ObjectModel::ReadOnlyCollection<System::Windows::Media::Imaging::BitmapFrame ^> ^ get(); };
public override System.Collections.ObjectModel.ReadOnlyCollection<System.Windows.Media.Imaging.BitmapFrame> Frames { get; }
member this.Frames : System.Collections.ObjectModel.ReadOnlyCollection<System.Windows.Media.Imaging.BitmapFrame>
Public Overrides ReadOnly Property Frames As ReadOnlyCollection(Of BitmapFrame)

Property Value

An instance of BitmapFrame. This property has no default value.

Examples

The following example demonstrates how to use a BitmapFrame as a BitmapSource.


// 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);
' 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 myImage1 As New Image()
myImage1.Source = bitmapSource
myImage1.Stretch = Stretch.None
myImage1.Margin = New Thickness(20)

Remarks

Because a LateBoundBitmapDecoder is downloaded asynchronously, it is possible for the underlying collection of Frames to change after content is downloaded and decoded. While content is downloading, the collection always returns at least one item. When downloading and decoding are complete, the BitmapFrame automatically changes its underlying content. In other words, only the collection object can change; the actual frame object remains the same.

Any frame obtained from a LateBoundBitmapDecoder while the image is downloading will return a width/height of 1,1 until the frames have finished downloading.

Only Tagged Image File Format (TIFF) and Graphics Interchange Format (GIF) images support more than one frame.

Any BitmapFrame objects that this property returns are frozen.

Applies to

See also