0

I have a selected image stream and i want to convert it to byte. How can i do that?

void photoChooserTask_Completed(object sender, PhotoResult e)
{
    if (e.TaskResult == TaskResult.OK)
    {
        MessageBox.Show(e.ChosenPhoto.Length.ToString());
 var image = new BitmapImage();
            image.SetSource(e.ChosenPhoto);

/// ????


        //Code to display the photo on the page in an image control named myImage.
        //System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
        //bmp.SetSource(e.ChosenPhoto);
        //myImage.Source = bmp;
    }
}
  • See this answer: http://stackoverflow.com/questions/1080442/how-to-convert-an-stream-into-a-byte-in-c – Robban Apr 23 '14 at 07:00
  • thanks and how can i set a length for that byte ? so for example 2mb – user3561309 Apr 23 '14 at 07:14
  • 1
    If you mean that you want to restrict the size of the image you will have to resize the image after reading the byte stream. Cutting the byte stream short at 2mb would make you lose image data. – Robban Apr 23 '14 at 07:30

0 Answers0