Export (0) Print
Expand All

WmpBitmapEncoder Class

Defines an encoder that is used to encode Microsoft Windows Media Photo images.

Namespace:  System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public sealed class WmpBitmapEncoder : BitmapEncoder

The WmpBitmapEncoder type exposes the following members.

  NameDescription
Public methodWmpBitmapEncoderInitializes a new instance of the WmpBitmapEncoder class.
Top

  NameDescription
Public propertyAlphaDataDiscardLevelGets or sets the level of alpha frequency data to discard during a compressed domain transcode.
Public propertyAlphaQualityLevelGets or sets the compression quality for a planar alpha channel.
Public propertyCodecInfoGets information that describes this codec. (Inherited from BitmapEncoder.)
Public propertyColorContextsGets or sets a value that represents the color profile that is associated with this encoder. (Inherited from BitmapEncoder.)
Public propertyCompressedDomainTranscodeGets or sets a value that indicates whether compressed domain operations can be used. Compressed domain operations are transformation operations that are done without decoding the image data.
Public propertyDispatcherGets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)
Public propertyFlipHorizontalGets or sets a value indicating whether to flip the image horizontally.
Public propertyFlipVerticalGets or sets a value that indicates whether to flip the image vertically.
Public propertyFramesGets or sets the individual frames within an image. (Inherited from BitmapEncoder.)
Public propertyFrequencyOrderGets or sets a value that indicates whether to encoding in frequency order.
Public propertyHorizontalTileSlicesGets or sets the number of horizontal divisions to use during compression encoding. A single division creates two horizontal regions.
Public propertyIgnoreOverlapGets or sets a value that indicates whether to ignore region overlap pixels in subregion compressed domain encoding. This feature is not currently implemented.
Public propertyImageDataDiscardLevelGets or sets the level of image data to discard during a compressed domain transcode.
Public propertyImageQualityLevelGets or sets the image quality level.
Public propertyInterleavedAlphaGets or sets a value that indicates whether to encode the alpha channel data as an additional interleaved channel.
Public propertyLosslessGets or sets a value that indicates whether to encode using lossless compression.
Public propertyMetadataGets or sets the metadata that will be associated with this bitmap during encoding. (Inherited from BitmapEncoder.)
Public propertyOverlapLevelGets or sets the overlap processing level.
Public propertyPaletteGets or sets a value that represents the BitmapPalette of an encoded bitmap. (Inherited from BitmapEncoder.)
Public propertyPreviewGets or sets a BitmapSource that represents the global preview of a bitmap, if there is one. (Inherited from BitmapEncoder.)
Public propertyQualityLevelGets or sets the compression quality for the main image.
Public propertyRotationGets or sets the Rotation of the image.
Public propertySubsamplingLevelGets or sets the sub-sampling level for RGB image encoding.
Public propertyThumbnailGets or sets a BitmapSource that represents the global embedded thumbnail. (Inherited from BitmapEncoder.)
Public propertyUseCodecOptionsGets or sets a value that indicates codec options are to be used.
Public propertyVerticalTileSlicesGets or sets the number of vertical divisions to use during compression encoding. A single division creates two vertical regions.
Top

  NameDescription
Public methodCheckAccessDetermines whether the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSaveEncodes a bitmap image to a specified Stream. (Inherited from BitmapEncoder.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodVerifyAccessEnforces that the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Top

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 Windows Media Photo Specification.

Windows Media Photo files do not support preview, global thumbnails, frame level thumbnails, or multiple frames.

Encoding does not work in partial trust. See WPF Partial Trust Security for information on partial trust.

The following examples show how to decode and encode a Microsoft Windows Media Photo image using the specific WmpBitmapDecoder and WmpBitmapEncoder objects.

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(
    width,
    height,
    96,
    96,
    PixelFormats.Indexed1,
    myPalette,
    pixels,
    stride);

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();
encoder.Frames.Add(BitmapFrame.Create(image));
encoder.Save(stream);

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft