sooraj P R
sooraj P R

Reputation: 259

How to get live camera preview in Windows Phone 8

I want to create an application in Windows phone8. In this application i want to show live camera preview with different effect in multiple frame using C# in Windows phone 8. please give me a solution

Upvotes: 1

Views: 837

Answers (1)

Mintey
Mintey

Reputation: 118

To use the camera in Windows phone 8 you need to use the PhotoCamera object. Best to create this object on your OnNavigatedTo like so:

protected override void OnNavigatedTo (System.Windows.Navigation.NavigationEventArgs e) 
{ 
    if (PhotoCamera.IsCameraTypeSupported(CameraType.Primary) == true) 
    { 
        cam = new PhotoCamera(CameraType.Primary); 
        cam.CaptureImageAvailable += new EventHandler<Microsoft.Devices.ContentReadyEventArgs>(cam_CaptureImageAvailable); 
        viewfinderBrush.SetSource(cam); 
    }
    else 
    {
        txtMessage.Text = "A Camera is not available on this device."; }
    }   
}
// dispose when we leave
protected override void OnNavigatingFrom (System.Windows.Navigation.NavigatingCancelEventArgs e) 
{ 
    if (cam != null) 
    { 
        cam.Dispose(); 
    } 
}

To actually capture the image from the camera you can then call the CaptureImage method on the cam object.

Upvotes: 1

Related Questions