Drawing on Image using SkaiSharp too slow.

HernandoZHernandoZ GBUniversity ✭✭

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

Best Answer

Answers

  • HernandoZHernandoZ GBUniversity ✭✭

    Thanks @seanyda it makes sense ...
    I decoded the image on the initializer.

Sign In or Register to comment.