Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

SkiaSharp canvas.Draw

$
0
0

I am trying to draw a bitmap that contains image info. I want to draw the bitmap so that it is drawn on the full surface of the screen. Here is the code I have currently:

    /// <summary>
    /// Paints the surface of the canvas view with the dictionary of paths that has been created
    /// </summary>
    private void PaintCanvasViewSurface(object sender, SKPaintSurfaceEventArgs args)
    {
        canvas = args.Surface.Canvas;

        float gridHeight = (float)imageGrid.Height;
        float gridWidth = (float)imageGrid.Width;
        size = new SKSize(gridWidth, gridHeight);
        rect = SKRect.Create(size);

        canvas.DrawBitmap(bitmap, rect, null);

        foreach (SKPath path in completedPaths)
            canvas.DrawPath(path, paint);

        foreach (SKPath path in inProgressPaths.Values)
            canvas.DrawPath(path, paint);
    }

This works on UWP, but on Android only draws the bitmap so that it takes up 1/3 of the height and 1/3 of the width. canvas.DrawBitmap(bitmap, 0, 0) works on Android, but produces an undersized image on UWP.

Any suggestions or alternative approaches?

Thanks in advance.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>