From 578c67ef0d486ab4045f9f04eb22d41b34850a8a Mon Sep 17 00:00:00 2001 From: Paddy Xu Date: Thu, 30 Aug 2018 23:46:25 +0300 Subject: [PATCH] Fix #312: scaling still wrong --- .../AnimatedImage/NativeImageProvider.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/NativeImageProvider.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/NativeImageProvider.cs index 448223d..6a5ff14 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/NativeImageProvider.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/NativeImageProvider.cs @@ -36,10 +36,10 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage public override Task GetThumbnail(Size size, Size fullSize) { - var decodeWidth = Math.Round(fullSize.Width * - Math.Min(size.Width / 2 / fullSize.Width, size.Height / 2 / fullSize.Height)); - var scale = fullSize.Width / decodeWidth; - var decodeHeight = Math.Round(fullSize.Height / scale); + var decodeWidth = (int) Math.Round(fullSize.Width * + Math.Min(size.Width / 2 / fullSize.Width, + size.Height / 2 / fullSize.Height)); + var decodeHeight = (int) Math.Round(fullSize.Height / fullSize.Width * decodeWidth); return new Task(() => { @@ -54,7 +54,8 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage (int) decodeHeight; // specific size to avoid .net's double to int conversion img.EndInit(); - var scaled = new TransformedBitmap(img, new ScaleTransform(scale, scale)); + var scaled = new TransformedBitmap(img, + new ScaleTransform(fullSize.Width / decodeWidth, fullSize.Height / decodeHeight)); scaled.Freeze(); return scaled; }