Episodex
Episodex

Reputation: 4559

ImageSource.FromStream() not working on some Android devices

I have an Image element on my content page. I want to assign MemoryStream source to it in constructor of my ContentPage. This works ok on Samsung Galaxy A3 (Android 5.0.2) but displays nothing (no error, no exception, no image) on Samsung Galaxy Note 3 (Android 5.0). Is it a bug in Xamarin.Forms? Or do I do something wrong?

Code:

Image image = new Image();
var path = "some/path/to/image.jpg";
var bytes = File.ReadAllBytes(path); //has correct byte array with correct length
image.Source = ImageSource.FromStream(() => new MemoryStream(bytes)); 

Upvotes: 1

Views: 1793

Answers (1)

ValeroLlinares
ValeroLlinares

Reputation: 36

I have the same problem.

But selecting a lower resolution in camera, the image works, I need select resolution < 9 Mpx and the image works, with resolutions biggers the image does not work. It depend's of android version and device, it's a out of memory exception.

So, I resize the image taken with the camera and it works.

You can install FFimageLoading plugin and CachedImage control, i don't test it because i prefer resize the image, the app is larger with plugins.

Upvotes: 2

Related Questions