Skip to content

Latest commit

 

History

History
74 lines (52 loc) · 3.06 KB

bitmapdecoder.md

File metadata and controls

74 lines (52 loc) · 3.06 KB
-api-id -api-type
T:Windows.Graphics.Imaging.BitmapDecoder
winrt class

Windows.Graphics.Imaging.BitmapDecoder

-description

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

-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

-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();
}

-see-also

Animated GIF playback (XAML) sample (Windows 10), OCR sample (Windows 10), Camera resolution sample (Windows 10), Basic camera app sample (Windows 10), Video stabilization sample (Windows 10), Camera face detection sample (Windows 10), Manual camera controls sample (Windows 10), High dynamic range sample (Windows 10), Camera Advanced Capture sample