From b135ac4efbaeb40a26b790a83a320be254df748b Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sat, 22 Jun 2019 21:07:26 +0200 Subject: [PATCH] Don't create a bitmap if it is going to be zero --- source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKXamlCanvas.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKXamlCanvas.cs b/source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKXamlCanvas.cs index 58d2f62a..fc8b87aa 100644 --- a/source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKXamlCanvas.cs +++ b/source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKXamlCanvas.cs @@ -156,10 +156,11 @@ namespace SkiaSharp.Views.UWP var size = CreateSize(); var info = new SKImageInfo(size.Width, size.Height, SKImageInfo.PlatformColorType, SKAlphaType.Premul); - if (bitmap == null || bitmap.PixelWidth != info.Width || bitmap.PixelHeight != info.Height) - { - FreeBitmap(); + if (bitmap?.PixelWidth != info.Width || bitmap?.PixelHeight != info.Height) + FreeBitmap(); + if (bitmap == null && info.Width > 0 && info.Height > 0) + { bitmap = new WriteableBitmap(info.Width, info.Height); pixels = bitmap.GetPixels();