How take photo from Windows Phone 7 using code

Hello friends,

Today we will learn how to take photo from windows phone using code.

For this we will do following design we will have a button with name btnImage and text Take image.

We have an image control also on the page.

Now as we need to add same reference as we added in our previous 3 examples which is “Microsoft.Phone.Tasks”

Now on the  button click event we will write following code

CameraCaptureTask cameraTask = new CameraCaptureTask();
cameraTask.Show();

cameraTask.Completed += new EventHandler(cameraTask_Completed);

Now in the above code we have created a delegate in this delegate we will right following code

this.imgsrc.Source = PictureDecoder.DecodeJpeg(e.ChosenPhoto);

Here in the above line we are providing the capture image as a source code to our image control.

So when you click the take photo button you will get following screen.

And once you accept the photo you will get taken photo in image control of our windows phone app. So you are now aware how to capture image.

You can download the code at https://skydrive.live.com/?cid=1eda2012469ff8ad&id=1EDA2012469FF8AD!243

Enjoy doing taking Photos

Thanks & Best Regards,

Rajat Jaiswal

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s