Esempio n. 1
0
        public static PImage ToImage(this NSData data, CGSize destSize, nfloat destScale, Configuration config, TaskParameter parameters, BaseDecoder.RCTResizeMode resizeMode = BaseDecoder.RCTResizeMode.ScaleAspectFit, ImageInformation imageinformation = null, bool allowUpscale = false)
        {
            var decoded = BaseDecoder.SourceRegfToDecodedImage(data, destSize, destScale, config, parameters, resizeMode, imageinformation, allowUpscale);

            PImage result;

            if (decoded.IsAnimated)
            {
#if __IOS__
                result = PImage.CreateAnimatedImage(decoded.AnimatedImages
                                                    .Select(v => v.Image)
                                                    .Where(v => v?.CGImage != null).ToArray(), decoded.AnimatedImages.Sum(v => v.Delay) / 100.0);
#elif __MACOS__
                result = new PImage();
                var repr = decoded.AnimatedImages
                           .Select(v => v.Image.Representations().First())
                           .ToArray();
                result.AddRepresentations(repr);
#endif
            }
            else
            {
                result = decoded.Image;
            }

            return(result);
        }
        public static NSImage LoadImageFromSvg(this string svg, Size size, NSColor color = null)
        {
            var normal        = svg.LoadImageFromSvg(size, 1, color).ToImageRep();
            var retina        = svg.LoadImageFromSvg(size, 2, color).ToImageRep();
            var combinedImage = new NSImage();

            combinedImage.MatchesOnMultipleResolution = true;
            combinedImage.AddRepresentations(new NSImageRep [] { normal, retina });
            return(combinedImage);
        }