The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

BmpBitmapEncoder Class

Defines an encoder that is used to encode bitmap (BMP) format images.

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

public sealed class BmpBitmapEncoder : BitmapEncoder
public final class BmpBitmapEncoder extends BitmapEncoder
public final class BmpBitmapEncoder extends BitmapEncoder
<BmpBitmapEncoder .../>

Bitmap (BMP) format does not support features that are supported by other bitmap formats, including global preview, global thumbnail, global metadata, frame level thumbnails, multiple frames, and frame level metadata.

Encoding does not work in partial trust. See the Windows Presentation Foundation Partial Trust Programming topic for information on partial trust.

The following example demonstrates how to use the BmpBitmapEncoder to encode a new bitmap image.

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

// Try creating a new image with a custom palette.
List<System.Windows.Media.Color> colors = new List<System.Windows.Media.Color>();
BitmapPalette myPalette = new BitmapPalette(colors);

// Creates a new empty image with the pre-defined palette
BitmapSource image = BitmapSource.Create(

FileStream stream = new FileStream("new.bmp", FileMode.Create);
BmpBitmapEncoder encoder = new BmpBitmapEncoder();
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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft