From 8a5d14c6b518c3e77b0e183565dc68115a4e6400 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 6 Nov 2023 19:56:27 +0900 Subject: [PATCH] gif: corrected the wrong aspect ratio scaling. --- src/bindings/wasm/tvgWasm.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bindings/wasm/tvgWasm.cpp b/src/bindings/wasm/tvgWasm.cpp index 387b6e07..f2c01b76 100644 --- a/src/bindings/wasm/tvgWasm.cpp +++ b/src/bindings/wasm/tvgWasm.cpp @@ -220,7 +220,11 @@ public: return false; } - animation->picture()->size(width, height); + //keep the aspect ratio. + float ow, oh; + animation->picture()->size(&ow, &oh); + float scale = static_cast(width) / ow; + animation->picture()->size(ow * scale, oh * scale); auto saver = Saver::gen(); if (!saver) {