Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

When is ImageSource actually loaded

$
0
0

I've been doing a bit of work with images and I'm wondering when exactly is an image loaded when using ImageSource? Is it at the time of assignment of the source, time of binding, time of use (Image img = imageSource)?

The examples in Working with Images so the various ways to load illustrated below and I'm wondering where I should be looking when doing clean up. I've seen various proposed solutions but none seem concrete enough to be an actual solution.

Trying to track down these memory issues in Android is starting to become hairy and I'm wondering if we're all just using the objects incorrectly. Should classes be designed with ImageSource as object for a field/property/variable or should we just be using strings and loading only using ImageSource at the last minute.

var uriImage1 = ImageSource.FromUri( new Uri( "http://xamarin.com/content/images/pages/forms/example-app.png" ) );
var uriImage2 = "http://xamarin.com/content/images/pages/forms/example-app.png";

var fileImage01 = ImageSource.FromFile( "waterfront.jpg" );
var fileImage02 = "waterfront.jpg";

var resourceImage01 = ImageSource.FromResource( "WorkingWithImages.beach.jpg" );

var cahceImage01 = new UriImageSource
{
    Uri = new Uri( "http://xamarin.com/content/images/pages/forms/example-app.png" ),
    CachingEnabled = true,
    CacheValidity = new TimeSpan( 0, 0, 0, 5 )
};

I know changes to images are coming but we don't know when that is so we have to try things now. Are there currently best practices for working with Images or should I just be feeling around for what works best.


Viewing all articles
Browse latest Browse all 58056

Trending Articles