diff --git a/src/loaders/lottie/tvgLottieBuilder.cpp b/src/loaders/lottie/tvgLottieBuilder.cpp index a625722c..ae44bbc4 100644 --- a/src/loaders/lottie/tvgLottieBuilder.cpp +++ b/src/loaders/lottie/tvgLottieBuilder.cpp @@ -1042,6 +1042,7 @@ static void _updateImage(LottieGroup* layer) TaskScheduler::async(true); PP(image->picture)->ref(); + image->picture->size(image->width, image->height); } if (image->refCnt == 1) layer->scene->push(tvg::cast(image->picture)); diff --git a/src/loaders/lottie/tvgLottieModel.h b/src/loaders/lottie/tvgLottieModel.h index 9bfc5798..9790ea00 100644 --- a/src/loaders/lottie/tvgLottieModel.h +++ b/src/loaders/lottie/tvgLottieModel.h @@ -458,6 +458,8 @@ struct LottieImage : LottieObject char* mimeType = nullptr; uint32_t size = 0; uint16_t refCnt = 0; //refernce count + float width = 0.0f; + float height = 0.0f; ~LottieImage(); diff --git a/src/loaders/lottie/tvgLottieParser.cpp b/src/loaders/lottie/tvgLottieParser.cpp index e3726dcc..5fa50faf 100644 --- a/src/loaders/lottie/tvgLottieParser.cpp +++ b/src/loaders/lottie/tvgLottieParser.cpp @@ -899,7 +899,7 @@ void LottieParser::parseObject(Array& parent) } -LottieImage* LottieParser::parseImage(const char* data, const char* subPath, bool embedded) +LottieImage* LottieParser::parseImage(const char* data, const char* subPath, bool embedded, float width, float height) { //Used for Image Asset auto image = new LottieImage; @@ -922,6 +922,8 @@ LottieImage* LottieParser::parseImage(const char* data, const char* subPath, boo snprintf(image->path, len, "%s/%s%s", dirName, subPath, data); } + image->width = width; + image->height = height; image->prepare(); return image; @@ -938,6 +940,8 @@ LottieObject* LottieParser::parseAsset() //Used for Image Asset const char* data = nullptr; const char* subPath = nullptr; + float width = 0.0f; + float height = 0.0f; auto embedded = false; while (auto key = nextObjectKey()) { @@ -952,10 +956,12 @@ LottieObject* LottieParser::parseAsset() else if (KEY_AS("layers")) obj = parseLayers(); else if (KEY_AS("u")) subPath = getString(); else if (KEY_AS("p")) data = getString(); + else if (KEY_AS("w")) width = getFloat(); + else if (KEY_AS("h")) height = getFloat(); else if (KEY_AS("e")) embedded = getInt(); else skip(key); } - if (data) obj = parseImage(data, subPath, embedded); + if (data) obj = parseImage(data, subPath, embedded, width, height); if (obj) obj->id = id; return obj; } diff --git a/src/loaders/lottie/tvgLottieParser.h b/src/loaders/lottie/tvgLottieParser.h index f50f022c..e731f600 100644 --- a/src/loaders/lottie/tvgLottieParser.h +++ b/src/loaders/lottie/tvgLottieParser.h @@ -74,7 +74,7 @@ private: LottieObject* parseObject(); LottieObject* parseAsset(); - LottieImage* parseImage(const char* data, const char* subPath, bool embedded); + LottieImage* parseImage(const char* data, const char* subPath, bool embedded, float width, float height); LottieLayer* parseLayer(); LottieObject* parseGroup(); LottieRect* parseRect();