uwp 高分辨率缩略图

uwp highresolution Thumbnail

我正在尝试将视频文件的缩略图放在更大的 xaml 元素上,例如:页面或网格的背景图像或页面上的顶部横幅。在这种情况下,我从以下代码中获得了正常的缩略图。看起来确实不错,因为它们的分辨率很低。

var imgSource = await MyVideoFile.GetScaledImageAsThumbnailAsync(ThumbnailMode.VideosView, 200, ThumbnailOptions.UseCurrentScale)

我想要高分辨率的缩略图。我应该将视频文件的帧提取为位图图像并使用它们吗?或者有没有办法获得特定尺寸的高分辨率缩略图?

Should I extract out the frames of the video file as Bitmap Images and use them?or is therea way of getting a high resolution Thumbnail of a specific size?

这取决于您的要求。但根据你的描述,你可能不需要这样做。

我检查了你的代码。您已将固定值 200 设置为 requiredSize。请阅读 GetScaledImageAsThumbnailAsync(ThumbnailMode, UInt32, ThumbnailOptions) 方法的文档。它显示:

The requested size, in pixels, of the longest edge of the thumbnail. Windows uses the requestedSize as a guide and tries to scale the thumbnail image without reducing the quality of the image.

表示"requiredSize"应该是StorageItemThumbnail对象的原始宽度。然后,在你原来的post中,你说:

I am trying to put the Thumbnail of video files on bigger xaml elements like : background Image of a page or grid or a top banner on the page.

如果 xaml 元素的大小比 StorageItemThumbnail 对象的原始大小大得多,那么它总是看起来很糟糕。

所以,我建议您可以通过较大元素的大小将动态 "requiredSize" 传递给 GetScaledImageAsThumbnailAsync 方法,然后它会 return 一个具有适合您的分辨率的缩略图.

例如:

var imgSource = await MyVideoFile.GetScaledImageAsThumbnailAsync(ThumbnailMode.VideosView, bigelement.Width, ThumbnailOptions.UseCurrentScale)

文档最后还说:

If Windows can't find a thumbnail image that it can scale to meet the requested size, a larger thumbnail might be returned. If no larger thumbnail is available, a thumbnail image that is smaller than the requested size might be returned.

如果您遇到这种情况,您可以考虑像您所说的那样将视频文件的帧提取为位图图像。