BitmapEncoder.Frames Property

Definition

Gets or sets the individual frames within an image.

C#
public virtual System.Collections.Generic.IList<System.Windows.Media.Imaging.BitmapFrame> Frames { get; set; }

Property Value

A collection of BitmapFrame objects within the image.

Exceptions

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

Examples

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

C#
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);

Remarks

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.

XAML Text Usage

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

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also