Skip to content

Commit

Permalink
Merge pull request #14 from afunc233/avalonia11
Browse files Browse the repository at this point in the history
LoadFromLocalAsync
  • Loading branch information
SKProCH authored May 27, 2023
2 parents 3253f74 + 2e30a20 commit e405690
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion AsyncImageLoader.Avalonia/Loaders/BaseWebImageLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public void Dispose()
/// <returns>Bitmap</returns>
protected virtual async Task<Bitmap?> LoadAsync(string url)
{
var internalOrCachedBitmap = await LoadFromInternalAsync(url) ?? await LoadFromGlobalCache(url);
var internalOrCachedBitmap = await LoadFromLocalAsync(url) ??
await LoadFromInternalAsync(url) ?? await LoadFromGlobalCache(url);
if (internalOrCachedBitmap != null) return internalOrCachedBitmap;

try
Expand All @@ -81,6 +82,16 @@ public void Dispose()
}
}

/// <summary>
/// the url maybe is local file url,so if file exists ,we got a Bitmap
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
private Task<Bitmap?> LoadFromLocalAsync(string url)
{
return Task.FromResult(File.Exists(url) ? new Bitmap(url) : null);
}

/// <summary>
/// Receives image bytes from an internal source (for example, from the disk).
/// This data will be NOT cached globally (because it is assumed that it is already in internal source us and does not
Expand Down

0 comments on commit e405690

Please sign in to comment.