async Task <FFGifDrawable> PlatformGenerateGifImageAsync(string path, ImageSource source, Stream imageData, ImageInformation imageInformation, bool enableTransformations, bool isPlaceholder) { if (imageData == null) { throw new ArgumentNullException(nameof(imageData)); } ThrowIfCancellationRequested(); try { //TODO Add caching, transformations, downsampling, etc var gifDecoder = new GifDecoder(); await gifDecoder.ReadGifAsync(imageData); ThrowIfCancellationRequested(); var bitmap = gifDecoder.GetBitmap(); ThrowIfCancellationRequested(); return(new FFGifDrawable(Context.Resources, bitmap, gifDecoder)); } finally { imageData?.Dispose(); } }
async Task <FFGifDrawable> PlatformGenerateGifImageAsync(string path, ImageSource source, Stream imageData, ImageInformation imageInformation, bool enableTransformations, bool isPlaceholder) { if (imageData == null) { throw new ArgumentNullException(nameof(imageData)); } ThrowIfCancellationRequested(); try { int downsampleWidth = 0; int downsampleHeight = 0; if (Parameters.DownSampleSize != null && (Parameters.DownSampleSize.Item1 > 0 || Parameters.DownSampleSize.Item2 > 0)) { downsampleWidth = Parameters.DownSampleSize.Item1; downsampleHeight = Parameters.DownSampleSize.Item2; } if (Parameters.DownSampleUseDipUnits) { downsampleWidth = downsampleWidth.DpToPixels(); downsampleHeight = downsampleHeight.DpToPixels(); } var gifDecoder = new GifDecoder(downsampleWidth, downsampleHeight, (bmp) => { return(PlatformTransformAsync(path, source, enableTransformations, isPlaceholder, bmp)); }); await gifDecoder.ReadGifAsync(imageData); ThrowIfCancellationRequested(); var bitmap = gifDecoder.GetBitmap(); ThrowIfCancellationRequested(); return(new FFGifDrawable(Context.Resources, bitmap, gifDecoder)); } finally { imageData.TryDispose(); } }