Files
TheXamlGuy/Media/Capture/LowLagPhotoCapture.cs
T
2022-11-01 15:26:08 +00:00

22 lines
575 B
C#

namespace TheXamlGuy.Media.Capture;
public class LowLagPhotoCapture : ILowLagPhotoCapture
{
private readonly IMediaFrameReader frameReader;
internal LowLagPhotoCapture(IMediaFrameReader frameReader)
{
this.frameReader = frameReader;
}
public async Task<CapturedPhoto?> CaptureAsync()
{
if (await frameReader.TryAcquireLatestFrameAsync() is MediaFrame frame)
{
return new CapturedPhoto(frame.Bitmap, frame.Width, frame.Height);
}
return await Task.FromResult<CapturedPhoto?>(default);
}
}