xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

ImageSource.FromFile strange work #5631

Open dronishe opened 5 years ago

dronishe commented 5 years ago

Description

Setting image source from file path works differently depending on file location and on Xamarin Forms version. The following code in xaml leads to different image sizes (see screenshots) with different Xamarin Forms versions.

`

`

Images in drawable folder and in app folder are the same, but using Xamarin.Forms version 3.2.0.871581 (or lower) I get 2 same sized images and in version 3.3.0.912540 (or higher) I get second image much smaller.

I can reproduce this behavior only on Visual Studio Emulator for android, on real devices I have no such problem.

Steps to Reproduce

  1. Create new Xamarin Forms project in Visual Studio
  2. Add the same image to drawable folder and to the app folder on a virtual device
  3. Add two images with source from files from step 2.
  4. Start app on Visual Studio Android Emulator with different Xamarin Forms (3.2.0.871581 and 3.3.0.912540) versions.

Expected Behavior

Get same images sizes for the same code independently from Xamarin Forms version.

Actual Behavior

Different images sizes for the same code for different Xamarin Forms version

Basic Information

Screenshots

imgsource_fine imgsource_wrong

Reproduction Link

https://github.com/dronishe/XamarinImagFromSourceExample

I’ve created a simple repo for reproduction. Last commit – same image size with older version of Xamarin Forms. Second to last commit – same code, differs only with Xamarin Forms version. Images have different size.

Confusedfish commented 3 years ago

This sounds like a very similar issue that I am facing on an Android 10 device, physical or virtual. I don't get the problem on iOS nor Android 9.