copy exist bitmap avoid bitmap reuse

This commit is contained in:
王劲鹏 2022-06-24 16:21:39 +08:00 committed by osborn
parent 78ba91030f
commit a72cabe9ea

View File

@ -376,6 +376,8 @@ public class ImageNode extends ViewNode<ImageView> {
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<ImageView> {
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