Closed justicezxz closed 3 years ago
what format are those pictures in? after base64 decoding?
Yes, like this JSON file https://skottie.skia.org/c16eee287f2cea44102b6670c66e60ab?h=1000&w=1000
Ok, this format is Lottie. We have an example scene here https://github.com/JetBrains/skija/blob/master/examples/scenes/src/SkottieScene.java
Yes, I tried, but the picture in JSON is not displayed
hi, I also encountered this problem, if there are pictures in json, how can I load pictures
If you share your source code I might be able to help you
just run the example with this json file looks like image resource is not loaded
Oh, I see. I think those are just not supported in Skia. You can open an issue here https://bugs.chromium.org/p/skia/issues/list?q=Area%3DSkottie&can=2
For pictures, skija needs to add ResourceProvider to specify the way to load resources, just like fonts
please add these two lines in AnimationBuilder.cc
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skija_skottie_AnimationBuilder__1nBuildFromFile
(JNIEnv* env, jclass jclass, jlong ptr, jstring pathStr) {
Animation::Builder* instance = reinterpret_cast<Animation::Builder*>(static_cast<uintptr_t>(ptr));
SkString path = skString(env, pathStr);
auto resource_provider =
skresources::CachingResourceProvider::Make(
skresources::DataURIResourceProviderProxy::Make(
skresources::FileResourceProvider::Make(SkOSPath::Dirname(path.c_str()),
/*predecode=*/true),
/*predecode=*/true));
instance->setResourceProvider(std::move(resource_provider));
sk_sp<Animation> animation = instance->makeFromFile(path.c_str());
return reinterpret_cast<jlong>(animation.release());
}
I’ll take a look next week!
I’ve added all three resource providers as classes to skija.resources package. See https://github.com/JetBrains/skija/blob/e265802686173485b3cc03bf6c9dca2fd364a5ed/examples/scenes/src/SkottieScene.java#L43 for an example. Source code is here, but for jars there have been some maven deployment issues, hopefully will fix them next week
Deployed as 0.93.4
hi, how to render animation with image? use json file containing Base64 pictures. I found that skia can do it.
thanks