diff --git a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecView.cs b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecView.cs index 42f607d68..e57a5aad4 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecView.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecView.cs @@ -319,38 +319,11 @@ public Image GetImage(PaletteState state) { // Get value from button spec passing inheritance redirector var baseImage = ButtonSpec.GetImage(_redirector, state); - if (baseImage == null) - { - return null; - } - - if (!_cachedImages.ContainsKey(baseImage)) - { - // Currently the `ViewButton.FactorDpi#`'s do _NOT_ change whilst the app is running - _lastFactorDpiX = ViewButton.FactorDpiX; - _lastFactorDpiY = ViewButton.FactorDpiY; - - var targetWidth = 16 * _lastFactorDpiX * 1.25f; - var targetHeight = 16 * _lastFactorDpiY * 1.25f; - - if ((targetWidth > baseImage.Width) && (targetHeight > baseImage.Height)) - { - // Image needs to be regenerated as oversized in order to be scaled back later - // $\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\Rendering\RenderStandard.cs - // line 5779: memento.Image = CommonHelper.ScaleImageForSizedDisplay(memento.Image, currentWidth, currentHeight); - - // Note: Something's wrong here? https://github.com/Krypton-Suite/Standard-Toolkit/issues/603 - var ratio = 1.0f * Math.Min(baseImage.Width, baseImage.Height) / Math.Max(baseImage.Width, baseImage.Height); - _cachedImages[baseImage] = - CommonHelper.ScaleImageForSizedDisplay(baseImage, baseImage.Width * ratio * _lastFactorDpiX, baseImage.Height * ratio * _lastFactorDpiY); - } - else - { - _cachedImages[baseImage] = baseImage; - } - } - - return _cachedImages[baseImage]; + + // No need to perform scaling as it will be done @ + // $\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\Rendering\RenderStandard.cs + // line 5779: memento.Image = CommonHelper.ScaleImageForSizedDisplay(memento.Image, currentWidth, currentHeight); + return baseImage; } /// diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderStandard.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderStandard.cs index 629a6ab0c..ef863c482 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderStandard.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderStandard.cs @@ -5771,31 +5771,15 @@ private static void AllocateImageSpace(StandardContentMemento memento, try { // Check for enough space to show all of the image - if ((displayRect.Width < memento.Image.Width) - || (displayRect.Height < memento.Image.Height) - ) + if ((displayRect.Width < memento.Image.Width) || + (displayRect.Height < memento.Image.Height)) { - float ratioW = float.MaxValue; - float ratioH = float.MaxValue; - if (displayRect.Width < memento.Image.Width) - { - ratioW = 1.0f * displayRect.Width / memento.Image.Width; - } - - if (displayRect.Height < memento.Image.Height) - { - ratioH = 1.0f * displayRect.Height / memento.Image.Height; - } + var ratio = 1.0f * Math.Min(memento.Image.Width, memento.Image.Height) / + Math.Max(memento.Image.Width, memento.Image.Height); + // Resize image to fit display area + memento.Image = CommonHelper.ScaleImageForSizedDisplay(memento.Image, displayRect.Width * ratio, displayRect.Height * ratio); - var useRatio = Math.Min(ratioW, ratioH); - if (useRatio > 0) - { - // Resize image to fit display area - memento.Image = CommonHelper.ScaleImageForSizedDisplay(memento.Image, - memento.Image.Width * useRatio, memento.Image.Height * useRatio); - } } - // Cache the size of the image memento.ImageRect.Size = memento.Image.Size;