protected async override Task <SelfDisposingBitmapDrawable> GenerateImageAsync(string path, ImageSource source, Stream imageData, ImageInformation imageInformation, bool enableTransformations, bool isPlaceholder) { try { SelfDisposingBitmapDrawable image = null; if (imageInformation.Type == ImageInformation.ImageType.GIF && Configuration.AnimateGifs && GifDecoder.CheckIfAnimated(imageData)) { image = await PlatformGenerateGifImageAsync(path, source, imageData, imageInformation, enableTransformations, isPlaceholder); } else { image = await PlatformGenerateImageAsync(path, source, imageData, imageInformation, enableTransformations, isPlaceholder); } if (image == null || !image.HasValidBitmap) { throw new BadImageFormatException("Bad image format"); } return(image); } catch (Exception ex) { var javaException = ex as Java.Lang.Throwable; if (javaException != null && javaException.Class == Java.Lang.Class.FromType(typeof(Java.Lang.OutOfMemoryError))) { throw new OutOfMemoryException(); } throw; } }