StorageFolder.GetThumbnailAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
GetThumbnailAsync(ThumbnailMode, UInt32, ThumbnailOptions) |
Gets a thumbnail image for the current folder, sized for the specified purpose of the thumbnail and adjusted to the requested size with the specified options. |
GetThumbnailAsync(ThumbnailMode, UInt32) |
Gets a thumbnail image for the current folder, sized for the specified purpose of the thumbnail and adjusted to the requested size. |
GetThumbnailAsync(ThumbnailMode) |
Gets a thumbnail image for the current folder, sized for the specified purpose of the thumbnail. |
GetThumbnailAsync(ThumbnailMode, UInt32, ThumbnailOptions)
Gets a thumbnail image for the current folder, sized for the specified purpose of the thumbnail and adjusted to the requested size with the specified options.
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)
Parameters
- mode
- ThumbnailMode
A value from the enumeration that describes the purpose of the thumbnail and determines how the thumbnail image is adjusted.
For guidance about choosing the best thumbnail mode, see Guidelines and checklist for thumbnails.
- requestedSize
-
UInt32
unsigned int
uint32_t
The requested size, in pixels, of the longest edge of the thumbnail. This method uses the requestedSize as a guide and tries to scale the thumbnail image without reducing the quality of the image.
If this method can't find a thumbnail image that it can scale to the requested size, it may return a larger thumbnail. If no larger thumbnail is available, it may return a thumbnail image that is smaller than the requested size.
- options
- ThumbnailOptions
A value from the enumeration that specifies how to retrieve and size the image. The default value, UseCurrentScale, is suitable for most apps.
Returns
When this method completes successfully, it returns a StorageItemThumbnail that represents the thumbnail image, or null if there is no thumbnail image associated with the folder.
Implements
- Attributes
See also
Applies to
GetThumbnailAsync(ThumbnailMode, UInt32)
Gets a thumbnail image for the current folder, sized for the specified purpose of the thumbnail and adjusted to the requested size.
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)
Parameters
- mode
- ThumbnailMode
A value from the enumeration that describes the purpose of the thumbnail and determines how the thumbnail image is adjusted.
For guidance about choosing the best thumbnail mode, see Guidelines and checklist for thumbnails.
- requestedSize
-
UInt32
unsigned int
uint32_t
The requested size, in pixels, of the longest edge of the thumbnail. This method uses the requestedSize as a guide and tries to scale the thumbnail image without reducing the quality of the image.
If this method can't find a thumbnail image that it can scale to the requested size, it may return a larger thumbnail. If no larger thumbnail is available, it may return a thumbnail image that is smaller than the requested size.
Returns
When this method completes successfully, it returns a StorageItemThumbnail that represents the thumbnail image, or null if there is no thumbnail image associated with the folder.
Implements
- Attributes
See also
Applies to
GetThumbnailAsync(ThumbnailMode)
Gets a thumbnail image for the current folder, sized for the specified purpose of the thumbnail.
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)
Parameters
- mode
- ThumbnailMode
A value from the enumeration that describes the purpose of the thumbnail and determines how the thumbnail image is adjusted.
For guidance about choosing the best thumbnail mode, see Guidelines and checklist for thumbnails.
Returns
When this method completes successfully, it returns a StorageItemThumbnail that represents the thumbnail image, or null if there is no thumbnail image associated with the folder.
Implements
- Attributes
Examples
The following example gets a thumbnail image for the user's Pictures folder and displays the thumbnail in an Image control. This example also requests an image whose longest side is 64 pixels, and requests the image only if it's already cached on the device. The example assumes that there's an Image control named ImageControl on the current page.
Before you run the following example, enable the Pictures Library capability in the app manifest file.
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;
Remarks
For a sample that demonstrates the GetThumbnailAsync method, see File and folder thumbnail sample.
For guidance about choosing the best thumbnail mode, see Guidelines and checklist for thumbnails.
The StorageFolder.GetThumbnailAsync method sometimes returns the default image of a folder. For Windows Phone 8.x app, this method ignores the current theme when it returns this default image. The image returned is always the image for the dark theme; that is, the folder is transparent with a white border. If you want to return the image for the light theme, you have to create your own image that's visible on a light background. Then you have to use conditional logic to check the active theme. If the active theme is the light theme, use a method other than GetThumbnailAsync to retrieve your custom image.