Reputation: 2841
In Xamarin Forms, using C# is there a way to get the dimensions of the source of an image before you render it to the page?
I want to be able to display images in either portrait or landscape depending on how the source image looks, and the only way I can think of to determine that is to work out the source dimension, unless there is another way to go about it?
Upvotes: 1
Views: 602
Reputation: 2841
Found it here, as I'm using FFImageLoading I can do this:
var cachedImage = new CachedImage() {
WidthRequest = 300,
HeightRequest = 300,
DownsampleToViewSize = true, };
cachedImage.Success += (sender, e) => {
var h = e.ImageInformation.OriginalHeight;
var w = e.ImageInformation.OriginalWidth; };
Upvotes: 1