LowLagPhotoCapture.FinishAsync 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
异步释放捕获照片操作使用的 LowLagPhotoCapture 对象和资源。
public:
virtual IAsyncAction ^ FinishAsync() = FinishAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncAction FinishAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncAction FinishAsync();
function finishAsync()
Public Function FinishAsync () As IAsyncAction
返回
用于控制异步操作的对象。
- 属性
示例
以下示例演示如何设置和拍摄低延迟照片。 它在 Image 对象中显示捕获的照片和缩略图。 XAML 创建一个包含两个 Image 对象和一些 Button 对象的简单 UI,以便与 MediaCapture 元素交互。 在代码中,有一个用于初始化 MediaCapture 对象的方法、一个初始化 LowLagPhotoCapture 对象的方法、一个用于拍摄照片并显示它的方法,以及一个用于关闭 LowLagPhotoCapture 的方法。
<StackPanel Orientation="Horizontal">
<Image x:Name="imageLowLagPhoto" Stretch="None"
Width="320" Height="240" />
<Image x:Name="imageLowLagThumbnail" Stretch="None"
Width="320" Height="240" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Click="InitMediaCapture_Click" Content="Initialize Camera" />
<Button Click="InitLowLagPhotoCapture_Click" Content="Initialize Low Lag Photo Capture"/>
<Button Click="CaptureLagPhotoCapture_Click" Content="Capture Low Lag Photo"/>
<Button Click="CloseLagPhotoCapture_Click" Content="Finish low Lag Capture"/>
</StackPanel>
LowLagPhotoCapture lowLagCaptureMgr = null;
MediaCapture mediaCaptureManager;
async private void InitMediaCapture_Click(object sender, RoutedEventArgs e)
{
mediaCaptureManager = new MediaCapture();
await mediaCaptureManager.InitializeAsync();
}
async private void InitLowLagPhotoCapture_Click(object sender, RoutedEventArgs e)
{
// Enable thumbnail images
mediaCaptureManager.VideoDeviceController.LowLagPhoto.ThumbnailEnabled = true;
mediaCaptureManager.VideoDeviceController.LowLagPhoto.ThumbnailFormat = MediaThumbnailFormat.Bmp;
mediaCaptureManager.VideoDeviceController.LowLagPhoto.DesiredThumbnailSize = 25;
// Image properties
ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();
// Create LowLagPhotoCapture object
lowLagCaptureMgr = await mediaCaptureManager.PrepareLowLagPhotoCaptureAsync(imgFormat);
}
async private void CaptureLagPhotoCapture_Click(object sender, RoutedEventArgs e)
{
// Take photo
CapturedPhoto photo = await lowLagCaptureMgr.CaptureAsync();
// Get photo as a BitmapImage
BitmapImage bitmap = new BitmapImage();
await bitmap.SetSourceAsync(photo.Frame);
// Get thumbnail as a BitmapImage
BitmapImage bitmapThumbnail = new BitmapImage();
await bitmapThumbnail.SetSourceAsync(photo.Thumbnail);
// imageLowLagPhoto is a <Image> object defined in XAML
imageLowLagPhoto.Source = bitmap;
// imageLowLagThumbnail is a <Image> object defined in XAML
imageLowLagThumbnail.Source = bitmapThumbnail;
}
async private void CloseLagPhotoCapture_Click(object sender, RoutedEventArgs e)
{
// Release the LowLagPhotoCapture object and resources
await lowLagCaptureMgr.FinishAsync();
}