gif: corrected the wrong aspect ratio scaling.

This commit is contained in:
Hermet Park 2023-11-06 19:56:27 +09:00 committed by Hermet Park
parent ebe4672eff
commit 2f8c920654
2 changed files with 9 additions and 2 deletions

View file

@ -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<float>(width) / ow;
animation->picture()->size(ow * scale, oh * scale);
auto saver = Saver::gen();
if (!saver) {

View file

@ -72,7 +72,10 @@ private:
auto picture = animation->picture();
if (picture->load(in) != Result::Success) return false;
picture->size(static_cast<float>(width), static_cast<float>(height));
float width, height;
picture->size(&width, &height);
float scale = static_cast<float>(this->width) / width;
picture->size(width * scale, height * scale);
auto saver = Saver::gen();
if (saver->save(std::move(animation), out, 100, fps) != Result::Success) return false;