0
votes

I saved the image in MediaLibrary as follow

 System.Windows.Media.Imaging.Extensions.SaveJpeg(wb, msWrite, g_IntWidth, g_IntHeight, 0, 100);
 MediaLibrary ML = new MediaLibrary();
 ML.SavePicture("My1stPhoto.jpg", msWrite);

The problem is :

later when I use PhotoChooser to select previously saved Photo ( My1stPhoto.jpg ), but this is working. It seems the return filename is not the same as My1stPhoto.jpg

I used below code , the byte is 0 ? Need your help. Thanks.

 void photoChooserTask_Completed(object sender, PhotoResult e)
  {
           strSelectedFilenameinHub = e.OriginalFileName;

           StreamResourceInfo sri = null;

            Uri jpegUri = new Uri( strSelectedFilenameinHub, UriKind.Relative);

             sri = Application.GetResourceStream(jpegUri);

             byte[] imageData = new byte[sri.Stream.Length];

            sri.Stream.Read(imageData, 0, System.Convert.ToInt32(sri.Stream.Length));

 }


 
1

1 Answers

0
votes

Why would you want to retrieve the stream using the media library? You can use directly e.ChosenPhoto to retrieve the contents of the picture:

void photoChooserTask_Completed(object sender, PhotoResult e)
{    
     byte[] imageData = new byte[e.ChosenPhoto.Length];

     e.ChosenPhoto.Read(imageData, 0, System.Convert.ToInt32(e.ChosenPhoto.Length));
}

I also doubt that you need to copy the contents of the stream to a byte array. Depending on what you want to do with the picture, you may want to choose a less memory-consuming way.