mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
lottie: compatibility++
retry image loading with the given candidates, even if the suggested format is mismatched.
This commit is contained in:
parent
6b6947f679
commit
c89f6253bf
1 changed files with 13 additions and 8 deletions
|
@ -727,17 +727,22 @@ 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.
|
||||||
delete(picture);
|
const char* type[] = {image->mimeType, "png", "jpg", "webp"};
|
||||||
return;
|
for (int i = 0; i < 4; ++i) {
|
||||||
}
|
if (picture->load((const char*)image->b64Data, image->size, type[i]) == Result::Success) {
|
||||||
} else {
|
succeed = true;
|
||||||
if (picture->load(image->path) != Result::Success) {
|
break;
|
||||||
delete(picture);
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
} else if (picture->load(image->path) != Result::Success) succeed = true;
|
||||||
|
|
||||||
|
if (!succeed) {
|
||||||
|
delete(picture);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskScheduler::async(true);
|
TaskScheduler::async(true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue