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); drawable.setDither(true);
super.setResource(drawable); super.setResource(drawable);
} else if (stretchInset != null) { } else if (stretchInset != null) {
Bitmap newBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, false);
float left = stretchInset.getProperty("left").asNumber().toFloat() * scale; float left = stretchInset.getProperty("left").asNumber().toFloat() * scale;
float top = stretchInset.getProperty("top").asNumber().toFloat() * scale; float top = stretchInset.getProperty("top").asNumber().toFloat() * scale;
float right = stretchInset.getProperty("right").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( Rect rect = new Rect(
(int) left, (int) left,
(int) top, (int) top,
(int) (bitmap.getWidth() - right), (int) (newBitmap.getWidth() - right),
(int) (bitmap.getHeight() - bottom) (int) (newBitmap.getHeight() - bottom)
); );
NinePatchDrawable ninePatchDrawable = new NinePatchDrawable( NinePatchDrawable ninePatchDrawable = new NinePatchDrawable(
getContext().getResources(), getContext().getResources(),
bitmap, newBitmap,
DoricUtils.getNinePatchChunk(rect), DoricUtils.getNinePatchChunk(rect),
rect, rect,
null null