lottie: compatibility++

retry image loading with the given candidates,
even if the suggested format is mismatched.
This commit is contained in:
Hermet Park 2024-01-31 16:03:44 +09:00 committed by Hermet Park
parent 6b6947f679
commit c89f6253bf

View file

@ -727,18 +727,23 @@ static void _updateImage(LottieGroup* parent, LottieObject** child, float frameN
//force to load a picture on the same thread //force to load a picture on the same thread
TaskScheduler::async(false); TaskScheduler::async(false);
auto succeed = false;
if (image->size > 0) { if (image->size > 0) {
if (picture->load((const char*)image->b64Data, image->size, image->mimeType) != Result::Success) { //try all, just in case.
const char* type[] = {image->mimeType, "png", "jpg", "webp"};
for (int i = 0; i < 4; ++i) {
if (picture->load((const char*)image->b64Data, image->size, type[i]) == Result::Success) {
succeed = true;
break;
}
}
} else if (picture->load(image->path) != Result::Success) succeed = true;
if (!succeed) {
delete(picture); delete(picture);
return; return;
} }
} else {
if (picture->load(image->path) != Result::Success) {
delete(picture);
return;
}
}
TaskScheduler::async(true); TaskScheduler::async(true);