I want to create a bitmap from a bytearray .
I tried the following codes
Bitmap bmp;
bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
and
ByteArrayInputStream bytes = new ByteArrayInputStream(data);
BitmapDrawable bmd = new BitmapDrawable(bytes);
bmp = bmd.getBitmap();
But ,When i am tring to initialize the Canvas object with the bitmap like
Canvas canvas = new Canvas(bmp);
It leads to an error
java.lang.IllegalStateException: Immutable bitmap passed to Canvas constructor
Then how to get a mutable bitmap from an byteArray.
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…