private UIElement Rendering(byte[] resourceStream, string title) { var control = new SKXamlCanvas(); var bmp = SKBitmap.Decode(resourceStream); var width = bmp.Info.Width; var height = bmp.Info.Height; control.Width = width; control.Height = height; control.PaintSurface += (s, e) => { var canvas = e.Surface.Canvas; canvas.DrawBitmap(bmp, 0, 0); var textPos = new SKPoint(width / 2f, height / 2f); using (var paint = new SKPaint()) { paint.TextSize = 45f; paint.IsAntialias = true; paint.TextAlign = SKTextAlign.Center; paint.Color = SKColors.Cyan; canvas.DrawText(title, textPos, paint); paint.Color = SKColors.Crimson; paint.IsStroke = true; paint.StrokeWidth = 2f; canvas.DrawText(title, textPos, paint); } }; return(control); }
public MainPage() { skiaView = new SKXamlCanvas(); skiaView.PaintSurface += OnPaintSurface; Content = skiaView; }
/// <summary> /// Initializes a new instance of the <see cref="MotionCanvas"/> class. /// </summary> public MotionCanvas() { InitializeComponent(); Loaded += OnLoaded; Unloaded += OnUnloaded; var canvas = (SKXamlCanvas)FindName("canvas"); _skiaElement = canvas; _skiaElement.PaintSurface += OnPaintSurface; }
public static void UpdateIgnorePixelScaling(this SKXamlCanvas nativeView, ISKCanvasView canvasView) => nativeView.IgnorePixelScaling = canvasView?.IgnorePixelScaling ?? false;
void Build() { Content = new SKXamlCanvas { } }