-
Notifications
You must be signed in to change notification settings - Fork 376
Android API
Unlike Picasso you cannot use FFImageLoading with standard ImageViews. Instead simply load your images into ImageViewAsync instances. Updating your code is very easy since ImageViewAsync inherits from ImageView.
By default, on Android, images are loaded without transparency channel. This allows saving 50% of memory since 1 pixel uses 2 bytes instead of 4 bytes in RGBA. This is overridable for all images using ImageService.Instance.Initialize(loadWithTransparencyChannel:true)
or, per image request, by explicitly setting TaskParameter.TransparencyChannel(true or false)
.
On Android images can be loaded from Internet, Resources, Assets or File.
When the image is loaded from internet the image is cached on disk (by default 30 days but there is an optional TimeSpan so you can choose yours).
ImageService.Instance.LoadUrl(urlToImage).Into(_imageView);
If you don't know what are resources you can read Xamarin resources documentation.
ImageService.Instance.LoadCompiledResource(fullPathToImage).Into(_imageView);
If you don't know what are assets you can read Xamarin asset documentation.
ImageService.Instance.LoadFileFromApplicationBundle(fullPathToImage).Into(_imageView);
When you want to load the image from a file:
ImageService.Instance.LoadFile(fullPathToImage).Into(_imageView);
The image can be loaded from an existing Stream. Pleas note: In this case the image is only cached in memory when custom key is provided. Please note that the Stream is automatically closed.
ImageService.Instance.LoadStream((token) => { return SomeMethodWhichReturnsStream(token); }).Into(_imageView);