I want Save the Captured image in Media LIbrary. Any one can help me. :)
CameraCaptureTask myCamera = new CameraCaptureTask();
myCamera.Show();
This is the code i used to open the camera and Capture
I want Save the Captured image in Media LIbrary. Any one can help me. :)
CameraCaptureTask myCamera = new CameraCaptureTask();
myCamera.Show();
This is the code i used to open the camera and Capture
use the SavePictureToCameraRoll method of the MediaLibrary object
public async void Capture()
{
await seq.StartCaptureAsync();
// Set the stream position to the beginning.
captureStream1.Seek(0, SeekOrigin.Begin);
MediaLibrary library = new MediaLibrary();
Picture picture1 = library.SavePictureToCameraRoll("image1", captureStream1);
}
Declare your CameraCaptureTask
in your Page before the constructor:
CameraCaptureTask cameraCaptureTask;
In the Page constructure, initialize the CameraCaptureTask and subscribe to the Completed
event handler:
cameraCaptureTask = new CameraCaptureTask();
cameraCaptureTask.Completed += new EventHandler<PhotoResult>(cameraCaptureTask_Completed);
Call the Show method when you want to launch the task (example: in the Page constructor or on a button click event):
cameraCaptureTask.Show();
Add the code for the completed event handler to your page. This code runs after the user completes the task. The result is a PhotoResult object that exposes a stream containing the image data:
void cameraCaptureTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
MediaLibrary medialibrary = new MediaLibrary(); // Don't forget to the "using Microsoft.Xna.Framework.Media;" namespace
medialibrary.SavePicture("ImageName", e.ChosenPhoto);
}
}