From 7f95a3be88926b3f274c64db93cf654b6866571a Mon Sep 17 00:00:00 2001 From: Henrich Date: Mon, 29 Oct 2018 17:11:27 +0100 Subject: [PATCH] fix AccessViolationException during creating Exception --- src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs b/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs index b2c936d6ad..5efbc0861e 100644 --- a/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs @@ -143,23 +143,26 @@ namespace Avalonia.Skia // Create bitmap using default platform settings _bitmap = new SKBitmap(destinationInfo.Width, destinationInfo.Height); + SKColorType bitmapColorType; if (!_bitmap.CanCopyTo(destinationInfo.ColorType)) { + bitmapColorType = _bitmap.ColorType; _bitmap.Dispose(); throw new Exception( - $"Unable to create pixel format shim for conversion from {_bitmap.ColorType} to {destinationInfo.ColorType}"); + $"Unable to create pixel format shim for conversion from {bitmapColorType} to {destinationInfo.ColorType}"); } Surface = SKSurface.Create(_bitmap.Info, _bitmap.GetPixels(), _bitmap.RowBytes); if (Surface == null) { + bitmapColorType = _bitmap.ColorType; _bitmap.Dispose(); throw new Exception( - $"Unable to create pixel format shim surface for conversion from {_bitmap.ColorType} to {destinationInfo.ColorType}"); + $"Unable to create pixel format shim surface for conversion from {bitmapColorType} to {destinationInfo.ColorType}"); } SurfaceCopyHandler = Disposable.Create(CopySurface);