mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
gif: corrected the wrong aspect ratio scaling.
This commit is contained in:
parent
ebe4672eff
commit
2f8c920654
2 changed files with 9 additions and 2 deletions
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue