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
[sourcecode language="C#"]
this.imgsrc.Source = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
[/sourcecode]
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
No comments:
Post a Comment