WmpBitmapDecoder Class
Defines a decoder for Microsoft Windows Media Photo encoded images.
Assembly: PresentationCore (in PresentationCore.dll)
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 Dim imageStreamSource As New FileStream("tulipfarm.wdp", FileMode.Open, FileAccess.Read, FileShare.Read) Dim decoder As New WmpBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default) Dim bitmapSource As BitmapSource = decoder.Frames(0) ' Draw the Image Dim myImage As 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.
Dim width As Integer = 128 Dim height As Integer = width Dim stride As Integer = CType(width / 8, Integer) Dim pixels(height * stride) As Byte ' Define the image palette Dim myPalette As BitmapPalette = BitmapPalettes.WebPalette ' Creates a new empty image with the pre-defined palette Dim image As BitmapSource = System.Windows.Media.Imaging.BitmapSource.Create( _ width, height, 96, 96, PixelFormats.Indexed1, myPalette, pixels, stride) Dim stream As New FileStream("new.wdp", FileMode.Create) Dim encoder As New WmpBitmapEncoder() Dim myTextBlock As New TextBlock() myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString() encoder.Frames.Add(BitmapFrame.Create(image)) encoder.Save(stream)
System.Windows.Threading.DispatcherObject
System.Windows.Media.Imaging.BitmapDecoder
System.Windows.Media.Imaging.WmpBitmapDecoder
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.