Ejemplo n.º 1
0
        public async Task <FormsCAKeyFrameAnimation> LoadImageAnimationAsync(ImageSource imagesource, CancellationToken cancelationToken = default(CancellationToken), float scale = 1)
        {
            FormsCAKeyFrameAnimation animation = await ImageAnimationHelper.CreateAnimationFromUriImageSourceAsync(imagesource as UriImageSource, cancelationToken).ConfigureAwait(false);

            if (animation == null)
            {
                Log.Warning(nameof(FileImageSourceHandler), "Could not find image: {0}", imagesource);
            }

            return(animation);
        }
Ejemplo n.º 2
0
        public Task <FormsCAKeyFrameAnimation> LoadImageAnimationAsync(ImageSource imagesource, CancellationToken cancelationToken = default(CancellationToken), float scale = 1)
        {
            FormsCAKeyFrameAnimation animation = ImageAnimationHelper.CreateAnimationFromFileImageSource(imagesource as FileImageSource);

            if (animation == null)
            {
                Log.Warning(nameof(FileImageSourceHandler), "Could not find image: {0}", imagesource);
            }

            return(Task.FromResult(animation));
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }