Created
February 13, 2018 20:32
-
-
Save jonathanpeppers/5421082514fbf9dcfdd250ade3c9807b to your computer and use it in GitHub Desktop.
FileImageSourceHandler from Xamarin.Forms https://github.com/xamarin/Xamarin.Forms/blob/b96f65bdd9e7e931971338b122a8940e2a35ccc7/Xamarin.Forms.Platform.Android/Renderers/FileImageSourceHandler.cs#L18-L33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<Bitmap> LoadImageAsync(ImageSource imagesource, Context context, CancellationToken cancelationToken = default(CancellationToken)) | |
{ | |
string file = ((FileImageSource)imagesource).File; | |
Bitmap bitmap; | |
if (File.Exists (file)) | |
bitmap = !DecodeSynchronously ? (await BitmapFactory.DecodeFileAsync (file).ConfigureAwait (false)) : BitmapFactory.DecodeFile (file); | |
else | |
bitmap = !DecodeSynchronously ? (await context.Resources.GetBitmapAsync (file).ConfigureAwait (false)) : context.Resources.GetBitmap (file); | |
if (bitmap == null) | |
{ | |
Log.Warning(nameof(FileImageSourceHandler), "Could not find image or image file was invalid: {0}", imagesource); | |
} | |
return bitmap; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment