StorageFolder.GetThumbnailAsync 方法

定義

多載

GetThumbnailAsync(ThumbnailMode, UInt32, ThumbnailOptions)

取得目前資料夾的縮圖影像,其大小為縮圖的指定用途,並使用指定的選項調整為所要求的大小。

GetThumbnailAsync(ThumbnailMode, UInt32)

取得目前資料夾的縮圖影像,其大小為縮圖的指定用途,並調整為要求的大小。

GetThumbnailAsync(ThumbnailMode)

取得目前資料夾的縮圖影像,其大小為縮圖的指定用途。

GetThumbnailAsync(ThumbnailMode, UInt32, ThumbnailOptions)

取得目前資料夾的縮圖影像,其大小為縮圖的指定用途,並使用指定的選項調整為所要求的大小。

public:
 virtual IAsyncOperation<StorageItemThumbnail ^> ^ GetThumbnailAsync(ThumbnailMode mode, unsigned int requestedSize, ThumbnailOptions options) = GetThumbnailAsync;
/// [Windows.Foundation.Metadata.Overload("GetThumbnailAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(ThumbnailMode const& mode, uint32_t const& requestedSize, ThumbnailOptions const& options);
[Windows.Foundation.Metadata.Overload("GetThumbnailAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(ThumbnailMode mode, uint requestedSize, ThumbnailOptions options);
function getThumbnailAsync(mode, requestedSize, options)
Public Function GetThumbnailAsync (mode As ThumbnailMode, requestedSize As UInteger, options As ThumbnailOptions) As IAsyncOperation(Of StorageItemThumbnail)

參數

mode
ThumbnailMode

列舉中的值,描述縮圖的用途,並決定縮圖影像的調整方式。

如需選擇最佳縮圖模式的指引,請參閱 縮圖的指導方針和檢查清單

requestedSize
UInt32

unsigned int

uint32_t

縮圖最長邊緣的要求大小,以圖元為單位。 此方法會使用 requestedSize 作為指南,並嘗試調整縮圖影像,而不需要減少影像的品質。

如果這個方法找不到可調整為所要求大小的縮圖影像,可能會傳回較大的縮圖。 如果沒有較大的縮圖可用,它可能會傳回小於要求大小的縮圖影像。

options
ThumbnailOptions

列舉中的值,指定如何擷取和調整影像大小。 預設值 UseCurrentScale適用于大部分的應用程式。

傳回

當此方法成功完成時,它會傳回代表縮圖影像的 StorageItemThumbnail ,如果沒有與資料夾相關聯的縮圖影像,則會傳回 null

實作

M:Windows.Storage.IStorageItemProperties.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions) M:Windows.Storage.IStorageItemProperties.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,unsigned int,Windows.Storage.FileProperties.ThumbnailOptions) M:Windows.Storage.IStorageItemProperties.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,uint32_t,Windows.Storage.FileProperties.ThumbnailOptions)
屬性

另請參閱

適用於

GetThumbnailAsync(ThumbnailMode, UInt32)

取得目前資料夾的縮圖影像,其大小為縮圖的指定用途,並調整為要求的大小。

public:
 virtual IAsyncOperation<StorageItemThumbnail ^> ^ GetThumbnailAsync(ThumbnailMode mode, unsigned int requestedSize) = GetThumbnailAsync;
/// [Windows.Foundation.Metadata.Overload("GetThumbnailAsyncOverloadDefaultOptions")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(ThumbnailMode const& mode, uint32_t const& requestedSize);
[Windows.Foundation.Metadata.Overload("GetThumbnailAsyncOverloadDefaultOptions")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(ThumbnailMode mode, uint requestedSize);
function getThumbnailAsync(mode, requestedSize)
Public Function GetThumbnailAsync (mode As ThumbnailMode, requestedSize As UInteger) As IAsyncOperation(Of StorageItemThumbnail)

參數

mode
ThumbnailMode

列舉中的值,描述縮圖的用途,並決定縮圖影像的調整方式。

如需選擇最佳縮圖模式的指引,請參閱 縮圖的指導方針和檢查清單

requestedSize
UInt32

unsigned int

uint32_t

縮圖最長邊緣的要求大小,以圖元為單位。 此方法會使用 requestedSize 作為指南,並嘗試調整縮圖影像,而不需要減少影像的品質。

如果這個方法找不到可調整為所要求大小的縮圖影像,可能會傳回較大的縮圖。 如果沒有較大的縮圖可用,它可能會傳回小於要求大小的縮圖影像。

傳回

當此方法成功完成時,它會傳回代表縮圖影像的 StorageItemThumbnail ,如果沒有與資料夾相關聯的縮圖影像,則會傳回 null

實作

M:Windows.Storage.IStorageItemProperties.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32) M:Windows.Storage.IStorageItemProperties.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,unsigned int) M:Windows.Storage.IStorageItemProperties.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,uint32_t)
屬性

另請參閱

適用於

GetThumbnailAsync(ThumbnailMode)

取得目前資料夾的縮圖影像,其大小為縮圖的指定用途。

public:
 virtual IAsyncOperation<StorageItemThumbnail ^> ^ GetThumbnailAsync(ThumbnailMode mode) = GetThumbnailAsync;
/// [Windows.Foundation.Metadata.Overload("GetThumbnailAsyncOverloadDefaultSizeDefaultOptions")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(ThumbnailMode const& mode);
[Windows.Foundation.Metadata.Overload("GetThumbnailAsyncOverloadDefaultSizeDefaultOptions")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(ThumbnailMode mode);
function getThumbnailAsync(mode)
Public Function GetThumbnailAsync (mode As ThumbnailMode) As IAsyncOperation(Of StorageItemThumbnail)

參數

mode
ThumbnailMode

列舉中的值,描述縮圖的用途,並決定縮圖影像的調整方式。

如需選擇最佳縮圖模式的指引,請參閱 縮圖的指導方針和檢查清單

傳回

當此方法成功完成時,它會傳回代表縮圖影像的 StorageItemThumbnail ,如果沒有與資料夾相關聯的縮圖影像,則會傳回 null

實作

屬性

範例

下列範例會取得使用者 [圖片] 資料夾的縮圖影像,並在 [影像 ] 控制項中顯示縮圖。 本範例也會要求最長一邊為 64 圖元的影像,而且只有在裝置上快取影像時才要求影像。 此範例假設目前頁面上有一個名為 ImageControl 的 Image 控制項。

執行下列範例之前,請在應用程式資訊清單檔案中啟用 圖片庫 功能。

using Windows.Storage;
using Windows.Storage.FileProperties;
using System.Threading.Tasks;
using Windows.UI.Xaml.Media.Imaging; // For the Bitmap object.

// Get the user's Pictures folder.
// Enable the corresponding capability in the app manifest file.
StorageFolder picturesFolder = KnownFolders.PicturesLibrary;

// Get a thumbnail for the current folder.
StorageItemThumbnail thumb =
    await picturesFolder.GetThumbnailAsync(ThumbnailMode.SingleItem,
    64, ThumbnailOptions.ReturnOnlyIfCached);

// Display the thumbnail in an Image control
// named ImageControl on the current page.
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(thumb);
ImageControl.Source = bitmapImage;

備註

如需示範 GetThumbnailAsync 方法的範例,請參閱 檔案和資料夾縮圖範例

如需選擇最佳縮圖模式的指引,請參閱 縮圖的指導方針和檢查清單

StorageFolder.GetThumbnailAsync方法有時會傳回資料夾的預設影像。 針對 Windows Phone 8.x 應用程式,此方法會在傳回此預設影像時忽略目前的主題。 傳回的影像一律是深色主題的影像;也就是說,資料夾是透明且具有白色框線。 如果您想要傳回淺色主題的影像,您必須建立自己的影像,以在淺色背景上顯示。 然後您必須使用條件式邏輯來檢查使用中主題。 如果使用中主題是淺色主題,請使用 GetThumbnailAsync 以外的方法來擷取您的自訂影像。

另請參閱

適用於