Example #1
0
        static public FormsCAKeyFrameAnimation CreateAnimationFromFileImageSource(FileImageSource imageSource)
        {
            FormsCAKeyFrameAnimation animation = null;
            string file = imageSource?.File;

            if (!string.IsNullOrEmpty(file))
            {
                using (var parsedImageSource = CGImageSource.FromUrl(NSUrl.CreateFileUrl(file, null)))
                {
                    animation = ImageAnimationHelper.CreateAnimationFromCGImageSource(parsedImageSource);
                }
            }

            return(animation);
        }
Example #2
0
        static public async Task <FormsCAKeyFrameAnimation> CreateAnimationFromUriImageSourceAsync(UriImageSource imageSource, CancellationToken cancelationToken = default(CancellationToken))
        {
            FormsCAKeyFrameAnimation animation = null;

            if (imageSource?.Uri != null)
            {
                using (var streamImage = await imageSource.GetStreamAsync(cancelationToken).ConfigureAwait(false))
                {
                    if (streamImage != null)
                    {
                        using (var parsedImageSource = CGImageSource.FromData(NSData.FromStream(streamImage)))
                        {
                            animation = ImageAnimationHelper.CreateAnimationFromCGImageSource(parsedImageSource);
                        }
                    }
                }
            }

            return(animation);
        }