1

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

  • http://wp.qmatteoq.com/how-to-save-a-picture-captured-with-the-new-cameras-api-in-the-camera-roll-in-windows-phone-8/ took 5 seconds with google search there even is a msdn article: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662940%28v=vs.105%29.aspx – Master117 Sep 06 '13 at 10:10

2 Answers2

0

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);
}
Master117
  • 660
  • 6
  • 21
0

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);
    }
}
Olivier Payen
  • 15,198
  • 7
  • 41
  • 70
  • Dear Olivier, Thanks for your valubale help. Could you please make this code more clear where i can easily understand. I want to save the image in Media Library instead of Image Control –  Sep 10 '13 at 09:37
  • @Dinoo, I edited my answer to show you how to save to the MediaLibrary. – Olivier Payen Sep 10 '13 at 09:48
  • Dear Olivier, Great support from you, its amazing now working fine –  Sep 10 '13 at 09:52
  • Dear Olivier, thanks its working, can i save this image in an Object??? so that i can send it directly to server ??? if its possible can u rough it here –  Sep 10 '13 at 10:40
  • @Dinoo that's another question that you should post as such on stackoverflow. And don't forget to mark this question as answered if the solution works. – Olivier Payen Sep 10 '13 at 12:48
  • @Dear Olivier, unfortunately stack overflow blocked me from asking Question, so i asked here itself. –  Sep 10 '13 at 13:07
  • Look here : http://stackoverflow.com/questions/15490347/upload-image-file-in-windows-phone-7-application-to-php and here http://chriskoenig.net/2011/08/19/upload-files-from-windows-phone/ – Olivier Payen Sep 10 '13 at 13:24