4
votes

I have been working on Xamarin forms for a long time now but the thing that has always bugged me is what is the better approach to store images in xamarin forms.

I wanted to know which images should I use from PCL and which ones should I put in native resource files or is using PCL images a bad approach altogether.

I went through everything in Local Images and Embedded Images but found nothing related to the better approach among them or performance or anything as such.

1
You can choose one approach which you prefer in you application. But I prefer to Local Images.Robbit
Thanks currently what i am doing is i only have the redundant images in pcl for eg Splash Image or an Error Screen image so on and so forth @JoeLv-MSFTFreakyAli
Actually, I have tested the time of both approaches, there is no too much difference.Robbit
Can you show me what your conclusion was? I mean what was the time difference and which one turned out to be the better one as per youFreakyAli

1 Answers

0
votes

At the end after all the research for almost a year I came to the conclusion that the Local Image approach suits me better, even with the case where I had to add it to all three native projects depending what I target.

Reason being the following:

  • When I use local images I have an option to place different images in different size folders i.e. HDPI, MDPI(Android) and @2x,@3x(iOS)
  • What the above point does for me is it selects the image it should pick as per the current devices resolution which cannot be achieved with EmbeddedResources
  • One possible solution to issue mention above was using SVG's but as everyone knows that if the image you are using needs to look pixel perfect SVG's are not your best option as they lose some details here an there as you use them in your mobile devices.
  • One more cheeky thing I did (but I like to share my dev secrets) was whichever Images in my application were only in one size for all resolutions and platform or at least two of them I incorporated them in the Shared code

Note: Embedded Resource takes a little more time to load then your native Local Images always consider that while using