This documentation is archived and is not being maintained.

WmpBitmapDecoder Class

Defines a decoder for Microsoft Windows Media Photo encoded images. 

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

public sealed class WmpBitmapDecoder : BitmapDecoder
You cannot directly create an instance of this class in XAML.

Microsoft Windows Media Photo is a new codec that provides better image fidelity than JPEG with smaller file sizes and more features. Windows Media Photo images achieve lossy and lossless compression by using a single algorithm. Windows Media Photo images support existing metadata standards. For additional information about this format, see the Windows Media Photo Specification.

The following examples show how to decode and encode a Microsoft Windows Media Photo image using the specific WmpBitmapDecoder and WmpBitmapEncoder objects. For the complete sample, see WDP Encoder and Decoder Sample.

This example demonstrates how to decode a Windows Media Photo image using a WmpBitmapDecoder from a Uri.

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

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

This example demonstrates how to encode a BitmapSource into a Windows Media Photo image using a WmpBitmapEncoder.

int width = 128;
int height = width;
int stride = width / 8;
byte[] pixels = new byte[height * stride];

// Define the image palette
BitmapPalette myPalette = BitmapPalettes.WebPalette;

// Creates a new empty image with the pre-defined palette

BitmapSource image = BitmapSource.Create(

FileStream stream = new FileStream("new.wdp", FileMode.Create);
WmpBitmapEncoder encoder = new WmpBitmapEncoder();
TextBlock myTextBlock = new TextBlock();
myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString();

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