I am accessing the SKCanvas of an SKSurface in my PaintSurface function. This function fires and I get the error: System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'
private async void cnv_PaintSurface(object sender, SKPaintSurfaceEventArgs e)
{
SKSurface surface = e.Surface;
SKCanvas canvas = surface.Canvas;
**SkiaSharp.Extended.Svg.SKSvg svg = new SkiaSharp.Extended.Svg.SKSvg();
svg.Load(await GetStream());**
using (SKPaint paint = new SKPaint())
{
canvas.Clear(Colors.Black.ToSKColor()); //here is the error
canvas.DrawPicture(svg.Picture, paint);
}
}
private static async Task<Stream> GetStream()
{
StorageFile file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("car.svg");
var inputStream = await file.OpenReadAsync();
return inputStream.AsStreamForRead();
}```