BitmapDecoder 類別

定義

提供點陣圖容器資料的讀取權限,以及第一個框架中的資料。

public ref class BitmapDecoder sealed : IBitmapFrameWithSoftwareBitmap
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class BitmapDecoder final : IBitmapFrameWithSoftwareBitmap
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class BitmapDecoder : IBitmapFrameWithSoftwareBitmap
Public NotInheritable Class BitmapDecoder
Implements IBitmapFrameWithSoftwareBitmap
繼承
Object Platform::Object IInspectable BitmapDecoder
屬性
實作

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

以下是建立解碼器物件的部分範例。 此範例假設您已選取 Windows.Storage.Pickers.FileOpenPicker 的檔案。 如需有關選取檔案、建立解碼器和解碼影像的完整指示,請參閱 映射處理

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

備註

影像格式

BitmapDecoder 可以解碼下列格式。

  • JPEG
  • PNG
  • GIF
  • TIFF
  • BMP
  • ICO
  • JPEG-XR
  • 任何已安裝的相機原始格式,方法是使用 Microsoft 數位相機編解碼器套件。

如需解碼格式的清單,請參閱 BitmapEncoder 主題。

BitmapDecoder 類別會實作 IBitmapFrame。 它可讓您存取容器資料,以及來自第一個框架的資料。 這可讓應用程式完成最常見的案例,而不需要擷取個別 的 BitmapFrame

版本歷程記錄

Windows 版本 SDK 版本 已新增值
1809 17763 HeifDecoderId
1809 17763 WebpDecoderId

屬性

BitmapAlphaMode

第一個畫面的預設 Alpha 模式。

BitmapContainerProperties

提供容器點陣圖屬性的存取權。

BitmapPixelFormat

最適合第一個畫面的像素格式。

BitmapProperties

第一個框架內中繼資料的唯讀檢視。

BmpDecoderId

BMP 解碼器的唯一識別碼。

DecoderInformation

點陣圖解碼器的相關資訊。

DpiX

第一個框架的水準解析度,以每英吋點為單位。

DpiY

第一個框架的垂直解析度,以每英吋點為單位。

FrameCount

影像檔案內的框架數目。

GifDecoderId

GIF 解碼器的唯一識別碼。

HeifDecoderId

HEIF 解碼器的唯一識別碼。

IcoDecoderId

ICO 解碼器的唯一識別碼。

JpegDecoderId

JPEG 解碼器的唯一識別碼。

JpegXRDecoderId

JPEG-XR 解碼器的唯一識別碼。

OrientedPixelHeight

任何 EXIF 方向都套用至點陣圖之後,以圖元為單位的第一個框架高度。

OrientedPixelWidth

任何 EXIF 方向都套用至點陣圖之後,以圖元為單位的第一個畫面寬度。

PixelHeight

第一個框架的高度,以圖元為單位。

PixelWidth

第一個框架的寬度,以圖元為單位。

PngDecoderId

PNG 解碼器的唯一識別碼。

TiffDecoderId

TIFF 解碼器的唯一識別碼。

WebpDecoderId

WebP 解碼器的唯一識別碼。

方法

CreateAsync(Guid, IRandomAccessStream)

以非同步方式使用特定的位 圖編解碼器建立新的 BitmapDecoder ,並使用資料流程初始化它。

CreateAsync(IRandomAccessStream)

以非同步方式建立新的 BitmapDecoder ,並使用資料流程初始化它。

GetDecoderInformationEnumerator()

安裝在系統上的點陣圖解碼器及其相關資訊。

GetFrameAsync(UInt32)

以非同步方式從影像檔擷取框架。

GetPixelDataAsync()

以非同步方式要求框架的圖元資料。

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

使用指定的參數,以非同步方式要求框架的圖元資料。

GetPreviewAsync()

以非同步方式傳回包含預覽影像的資料流程。

GetSoftwareBitmapAsync()

以非同步方式取得解碼點陣圖的 SoftwareBitmap 標記法。

GetSoftwareBitmapAsync(BitmapPixelFormat, BitmapAlphaMode)

以非同步方式取得解碼點陣圖的 SoftwareBitmap 標記法。

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

以非同步方式取得解碼點陣圖的 SoftwareBitmap 標記法。

GetThumbnailAsync()

以非同步方式傳回包含縮圖影像的資料流程。

適用於

另請參閱