<分区>
我有一个字节数组,我需要将其转换为 Android Drawable。
如何执行此转换?
我已经试过了,但没有用:
fileData
是byte[]
数组
Drawable image = null;
image = new BitmapDrawable(BitmapFactory.decodeByteArray(fileData, 0, fileData.length));
<分区>
我有一个字节数组,我需要将其转换为 Android Drawable。
如何执行此转换?
我已经试过了,但没有用:
fileData
是byte[]
数组
Drawable image = null;
image = new BitmapDrawable(BitmapFactory.decodeByteArray(fileData, 0, fileData.length));
最佳答案
使用了这段代码
byte[] imageByteArray = cursor.getBlob(cursor
.getColumnIndex(SQLiteAdapter.KEY_CONTENT11));
if (imageByteArray != null) {
ByteArrayInputStream imageStream = new ByteArrayInputStream(
imageByteArray);
Bitmap company_logo = BitmapFactory
.decodeStream(imageStream);
img_logo.setBackgroundDrawable(null);
img_logo.setBackgroundDrawable(new BitmapDrawable(
getResources(), company_logo));
}
关于android - 如何将 byte [] 转换为 drawable?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17339525/