PhotoCamera Class

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

Provides the basic camera functionality for a Windows Phone still camera application. This class includes members for enabling and configuring functionality such as image capture, focus, resolution, and flash mode. Also, it provides events for camera focus, image capture, and image availability.

Inheritance Hierarchy

System..::.Object
  Microsoft.Devices..::.Camera
    Microsoft.Devices..::.PhotoCamera

Namespace:  Microsoft.Devices
Assembly:  Microsoft.Phone (in Microsoft.Phone.dll)
XMLNS for XAML: Not mapped to an xmlns.

Syntax

Public NotInheritable Class PhotoCamera _
    Inherits Camera
public sealed class PhotoCamera : Camera
<PhotoCamera .../>

The PhotoCamera type exposes the following members.

Constructors

  Name Description
PhotoCamera()()() Initializes a new instance of the PhotoCamera class.
PhotoCamera(CameraType) Initializes a new instance of the PhotoCamera class for the specified type of camera.

Top

Properties

  Name Description
AvailableResolutions Queries the camera for the available resolutions. (Inherited from Camera.)
CameraType Gets the type of camera that the Camera object represents; indicates the location of the camera on the device. (Inherited from Camera.)
FlashMode Gets or sets the flash mode. Unsupported flash modes silently default to Off.
IsFocusAtPointSupported Specifies whether the camera can programmatically auto focus on a specific point in the viewfinder.
IsFocusSupported Specifies whether the camera can be auto-focused programmatically.
Orientation Gets the number of degrees that the viewfinder brush needs to be rotated clockwise to align with the camera sensor. (Inherited from Camera.)
PreviewResolution Gets the current resolution of the image provided by the PhotoCameraGetPreviewBuffer methods. This method is for use by the live viewfinder. (Inherited from Camera.)
Resolution Gets or sets the resolution of the image captured by the camera. (Inherited from Camera.)
YCbCrPixelLayout Gets the YCbCr pixel layout of the camera preview buffer.

Top

Methods

  Name Description
CancelFocus Cancels the current focus operation.
CaptureImage Initiates a full-resolution capture of the current image displayed in the viewfinder.
Dispose Disposes of the image source stream and frees resources used by the Camera object. (Inherited from Camera.)
Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Finalize Releases unmanaged resources and performs other cleanup operations before the Camera object is reclaimed by garbage collection. (Inherited from Camera.)
Focus Starts a camera auto focus operation.
FocusAtPoint Starts a camera auto focus operation on a specific point in the viewfinder, for those devices that support it.
GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
GetPreviewBufferArgb32 Copies the current viewfinder ARGB frame into a buffer for further manipulation.
GetPreviewBufferY Copies the luminance data for the current viewfinder frame into a buffer for further manipulation.
GetPreviewBufferYCbCr Copies the current viewfinder frame into a buffer for further manipulation.
GetType Gets the Type of the current instance. (Inherited from Object.)
IsFlashModeSupported Determines whether a particular flash mode is supported on the device.
MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Events

  Name Description
AutoFocusCompleted Occurs after the focus operation is complete.
CaptureCompleted Occurs when the capture sequence is complete.
CaptureImageAvailable Occurs when an image is available.
CaptureStarted Occurs when the capture sequence has started.
CaptureThumbnailAvailable Occurs when a thumbnail image is available.
Initialized Occurs when the camera object has been initialized. (Inherited from Camera.)

Top

Remarks

To account for the Windows Phone execution model, initialize the PhotoCamera object in the OnNavigatedTo(NavigationEventArgs) method and explicitly call the camera Dispose method during the OnNavigatingFrom(NavigatingCancelEventArgs) method. Add event handlers for PhotoCamera and CameraButtons events in the OnNavigatedTo(NavigationEventArgs) method and remove them in the OnNavigatingFrom(NavigatingCancelEventArgs) method.

For examples and more information about how to implement these members, see How to create a base camera app for Windows Phone 8.

Important 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 lower-memory device. For more information, see Developing apps for lower-memory phones for Windows Phone 8 and How to use the camera capture task for Windows Phone 8.

Capabilities

If you use this API in your app, you must specify the following capabilities in the app manifest. Otherwise, your app might not work correctly or it might exit unexpectedly.

ID_CAP_ISV_CAMERA

Windows Phone 8, Windows Phone OS 7.1

For more info, see App capabilities and hardware requirements for Windows Phone 8.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Platforms

Windows Phone

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.Devices Namespace