CreateMagnifier() public static method

public static CreateMagnifier ( SKRect src, float inset, SKImageFilter input = null ) : SKImageFilter
src SKRect
inset float
input SKImageFilter
return SKImageFilter
Beispiel #1
0
        public static void MagnifierImageFilter(SKCanvas canvas, int width, int height)
        {
            canvas.Clear(SKColors.White);

            var assembly  = typeof(Demos).GetTypeInfo().Assembly;
            var imageName = assembly.GetName().Name + ".baboon.png";

            var size  = width > height ? height : width;
            var small = size / 5;

            // load the image from the embedded resource stream
            using (var resource = assembly.GetManifestResourceStream(imageName))
                using (var stream = new SKManagedStream(resource))
                    using (var bitmap = SKBitmap.Decode(stream))
                        using (var filter = SKImageFilter.CreateMagnifier(SKRect.Create(small * 2, small * 2, small * 3, small * 3), small))
                            using (var paint = new SKPaint())
                            {
                                paint.ImageFilter = filter;

                                canvas.DrawBitmap(bitmap, SKRect.Create(width, height), paint);
                            }
        }