I need to pass an image (Image _thresholdedImage
) like byte array... I don\'t know how I can do this. Any idea? Thank you!
_thresholdedImage.Sou
It turns out that you can convert the MediaFile object to a byte array. So no need to convert the file to ImageSource
or Image
.
var photo = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions() { });
byte[] imageArray = null;
using (MemoryStream memory = new MemoryStream()) {
Stream stream = photo.GetStream();
stream.CopyTo(memory);
imageArray = memory.ToArray();
}
Source: https://forums.xamarin.com/discussion/156236/how-to-get-the-bytes-from-the-imagesource-in-xamarin-forms
Shoutout to user "ajaxer" in the Xamarin forums whose solution saved me after spending 3 days on this issue.