首页  编辑  

安卓位图和流的转换

Tags: /Android/   Date Created:
流转位图:
bitmapOption.inMutable = true;
bitmap = BitmapFactory.decodeByteArray(stream.toByteArray(), 0, stream.size(), bitmapOption);

位图转流:
ByteBuffer buf = ByteBuffer.allocate(bitmap.getByteCount());
bitmap.copyPixelsToBuffer(buf);
byte[] rawBytes = buf.array();