Freigeben über


Capturing photos for Windows Phone 8

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

This section describes the APIs you can use to programmatically capture photos in Windows Phone. It also lists some points to keep in mind when you use the emulator to develop your camera app.

This topic contains the following sections.

Camera API overview

There are two sets of APIs your app can use to capture photos in Windows Phone.

Class

Description

Supported on Windows Phone OS 7.1

Supported on Windows Phone 8

PhotoCamera

Use this class to capture photos and access the preview buffer.

PhotoCaptureDevice

Use this class for advanced photo capture and to access the preview buffer.

The Microsoft.Devices..::.PhotoCamera class gives you the ability to programmatically capture photos in your app. You can use this class to specify the photo resolution and flash settings, and trigger autofocus. For advanced photo capture, the PhotoCaptureDevice class provides an extended set of capabilities and better performance. Use this class to control photo properties such as ISO, exposure compensation, and manual focus position (when available on the phone).

Using PhotoCamera

The Microsoft.Devices..::.PhotoCamera class is available to apps written for Windows Phone OS 7.1 and Windows Phone 8. However, this class can only be used in managed code. For more info about using Microsoft.Devices..::.PhotoCamera, see the following topics:

Using PhotoCaptureDevice

The Windows.Phone.Media.Capture APIs are only available to apps written for Windows Phone 8. These APIs are projected into C#, Visual Basic, and C++ and are accompanied by interfaces that can be called from native code. For more info about these APIs, see the following topics:

Using the emulator

When you use the emulator to develop a camera app, keep the following points in mind:

  • Some API calls may not work as expected on the emulator. Review the Windows Phone SDK release notes for the latest details.

  • The scene sent to the emulator camera is a box that floats around the borders of the viewfinder.

  • On the emulator, the GetPreviewBufferY method returns a buffer that is filled with the color black.

  • On the emulator, the GetPreviewBufferArgb method returns a buffer that is filled with the color white.

  • On the emulator, the GetPreviewBufferYCbCr method returns a buffer that is filled with the color green.

Tip

For the best development experience, we recommend that you develop your camera app on a Windows Phone 8 device.