StorageItemThumbnail Class
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.
Represents the thumbnail image associated with a system resource (like a file or folder).
public ref class StorageItemThumbnail sealed : IClosable, IRandomAccessStreamWithContentType
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
class StorageItemThumbnail final : IClosable, IRandomAccessStreamWithContentType
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public sealed class StorageItemThumbnail : System.IDisposable, IRandomAccessStreamWithContentType
Public NotInheritable Class StorageItemThumbnail
Implements IDisposable, IRandomAccessStreamWithContentType
- Inheritance
- Attributes
- Implements
Windows requirements
Device family |
Windows 10 (introduced in 10.0.10240.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v1.0)
|
Examples
This example demonstrates how to get thumbnails for files.
// Set query options with filter and sort order for results
List<string> fileTypeFilter = new List<string>();
fileTypeFilter.Add(".jpg");
fileTypeFilter.Add(".png");
fileTypeFilter.Add(".bmp");
fileTypeFilter.Add(".gif");
var queryOptions = new QueryOptions(CommonFileQuery.OrderByName, fileTypeFilter);
// Create query and retrieve files.
var query = KnownFolders.PicturesLibrary.CreateFileQueryWithOptions(queryOptions);
IReadOnlyList<StorageFile> fileList = await query.GetFilesAsync();
// Process results
foreach (StorageFile file in fileList)
{
// Get thumbnail
const uint requestedSize = 190;
const ThumbnailMode thumbnailMode = ThumbnailMode.PicturesView;
const ThumbnailOptions thumbnailOptions = ThumbnailOptions.UseCurrentScale;
var thumbnail = await file.GetThumbnailAsync(thumbnailMode, requestedSize, thumbnailOptions);
}
After GetThumbnailAsync completes, thumbnail gets a StorageItemThumbnail object.
In the example, the file
variable gets a StorageFile that represents each file that we want to retrieve a thumbnail for. We used a query to obtain StorageFile objects for these files (stored in the file
variable), but you can use whatever approach is best for your app to obtain StorageFile objects (like through the file picker).
Remarks
You can get thumbnails for many file system resources through the Windows Runtime objects that represent them. Many of these objects have methods or properties that let you get (and sometimes set) a StorageItemThumbnail that represents the thumbnail associated with a particular resource.
To find out how to get thumbnail for a particular Windows Runtime object, see the documentation for that object. For example, to get a thumbnail for a file you can call one of the StorageFile.getThumbnailAsync methods, or to get a thumbnail for a contact you can use the Contact.thumbnail property.
For more code samples about retrieving thumbnails, see the Folder enumeration sample and the File thumbnails sample.
Properties
CanRead |
Gets a value that indicates whether the thumbnail stream can be read from. |
CanWrite |
Gets a value that indicates whether the thumbnail stream can be written to. |
ContentType |
Gets the MIME content type of the thumbnail image. |
OriginalHeight |
Gets the original (not scaled) height of the thumbnail image. |
OriginalWidth |
Gets the original (not scaled) width of the thumbnail image. |
Position |
Gets the byte offset of the thumbnail stream. |
ReturnedSmallerCachedSize |
Gets a value that indicates whether the thumbnail image returned was a cached version with a smaller size. |
Size |
Gets or sets the size of the thumbnail image. |
Type |
Gets a value that indicates if the thumbnail is an icon or an image. |
Methods
CloneStream() |
Creates a new stream over the thumbnail that is represented by the current storageItemThumbnail object. |
Close() |
Releases system resources that are exposed by a Windows Runtime object. |
Dispose() |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
FlushAsync() |
Flushes data asynchronously in a sequential stream. |
GetInputStreamAt(UInt64) |
Retrieves the thumbnail image data as an undecoded stream. |
GetOutputStreamAt(UInt64) |
Retrieves an output stream object for writing thumbnail image data to a storage item. |
ReadAsync(IBuffer, UInt32, InputStreamOptions) |
Returns an asynchronous byte reader object. |
Seek(UInt64) |
Sets the offset of the thumbnail stream to the specified value. |
WriteAsync(IBuffer) |
Writes data asynchronously in a sequential stream. |