Camera and Photos Class Support for Windows Phone
March 22, 2012
You can use the Windows Phone and Silverlight 4 APIs to create camera and photo-based applications. This topic provides a list of the primary classes and describes ways that you can use them.
There are two ways to access the camera on the device:
-
Windows Phone camera API: To develop applications that feature photography scenarios.
-
Silverlight 4 webcam API: To develop applications that feature video scenarios and to port existing Silverlight 4 webcam applications to the device.
Use the Windows Phone camera API for applications when you want to develop applications that take high-resolution photographs, use the hardware shutter button, or access the flash mode or focus functionality. For example, this API could be used to create an advanced still-photo application.
Use the Silverlight 4 webcam API when you want to develop an application that records video and audio into a file. If you are already familiar with this API from developing Silverlight applications, you can re-use your webcam code for developing Windows Phone applications.
You can also use a combination of the two APIs to create augmented reality applications. Augmented reality applications overlay enhancements, such as graphics or audio, over a live view of the world. For an example showing how to use the PhotoCamera class with the VideoBrush in an augmented reality application, see the second procedure in How to: Use the Combined Motion API for Windows Phone.
Note:
|
|---|
|
|
The following classes are the primary classes for Windows Phone camera and photo application development. They are derived from the Microsoft.Devices, Microsoft.Phone, and System.Windows.Media.Imaging namespaces in the Windows Phone class library.
|
Class name |
Description |
|---|---|
|
Applications use this class to either encode a WriteableBitmap object into a JPEG stream, or decode a JPEG stream into a WriteableBitmap object. |
|
|
This class is used for decoding a JPEG stream into a WriteableBitmap object. |
|
|
This class represents the basic camera functionality for a Windows Phone still camera application. It includes members for enabling and configuring functionality such as image capture, focus, and flash mode. Also, it contains the primary focus events, image acquired event, and image saved event. |
A Windows Phone application can also use Silverlight 4 classes for camera application development. The following Silverlight 4 classes are derived from the System.Windows.Media namespace in the Silverlight class library. The following table provides these classes and their descriptions.
|
Class name |
Description |
|---|---|
|
Describes either the desired or supported formats for an audio capture device. |
|
|
Exposes the capture graph for audio devices. Derive from this class to receive audio information and to obtain the capture graph through AudioSink.CaptureSource. |
|
|
Represents a helper class for obtaining information about available capture devices (audio or video) and requesting client user permission to access the captures from available devices. |
|
|
The controller for a set of associated sources and sinks. Provides methods that work with specific audio or video captures from the associated capture device. |
|
|
Captures video using a CaptureSource object and records it to a video file in isolated storage. |
|
|
The video brush provides a way to render a composited video source onto an object. Typical usage is the background for elements such as a rectangle or container. You can also use it with the PhotoCamera class to create an augmented reality application. For an example, see the second procedure in How to: Use the Combined Motion API for Windows Phone. |
|
|
Describes desired and supported video format information for a video capture device, such as the camera on the phone. |
|
|
Exposes the capture graph for video devices. Derive from this class to receive video information and to obtain the capture graph through VideoSink.CaptureSource. |
Note:
|
|---|
| For best practices and guidelines for camera and photos application development, see Camera and Photos Best Practices for Windows Phone. |
Note:
If photo capture is not a core feature of your application, consider using the Camera Capture Task to capture photos instead of using the camera APIs directly. Memory allocated for the Camera Capture Task does not count toward total application memory use. This helps minimize your application’s memory use, which is particularly important when your application runs on a 256-MB device. For more information, see