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

Drawing on Image using SkaiSharp too slow.

$
0
0

Hi,

In developing an app for the user to take a picture and draw on the image, is all good so far using the media plugin to get image and skiasharp to draw on the image but drawing on the image is very slow, the image file size is about a 1MB .

this is the method to load the image and fingerpaint (from Demo)

 void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {

            SKCanvas canvas = args.Surface.Canvas;
            canvas.Clear();

            SKBitmap resourceBitmap = SKBitmap.Decode(MediaFile.ContentAsBytes);
            canvas.DrawBitmap(resourceBitmap, 0, 0);

            foreach (FingerPaintPolyline polyline in completedPolylines)
            {
                paint.Color = polyline.StrokeColor.ToSKColor();
                paint.StrokeWidth = polyline.StrokeWidth;
                canvas.DrawPath(polyline.Path, paint);
            }

            foreach (FingerPaintPolyline polyline in inProgressPolylines.Values)
            {
                paint.Color = polyline.StrokeColor.ToSKColor();
                paint.StrokeWidth = polyline.StrokeWidth;
                canvas.DrawPath(polyline.Path, paint);
            }
        }

I think the problem is that the view is refreshing for each stroke and I gets slower and slower .

How can improve this ?

thanks

Hernando


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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