BitmapDecoder Class

Definition

Provides read access to bitmap container data as well as data from the first frame.

public ref class BitmapDecoder sealed : IBitmapFrameWithSoftwareBitmap
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Static(Windows.Graphics.Imaging.IBitmapDecoderStatics, 65536, Windows.Foundation.UniversalApiContract)]
class BitmapDecoder sealed : IBitmapFrameWithSoftwareBitmap
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Static(Windows.Graphics.Imaging.IBitmapDecoderStatics, 65536, "Windows.Foundation.UniversalApiContract")]
class BitmapDecoder sealed : IBitmapFrameWithSoftwareBitmap
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Static(Windows.Graphics.Imaging.IBitmapDecoderStatics, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Static(Windows.Graphics.Imaging.IBitmapDecoderStatics2, 458752, "Windows.Foundation.UniversalApiContract")]
class BitmapDecoder sealed : IBitmapFrameWithSoftwareBitmap
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Static(typeof(Windows.Graphics.Imaging.IBitmapDecoderStatics), 65536, typeof(Windows.Foundation.UniversalApiContract))]
public sealed class BitmapDecoder : IBitmapFrameWithSoftwareBitmap
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Static(typeof(Windows.Graphics.Imaging.IBitmapDecoderStatics), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class BitmapDecoder : IBitmapFrameWithSoftwareBitmap
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Static(typeof(Windows.Graphics.Imaging.IBitmapDecoderStatics), 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Static(typeof(Windows.Graphics.Imaging.IBitmapDecoderStatics2), 458752, "Windows.Foundation.UniversalApiContract")]
public sealed class BitmapDecoder : IBitmapFrameWithSoftwareBitmap
Public NotInheritable Class BitmapDecoder
Implements IBitmapFrameWithSoftwareBitmap
Inheritance
BitmapDecoder
Attributes
Implements

Windows 10 requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

Here's a partial example of creating a decoder object. This example assumes you selected a file with Windows.Storage.Pickers.FileOpenPicker. For full instructions on selecting a file, creating an decoder, and decoding an image see Imaging

FileOpenPicker fileOpenPicker = new FileOpenPicker();
fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
fileOpenPicker.FileTypeFilter.Add(".jpg");
fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;

var inputFile = await fileOpenPicker.PickSingleFileAsync();

if (inputFile == null)
{
    // The user cancelled the picking operation
    return;
}

SoftwareBitmap softwareBitmap;

using (IRandomAccessStream stream = await inputFile.OpenAsync(FileAccessMode.Read))
{
    // Create the decoder from the stream
    BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);

    // Get the SoftwareBitmap representation of the file
    softwareBitmap = await decoder.GetSoftwareBitmapAsync();
}

Remarks

Image formats

BitmapDecoder can decode the following formats.

  • JPEG
  • PNG
  • GIF
  • TIFF
  • BMP
  • ICO
  • JPEG-XR
  • Any installed Camera raw formats by using the Microsoft Camera Codec Pack.

For a list of decoding formats, see the BitmapEncoder topic.

The BitmapDecoder class implements IBitmapFrame. It provides access to container data as well as data from the first frame. This allows applications to accomplish most common scenarios without needing to retrieve a separate BitmapFrame.

Version history

Windows version SDK version Value added
1809 17763 HeifDecoderId
1809 17763 WebpDecoderId

Properties

BitmapAlphaMode

The default alpha mode of the first frame.

BitmapContainerProperties

Provides access to the container bitmap properties.

BitmapPixelFormat

The pixel format that best fits the first frame.

BitmapProperties

A read-only view of the metadata within the first frame.

BmpDecoderId

The unique identifier of the BMP decoder.

DecoderInformation

Information about the bitmap decoder.

DpiX

The horizontal resolution of the first frame in dots per inch.

DpiY

The vertical resolution of the first frame in dots per inch.

FrameCount

The number of frames within the image file.

GifDecoderId

The unique identifier of the GIF decoder.

HeifDecoderId

The unique identifier of the HEIF decoder.

IcoDecoderId

The unique identifier of the ICO decoder.

JpegDecoderId

The unique identifier of the JPEG decoder.

JpegXRDecoderId

The unique identifier of the JPEG-XR decoder.

OrientedPixelHeight

The height of the first frame in pixels, after any EXIF orientation has been applied to the bitmap.

OrientedPixelWidth

The width of the first frame in pixels, after any EXIF orientation has been applied to the bitmap.

PixelHeight

The height of the first frame in pixels.

PixelWidth

The width of the first frame in pixels.

PngDecoderId

The unique identifier of the PNG decoder.

TiffDecoderId

The unique identifier of the TIFF decoder.

WebpDecoderId

The unique identifier of the WebP decoder.

Methods

CreateAsync(Guid, IRandomAccessStream)

Asynchronously creates a new BitmapDecoder using a specific bitmap codec and initializes it using a stream.

CreateAsync(IRandomAccessStream)

Asynchronously creates a new BitmapDecoder and initializes it using a stream.

GetDecoderInformationEnumerator()

The bitmap decoders installed on the system and information about them.

GetFrameAsync(UInt32)

Asynchronously retrieves a frame from the image file.

GetPixelDataAsync()

Asynchronously requests the pixel data for the frame.

GetPixelDataAsync(BitmapPixelFormat, BitmapAlphaMode, BitmapTransform, ExifOrientationMode, ColorManagementMode)

Asynchronously requests the pixel data for the frame using the specified parameters.

GetPreviewAsync()

Asynchronously returns a stream containing the preview image.

GetSoftwareBitmapAsync()

Asynchronously gets a SoftwareBitmap representation of the decoded bitmap.

GetSoftwareBitmapAsync(BitmapPixelFormat, BitmapAlphaMode)

Asynchronously gets a SoftwareBitmap representation of the decoded bitmap.

GetSoftwareBitmapAsync(BitmapPixelFormat, BitmapAlphaMode, BitmapTransform, ExifOrientationMode, ColorManagementMode)

Asynchronously gets a SoftwareBitmap representation of the decoded bitmap.

GetThumbnailAsync()

Asynchronously returns a stream containing the thumbnail image.

Applies to

See also