Avoid debugger crashing the whole app

Cleaned up bitmap brush
This commit is contained in:
Robert committed 2019-12-11 19:35:38 +01:00
1 parent a2871541b9
commit e5d7dbae26
3 files changed
+18 -18

No files matched your search

@@ -49,17 +49,24 @@ namespace Artemis.UI.Screens.Settings.Debug
return;
}
using (var skiaImage = SKImage.FromPixels(e.BitmapBrush.Bitmap.PeekPixels()))
try
{
var info = new SKImageInfo(skiaImage.Width, skiaImage.Height);
writeableBitmap.Lock();
using (var pixmap = new SKPixmap(info, writeableBitmap.BackBuffer, writeableBitmap.BackBufferStride))
using (var skiaImage = SKImage.FromPixels(e.BitmapBrush.Bitmap.PeekPixels()))
{
skiaImage.ReadPixels(pixmap, 0, 0);
}
var info = new SKImageInfo(skiaImage.Width, skiaImage.Height);
writeableBitmap.Lock();
using (var pixmap = new SKPixmap(info, writeableBitmap.BackBuffer, writeableBitmap.BackBufferStride))
{
skiaImage.ReadPixels(pixmap, 0, 0);
}
writeableBitmap.AddDirtyRect(new Int32Rect(0, 0, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight));
writeableBitmap.Unlock();
writeableBitmap.AddDirtyRect(new Int32Rect(0, 0, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight));
writeableBitmap.Unlock();
}
}
catch (AccessViolationException)
{
// oops
}
});
}