mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 19:27:56 +01:00
* Add basics of VideoPreviewer to build on * WIP * Minimal working code, todo next:dimension + MTC * Nits * Change back to GetImageSize as it indeed doesn't work with videos * Add win32 helper methods to get video size; Refactor get size operation; * Remove unused code * Set VideoTask; Add message error for HR result; * Add open read only for filestream * Remove unused code * Update expect.txt * Remove comment * Cleanup code * Force pause videopreview on previewer change --------- Co-authored-by: Jojo Zhou <yizzho@microsoft.com> Co-authored-by: Yawen Hou <yawenhou@microsoft.com> Co-authored-by: Clint Rutkas <clint@rutkas.com> Co-authored-by: Yawen Hou <Sytta@users.noreply.github.com> Co-authored-by: Samuel Chapleau 🌈 <sachaple@microsoft.com>
32 lines
1.2 KiB
C#
32 lines
1.2 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using Peek.Common.WIC;
|
|
|
|
namespace Peek.FilePreviewer.Previewers
|
|
{
|
|
public static class WICHelper
|
|
{
|
|
public static Task<Windows.Foundation.Size> GetImageSize(string filePath)
|
|
{
|
|
return Task.Run(() =>
|
|
{
|
|
// TODO: Find a way to get file metadata without hydrating files. Look into Shell API/Windows Property System, e.g., IPropertyStore
|
|
IWICImagingFactory factory = (IWICImagingFactory)new WICImagingFactory();
|
|
var decoder = factory.CreateDecoderFromFilename(filePath, IntPtr.Zero, StreamAccessMode.GENERIC_READ, WICDecodeOptions.WICDecodeMetadataCacheOnLoad);
|
|
var frame = decoder?.GetFrame(0);
|
|
int width = 0;
|
|
int height = 0;
|
|
|
|
// TODO: Respect EXIF data and find correct orientation
|
|
frame?.GetSize(out width, out height);
|
|
|
|
return new Windows.Foundation.Size(width, height);
|
|
});
|
|
}
|
|
}
|
|
}
|