I am trying to make a StreamImageSource into a Byte. My image named "imgPicked" is a StreamImageSource when I run it in the log. I want to convert that into a Byte [] but I am unsure of how you do it.
This is the code that I have:
private async void btnPickPicture_Clicked (object sender, EventArgs e)
{
await cameraOps.SelectPicture ();
var file = await cameraOps.SelectPicture();
imgPicked.Source = ImageSource.FromStream(() => file.Source);
System.Diagnostics.Debug.WriteLine (imgPicked.Source);
//imgPicked is an StreamImageSource
}
How do I turn my StreamImageSource (imgPicked) into a byte []?
This is what I have so far after googling:
byte[] data = File.ReadAll(imgPicked.Source);
But I do not find "File". Do I miss an assembly or did the author not mention what "File" inherits from (See link): Is there a cross-platform solution to ImageSource to byte[]?