white painted wall

Using the CameraCaptureTask in Windows Phone 7

The CameraCaptureTask allows the Windows Phone 7 App to launch the Camera Application .

This will be useful when the user wants to take a photo from the App and then do something useful with the Photo like saving the photo that was taken etc .

This blog post discusses how to use the CameraCaptureTask and display the photo that was taken on to the Image Control in Windows Phone 7 .

The CameraCaptureTask is defined in the namespace Microsoft.Phone.Tasks .

Using Microsoft.Phone.Tasks;
private void button1_Click(object sender, RoutedEventArgs e)
{
     CameraCaptureTask cameraCapture = new CameraCaptureTask();
     cameraCapture.Completed += new EventHandler<PhotoResult>(cameraCapture_Completed);
     cameraCapture.Show();

}

void cameraCapture_Completed(object sender, PhotoResult e)
{
     if (e.TaskResult == TaskResult.OK)
     {
        BitmapImage bitImage = new BitmapImage();
        bitImage.SetSource(e.ChosenPhoto);
        //image is a Image Control in the form
        image1.Source = bitImage;

}
}

When the photo is captured via Camera and Accepted , it can be accessed through the ChosenPhoto of the PhotoResult .

In the above example , the photo is displayed on the Image Control .

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...