导出 (0) 打印
全部展开
信息
您所需的主题如下所示。但此主题未包含在此库中。

StorageItemThumbnail Class

表示与系统资源关联的缩略图图象(如文件或文件夹)。

语法


/* 有关创建或访问此对象的信息,请参见“备注”。 */

特性

[Version(0x06020000)]

成员

StorageItemThumbnail类 具有这些类型的成员:

方法

The StorageItemThumbnail 类 具有这些方法。 对于 C#、Visual Basic 和 C++,它还继承方法于Object 类.

方法说明
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.

 

属性

StorageItemThumbnail类 具有这些属性。

属性访问类型说明

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.

 

备注

通过表示其的 Windows 运行时对象可以获取许多文件系统资源的访问。其中很多对象具有让您能够获取(有时设置)表示与某个资源关联的缩略图的 StorageItemThumbnail

要了解如何获取特定 Windows 运行时对象的缩略图,请参见对象文档。例如,要获取文件的缩略图,可以调用一个 StorageFile.getThumbnailAsync 方法,或者获取可以使用 Contact.thumbnail 属性的联系人的缩略图。

有关检索缩略图的更多代码示例,请参见文件夹枚举文件缩略图示例

示例

此示例演示如何获得文件的缩略图。



// Set query options with filter and sort order for results
var fileTypeFilter = [".jpg", ".png", ".bmp", ".gif"];
var queryOptions = new Windows.Storage.Search.QueryOptions(search.CommonFileQuery.orderByName, fileTypeFilter);

// Create query and retrieve files
var query = Windows.Storage.KnownFolders.picturesLibrary.createFileQueryWithOptions(queryOptions);
query.getFilesAsync().done(function (files) {
    // Process results
    files.forEach(function (file) {
        // Get thumbnail
        var requestedSize = 190;
        var thumbnailMode = Windows.Storage.FileProperties.ThumbnailMode.picturesView;
        var thumbnailOptions = Windows.Storage.FileProperties.ThumbnailOptions.useCurrentScale;
        item.getThumbnailAsync(thumbnailMode, requestedSize, thumbnailOptions).done(function (thumbnail) {
            // Perform tasks with thumnail
        });
    });
});

GetThumbnailAsync 完成后,缩略图将获取 StorageItemThumbnail 对象。

在此示例中,file 变量获取表示我们想要为其检索缩略图的每个文件的 StorageFile。我们使用查询获得这些文件的 StorageFile 对象(存储在 file 变量),但是,可以使用任意应用程序的最佳方法来获取 StorageFile 对象(如通过文件选择器)。

要求

最低支持客户端

Windows 8 [仅 Windows 应用商店应用程序]

最低支持服务器

Windows Server 2012 [仅 Windows 应用商店应用程序]

最低支持电话

Windows Phone 8

命名空间

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

元数据

Windows.winmd

另请参见

StorageFile

 

 

显示:
© 2014 Microsoft