StorageItemThumbnail class

Applies to Windows and Windows Phone

Represents the thumbnail image associated with a system resource (like a file or folder).

Syntax


public sealed class StorageItemThumbnail : IRandomAccessStreamWithContentType,
    IRandomAccessStream,
    IDisposable,
    IInputStream,
    IOutputStream,
    IContentTypeProvider

Attributes

[Version(0x06020000)]

Members

The StorageItemThumbnail class has these types of members:

Methods

The StorageItemThumbnail class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
CloneStream Creates a new stream over the thumbnail that is represented by the current storageItemThumbnail object.
Close [C++, JavaScript]Releases system resources that are exposed by a Windows Runtime object.
Dispose [C#, VB]Performs tasks associated with freeing, releasing, or resetting unmanaged resources.
FlushAsync Flushes data asynchronously in a sequential stream.
GetInputStreamAt Retrieves the thumbnail image data as an undecoded stream.
GetOutputStreamAt Retrieves an output stream object for writing thumbnail image data to a storage item.
ReadAsync Returns an asynchronous byte reader object.
Seek Sets the offset of the thumbnail stream to the specified value.
WriteAsync Writes data asynchronously in a sequential stream.

 

Properties

The StorageItemThumbnail class has these properties.

PropertyAccess typeDescription

CanRead

Read-onlyGets a value that indicates whether the thumbnail stream can be read from.

CanWrite

Read-onlyGets a value that indicates whether the thumbnail stream can be written to.

ContentType

Read-onlyGets the MIME content type of the thumbnail image.

OriginalHeight

Read-onlyGets the original (not scaled) height of the thumbnail image.

OriginalWidth

Read-onlyGets the original (not scaled) width of the thumbnail image.

Position

Read-onlyGets the byte offset of the thumbnail stream.

ReturnedSmallerCachedSize

Read-onlyGets a value that indicates whether the thumbnail image returned was a cached version with a smaller size.

Size

Read/writeGets or sets the size of the thumbnail image.

Type

Read-onlyGets a value that indicates if the thumbnail is an icon or an image.

 

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.

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).

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8

Namespace

Windows.Storage.FileProperties
Windows::Storage::FileProperties [C++]

Metadata

Windows.winmd

See also

StorageFile

 

 

Show:
© 2014 Microsoft. All rights reserved.