-api-id | -api-type |
---|---|
T:Windows.Graphics.Imaging.BitmapDecoder |
winrt class |
Provides read access to bitmap container data as well as data from the first frame.
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.
Windows version | SDK version | Value added |
---|---|---|
1809 | 17763 | HeifDecoderId |
1809 | 17763 | WebpDecoderId |
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();
}
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