Xamarin.Forms Image Caching Cross-Platform Solution - caching

We have number of images used as app assets, for case of simplicity, let's say 10 images only.
As far as I understand, Xamarin.Forms will not cashe these images, so if I have these 10 images showing in my toolbar (this is just to explain issue, we would not really put 10 images in a tiny toolbar) and I have 5 pages showing same toolbar, that means the 10 images will be loaded each 5 times resulting in total 50 images loaded. I would like to load only 10 images rather than loading 5pages x 10images = 50 images.
In addition, if I have to add these 10 images in our repository, I would have to add at least 3 copies of same image to our repository (1 for Android, 1 for IOS, 1 for UWP). This results in 30 images in repository but in reality I needed only 10.
So, these 2 issues make be believe there should be a better cross-platform solution so I can share same image across all 3 platforms, have only one image used by all 3 platforms (Android, IOS, UWP), and I load an image only once in memory regardless how many times I show in the UI.

You can look into FFImageLoading which supports caching. To have images in your shared code instead of your platform-specific code you could look into embedded images:
Embedded images are also shipped with an application (like local images) but instead of having a copy of the image in each application's file structure the image file is embedded in the assembly as a resource. This method of distributing images is particularly suited to creating components, as the image is bundled with the code.
https://developer.xamarin.com/guides/xamarin-forms/user-interface/images/#Embedded_Images
Keep in mind though that adding images per platform isn't a bad thing. Each platform has its own image versions due to different pixel densities etc. so to make it look good on each platform you might want to consider the platform-specific route.
Another alternative is adding your images as file-linked images in each platform specific file. The image file itself can saved in a single location and file-linked into the correct directories per platform.

There is a library for Xamarin.Forms called Forms9Patch which supports different resolutions and devices just like the specific projects for Android / iOS.
Forms9Patch has a MIT-license, here's the github.
Also this is a video that should give a good general overview.

Related

Xamarin UI Measurement

I'm a UI designer working with a junior app developer.
We are working on an app I gave him the assets and there sizes using Zeplin app, he showed me the app and it was different than was design telling me that Xamarin doesn't use pixels or dpi but using a number without any measurement.
Is there any way to help him as a designer or something he can use to make the program use pixels or dpi.
#Muslem Mohammed
I think as you are an UI Designer, you are aware that how to provide assets for native app development if not please check for below process.
You can provide Android Assets in the form of Mdpi drawable, hdpi, xhdpi, xxhdpi.
And for iOS 1x, 2x and 3x same like native app assets.
And the developer place all those images into respective folder with respect to the platform.
Example: For Android you will be providing 5 kinds of images with same name respect to the folder I mentioned above.
sample.png for respective folders with the resolution, developer place those images into Android specific project.
Then developer place all images under resources and keep in respective folders.
For iOS also provide the images with same name and by applying 1x,2x,3x with sample below,
sample.png, sample#2x.png and sample#3x.png.
Then developer go to iOS project and place all ios images into Resources folder.
And finally developer will place the image control like below,
<Image source="sample.png" />
And this will show up the image in iOS and Android as well.

Xcode 8 import pdf (vector) intro image assets not working well

I drag pdf intro image assets (universal) and building Xcode.
There is no generated png#2 png#3 . (only Pdf)
I follow this tutorial :
https://icons8.com/articles/how-to-use-vectors-in-xcode-7/
When I start app on the device images are so bad quality...
Xcode 6, 7 working ....
Maybe PDF file needs optimisation ?!
In research I found "size of svg is not important" but in this case it is (I test it).
Not sure if this helps, but from what I was reading about this, Xcode doesn't fully support vector graphics. It sounds like instead of you being able to load a vector image (.pdf) and it scales however necessary. Instead, whatever the default size of your .pdf is, it'll assume that is the 1x size, then scale the pdf to automatically create the 2x and 3x image when it's built. So its not actually scaling the original, just creating a 1x, 2x, and 3x png of the original size of your pdf. From what I'm reading, people are thinking this is done to maintain backwards compatibility. I couldn't find anything that says it has changed in Xcode 8, so I'm assuming it still works the same way.
This question seems to answer it well: How do vector images work in Xcode (i.e. pdf files)?
Hope I was able to help.
Possible hepful support links, I would suggest updating to the latest. xcode 13
xcode 8.1
xcode 8

Supporting Vector images in the App which is remotely stored

Would like to know is it possible to incorporate vector images from a remote source in an app as of targeting both 2x and 3x. It has been told that .png files are generated in the run time for the particular vector in asset catalog. Appreciate your comments just to be clear on this fact.
https://www.createful.com/2014/using-vector-pdf-icons-xcode-6/
How to programmatically put vector images in iOS asset catalog
Thanks.

Image size reduces while it send through "ShareMediaTask" in windows phone 8

In my image editing application i am providing two option to the user, 1) save image to Media library and another share it through ShareMediaTask. The issue i am facing is while saving the image to library the size of the image is 1.5 mb. If i share the same image through ShareMediaTask(Gmail / Hotmail etc) The size of the image reduces to 330 Kb. Hence it affects the quality of the image. How i can share the same image in Media library without losing the size and quality in windows phone 8.
I also tried the same share through library (ie without using my application). Still the result is same.
If anyone had a solution to this issue please update your suggestions.
Thanks,
Stez.
The email application automatically downscales images, there is no way to control this. An alternative solution would be to, eg, upload the image to Skydrive and email the link.

Why iPad default launch image orientations not working (iOS 5)?

There exists a number of questions (some answered already) that pertain to the launch images. I had no problems using launch images per se. My problem comes when trying to support multiple orientations of the launch image (portrait or landscape for my app).
The problem is this:
When i started my app dev, i used the usual default.png as the launch image.
But now i have 4 different launch images (portrait and landscape, plus their retina versions). However, with these launch imaged named different, Im seeing a black screen for the launch, no matter what orientation the device is in.
I spent a day on this. And i decided to just go with a single default.png (retina portrait) since I realized the launch image only lasts a few seconds and is not very important any way.
Alas, the curiosity is killing me.
Note: the images were named as follows (notice they are lower cased, and they also are placed under /images folder rather than at the project root folder):
default-portrait.png
default-portrait#2x.png
default-landscape.png
default-landscape#2x.png
Question:
what am i doing wrong? like i said, i went thru many online references to this problem. none of them helped for me.
It's because you put them into a sub-folder.
This document states:
All launch images must be PNG files and must reside in the top level
of your app’s bundle directory.
The fact that you are using lowercase filenames looks a bit dodgy too...

Resources