BitmapEncoder.Frames Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the individual frames within an image.

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

public virtual IList<BitmapFrame> Frames { get; set; }

Property Value

Type: System.Collections.Generic.IList<BitmapFrame>

A collection of BitmapFrame objects within the image.

Exception Condition
ArgumentNullException

The BitmapFrame value that is passed to the encoder is null.

Only Tagged Image File Format (TIFF), Graphics Interchange Format (GIF), and Microsoft Windows Media Photo images support more than one frame. Attempts to add additional frames to formats that do not support them will result in only the first frame being encoded.

You cannot use this property in Extensible Application Markup Language (XAML).

The following example shows how to add a frame to an encoder.

FileStream stream = new FileStream("empty.tif", FileMode.Create);
TiffBitmapEncoder encoder = new TiffBitmapEncoder();
TextBlock myTextBlock = new TextBlock();
myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString();
encoder.Frames.Add(BitmapFrame.Create(image));
MessageBox.Show(myPalette.Colors.Count.ToString());
encoder.Save(stream);

.NET Framework
Available since 3.0
Return to top
Show: