From a72cabe9eacca64a1edd51c3dfe02bcfe1239a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Fri, 24 Jun 2022 16:21:39 +0800 Subject: [PATCH] copy exist bitmap avoid bitmap reuse --- .../doric/src/main/java/pub/doric/shader/ImageNode.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doric-android/doric/src/main/java/pub/doric/shader/ImageNode.java b/doric-android/doric/src/main/java/pub/doric/shader/ImageNode.java index 8b1e1c08..f5cf772a 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/ImageNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/ImageNode.java @@ -376,6 +376,8 @@ public class ImageNode extends ViewNode { drawable.setDither(true); super.setResource(drawable); } else if (stretchInset != null) { + Bitmap newBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, false); + float left = stretchInset.getProperty("left").asNumber().toFloat() * scale; float top = stretchInset.getProperty("top").asNumber().toFloat() * scale; float right = stretchInset.getProperty("right").asNumber().toFloat() * scale; @@ -384,13 +386,13 @@ public class ImageNode extends ViewNode { Rect rect = new Rect( (int) left, (int) top, - (int) (bitmap.getWidth() - right), - (int) (bitmap.getHeight() - bottom) + (int) (newBitmap.getWidth() - right), + (int) (newBitmap.getHeight() - bottom) ); NinePatchDrawable ninePatchDrawable = new NinePatchDrawable( getContext().getResources(), - bitmap, + newBitmap, DoricUtils.getNinePatchChunk(rect), rect, null