thorvg / thorvg.viewer

ThorVG Viewer is a browser-based rendering tool that shows you the image result of vector resource formats, such as SVG and Lottie. It's powered by the ThorVG engine.
https://www.thorvg.org
MIT License
19 stars 7 forks source link

Major Upgrade: Integrate `@thorvg/lottie-player` #23

Closed tinyjin closed 8 months ago

tinyjin commented 9 months ago
tinyjin commented 9 months ago

@hermet I found a bug, that after exporting gif, gif exported well but the lottie-player isn't working. Seems not related to viewer, need to fix and update on thorvg/web side.

Since viewer heads latest version of @thorvg/lottie-player, we can ignore it for this step. Once I fix it from core, it will then work well.

Except the bug, think everything's good.

hermet commented 9 months ago

@tinyjin Hmm... There is no point to update the software if it hurts the functionality. It's not professional.

tinyjin commented 9 months ago

Yup, actually working on fixing last bug, I meant you can review the code while im doing on it, sorry for confusing, yes it will be definately updated together

hermet commented 9 months ago

Probably, this is a considerable solution

#include "tvgPicture.h"

bool save2Gif() {
        //acquire the picture data(lottie) from the current animation
        uint32_t size = 0;
        //LoadModule/Picture::Impl additionally needs the interface for this.
        //uint32_t* data(uint32_t& size);
        auto data = P(this->animation->picture())->data(size);

        //Copy a new animation to save
        auto animation = Animation::gen();
        auto picture = animation->picture();
        //Use the retained the above lottie data
        picture->load(data, size, "lottie");

        //Save it as it normal.
        auto saver = Saver::gen();
        if (!saver) {
            errorMsg = "Invalid saver";
            return false;
        }

        //set a white opaque background
        auto bg = tvg::Shape::gen();
        bg->fill(255, 255, 255, 255);
        bg->appendRect(0, 0, width, height);

        saver->background(std::move(bg));        

        if (saver->save(std::move(animation), "output.gif", 100, 30) != tvg::Result::Success) {
            errorMsg = "save(), fail";
            return false;
        }

        saver->sync();
}
tinyjin commented 8 months ago

@hermet fyi. This patch will use thorvg v0.11.6 again.

tinyjin commented 8 months ago

This patch will close #21 as initialization logic changed.

hermet commented 8 months ago

@hermet fyi. This patch will use thorvg v0.11.6 again.

any reason?

tinyjin commented 8 months ago

@hermet fyi. This patch will use thorvg v0.11.6 again.

any reason?

Sorry for the confusion! I was trying to say it will temporaily head main branch.

it's not reverting.