7 out of 18 rated this helpful - Rate this topic

Camera and Photos Overview for Windows Phone

Windows Phone

March 22, 2012

This topic provides an overview of the camera and photos development experience for Windows Phone. Also, it highlights and describes the topics within this section.

Important noteImportant Note:

When upgrading Windows Phone OS 7.0 applications to use the capabilities in Windows Phone OS 7.1, the camera capability ID_CAP_ISV_CAMERA is not automatically added to the application manifest file, WMAppManifest.xml. Without ID_CAP_ISV_CAMERA, applications using the camera API will not function. In new Windows Phone OS 7.1 projects, this capability is included in the application manifest file.

Windows Phone supports programmatic access to the camera on a device, offering a rich set of APIs for developers to create their applications. Some features include:

  • Creating a camera application with a viewfinder and capturing still photos

  • Providing real-time access to raw frames from the camera

  • Adjusting the resolution of the captured photo

  • Implementing functionality such as focus and flash

  • Detecting and querying the device camera capabilities such as flash

  • Accessing the camera hardware shutter button for capturing photos and triggering auto-focus

A camera is not required for all Windows Phone devices. It is important that you consider this when designing and implementing your application. Your application should always check to see whether a camera is available and respond gracefully if it is not.

Note Note:

multiple devices 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 Developing for 256-MB Devices and How to: Use the Camera Capture Task for Windows Phone.

The following illustrates a possible layout for a Windows Phone camera application. For step-by-step guidance for creating this sample, see How to: Create a Base Camera Application for Windows Phone.

AP_Con_CameraAnatomy

Windows Phone supports a full set of APIs for application development, and extensibility points that extend the camera and photo experience on the device. Some features include:

  • Using managed APIs for decoding and encoding photos

  • Allowing applications the ability to perform tasks such as saving a picture to the media library

  • Using App Connect to extend the Windows Phone built-in photo application

  • Using App Connect to extend the Windows Phone Pictures Hub

  • Extending the photos experience to upload photos to a web service

To use a primary or front-facing camera in your Windows Phone application, you must add the camera capability (ID_CAP_ISV_CAMERA) to the application manifest file. This capability declaration notifies the end user that your application uses the camera and allows them to opt-in. In most cases, this capability will be automatically added to the application manifest file of new Windows Phone application projects. However, if you are upgrading a Windows Phone OS 7.0 application, the camera capability will not be automatically added to the application manifest file.

If your application is designed specifically for use of the front-facing camera, you must additionally add the front-facing camera capability (ID_HW_FRONTCAMERA). Use this when your application requires the front-facing camera. For example, a “mirror” application that could not be useful without the front-facing camera could use this capability declaration to indicate that the front-facing camera is required.

If a front-facing camera is not present on the user’s device and you declare ID_HW_FRONTCAMERA, Marketplace warns the user that some features of the application might not work because their phone does not have a front-facing camera. This capability is not required to use the front-facing camera; it is only used to trigger the said warning when applicable.

If your application can use either camera, the front-facing camera or the primary camera (located on the back of the device), then do not use the ID_HW_FRONTCAMERA capability. In Windows Phone OS 7.1, the front-facing and primary camera are optional, so it is a best practice to check for their availability before using them. For examples that show how to do this, see How to: Create a Base Camera Application for Windows Phone and How to: Record Video in a Camera Application for Windows Phone.

For example, if your application requires the front-facing camera, include the following elements in the Capabilities element of the application manifest file.

<Capability Name="ID_CAP_ISV_CAMERA"/>
<Capability Name="ID_HW_FRONTCAMERA"/>

If your application can use either type of camera, only the camera capability element is required, as shown here.

<Capability Name="ID_CAP_ISV_CAMERA"/>

For more information about the application manifest file, see Application Manifest File for Windows Phone.

Camera and Photos Class Support for Windows Phone : Developers use a combination of both Windows Phone and Silverlight 4 class APIs to create camera applications. This section will provide a list of the primary classes and define usage.

Camera Applications for Windows Phone : This section provides end-to-end instruction on how to create Windows Phone camera applications.

Pictures Extensibility for Windows Phone : App Connect allows developers to integrate photo-based applications seamlessly into the Windows Phone Photo and Pictures Hub experience.

Decoding and Encoding Photos for Windows Phone : Windows Phone provides managed APIs for decoding and encoding photos. This is essential for photo applications and an indispensible part of the still-image platform infrastructure. Developers can easily implement a still-image application with both reasonable performance and memory consumption.

Camera and Photos Best Practices for Windows Phone : This section provides best practices for creating efficient, high-performing camera applications.

Did you find this helpful?
(1500 characters remaining)