From 8fa983d5bcecdf7030434d96777b8939fff9b8db Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 7 May 2020 19:43:35 -0300 Subject: [PATCH] image class will not make invalid render calls if its size is 0 causing divide by zero and passing .NaN to drawing context. --- src/Avalonia.Controls/Image.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Image.cs b/src/Avalonia.Controls/Image.cs index 8d249fe790..9550aebc41 100644 --- a/src/Avalonia.Controls/Image.cs +++ b/src/Avalonia.Controls/Image.cs @@ -69,10 +69,11 @@ namespace Avalonia.Controls { var source = Source; - if (source != null) + if (source != null && Bounds.Size != Size.Empty) { Rect viewPort = new Rect(Bounds.Size); Size sourceSize = source.Size; + Vector scale = Stretch.CalculateScaling(Bounds.Size, sourceSize, StretchDirection); Size scaledSize = sourceSize * scale; Rect destRect = viewPort