Skip to content
William Qi edited this page Aug 9, 2016 · 11 revisions

ImageViewAsync

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.

Transparency

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).

Source

On Android images can be loaded from Internet, Resources, Assets or File.

Internet

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);

Resources

If you don't know what are resources you can read Xamarin resources documentation.

ImageService.Instance.LoadCompiledResource(nameOfResource).Into(_imageView);

Assets

If you don't know what are assets you can read Xamarin asset documentation.

ImageService.Instance.LoadFileFromApplicationBundle(fullPathToImage).Into(_imageView);

File

When you want to load the image from a file:

ImageService.Instance.LoadFile(fullPathToImage).Into(_imageView);

Stream

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);