Share via


LowLagPhotoCapture.FinishAsync メソッド

定義

写真のキャプチャ操作で使用される 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 は、2 つの Image オブジェクトと、MediaCapture 要素と対話するためのいくつかの Button オブジェクトを含む単純な UI を作成します。 コードには、 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();
}

適用対象