From 2b0d14f41f96d5e0c14d2ef80141049b2d024d67 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 17 Feb 2023 23:12:48 +0000 Subject: [PATCH] Resizing --- UICatalog/Scenarios/Animation.cs | 36 +++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/UICatalog/Scenarios/Animation.cs b/UICatalog/Scenarios/Animation.cs index 231b0f399..ececdb508 100644 --- a/UICatalog/Scenarios/Animation.cs +++ b/UICatalog/Scenarios/Animation.cs @@ -134,11 +134,15 @@ namespace UICatalog.Scenarios { private Image[] fullResImages; private Image[] matchSizes; + Rect oldSize = Rect.Empty; + + internal void SetImage (Image image) { frameCount = image.Frames.Count; fullResImages = new Image[frameCount]; + matchSizes = new Image[frameCount]; for(int i=0;i[frameCount]; + oldSize = bounds; + } + + var imgScaled = matchSizes[currentFrame]; + + if(imgScaled == null) + { + var imgFull = fullResImages[currentFrame]; - var lines = GetBraille(); + // keep aspect ratio + var newSize = Math.Min(bounds.Width,bounds.Height); + + // generate one + matchSizes[currentFrame] = imgFull.Clone ( + x => x.Resize ( + newSize * BitmapToBraille.CHAR_HEIGHT, + newSize * BitmapToBraille.CHAR_HEIGHT)); + + } + + var lines = GetBraille(matchSizes[currentFrame]); for(int y = 0; y < lines.Length;y++) { @@ -169,10 +197,8 @@ namespace UICatalog.Scenarios { } } - private string[] GetBraille () + private string[] GetBraille (Image img) { - var img = fullResImages[currentFrame]; - var braille = new BitmapToBraille( img.Width, img.Height,