Expand Minimize

MediaCapture.PrepareLowLagPhotoCaptureAsync | prepareLowLagPhotoCaptureAsync method

Applies to Windows and Windows Phone

Initializes the low shutter lag photo capture and provides the LowLagPhotoCapture object used to manage the recording.

Syntax


public:
IAsyncOperation<LowLagPhotoCapture>^ PrepareLowLagPhotoCaptureAsync(
  ImageEncodingProperties^ type
)

Parameters

type

Type: ImageEncodingProperties

The encoding profile used for the image.

Return value

Type: IAsyncOperation<LowLagPhotoCapture>

When this method completes, a LowLagPhotoCapture object is returned which can be used to start the photo capture.

Remarks

Use PrepareLowLagPhotoCaptureAsync to initialize the capture. This is an asynchronous calls which returns a LowLagPhotoCapture object when it is finished, which is used to start the actual photo capture by calling LowLagPhotoCapture.CaptureAsync.

PrepareLowLagPhotoCaptureAsync must be called before LowLagPhotoCapture.CaptureAsync.

Examples

Here is some code that shows how to setup and take low lag photos. It displays the captured photo and thumbnail in Image objects. The XAML creates a simple UI with two Image objects and some Button objects to interact with the sample. In code, there is a method to initialize the MediaCapture object, a method to initialize the LowLagPhotoCapture object, a method to take the photo and display it, and a method to shutdown the 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();
}


Requirements

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Media.Capture
Windows::Media::Capture [C++]

Metadata

Windows.winmd

See also

MediaCapture

 

 

Show:
© 2014 Microsoft