diff options
author | Nguyen Huy Nghia <nghianh@hblab.vn> | 2024-05-14 21:53:09 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-14 10:53:09 -0400 |
commit | 13bed129980592cfaeda65527ece613ac3f0e2ef (patch) | |
tree | 48b1522e804f3b08d41b9e3900d084bc124e03e2 | |
parent | aebf9bc07bc54979633f3355ada3d3e6e12986a3 (diff) | |
download | lottie-upstream-master.tar.gz |
Fix base64 image asset not fit container's size (#2501)upstream-master
Currently, I am encountering a similar issue to [#1200](https://github.com/airbnb/lottie-android/issues/1200), but in the case where the asset is a base64 image, it has not been fixed yet.
-rw-r--r-- | lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java | 4 | ||||
-rw-r--r-- | lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java b/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java index 7b0f9e77..d2eaa3bb 100644 --- a/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java +++ b/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java @@ -640,7 +640,9 @@ public class LottieCompositionFactory { Logger.warning("data URL did not have correct base64 format.", e); return null; } - asset.setBitmap(BitmapFactory.decodeByteArray(data, 0, data.length, opts)); + Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, opts); + bitmap = Utils.resizeBitmapIfNeeded(bitmap, asset.getWidth(), asset.getHeight()); + asset.setBitmap(bitmap); } } } diff --git a/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java b/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java index 51bd27e2..fb491ca5 100644 --- a/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java +++ b/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java @@ -107,7 +107,8 @@ public class ImageAssetManager { return null; } bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, opts); - return putBitmap(id, bitmap); + Bitmap resizedBitmap = Utils.resizeBitmapIfNeeded(bitmap, asset.getWidth(), asset.getHeight()); + return putBitmap(id, resizedBitmap); } InputStream is; |