1、 BitMap to
inputStream:
ByteArrayOutputStream baos =
new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
InputStream isBm = new ByteArrayInputStream(baos
.toByteArray());
2、BitMap to
byte[]:
Bitmap defaultIcon =
BitmapFactory.decodeStream(in);
ByteArrayOutputStream stream = new
ByteArrayOutputStream();
defaultIcon.compress(Bitmap.CompressFormat.JPEG, 100,
stream);
byte[] bitmapdata =
stream.toByteArray();
3、Drawable to
byte[]:
Drawable d; // the drawable
(Captain Obvious, to the rescue!!!)
Bitmap
bitmap = ((BitmapDrawable)d).getBitmap();
ByteArrayOutputStream stream = new
ByteArrayOutputStream();
defaultIcon.compress(Bitmap.CompressFormat.JPEG, 100,
bitmap);
byte[] bitmapdata =
stream.toByteArray();
4、byte[] to Bitmap
:
Bitmap bitmap
=BitmapFactory.decodeByteArray(byte[], 0,byte[].length);
相关文章
- 09-28Byte[]、Image、Bitmap_之间的相互转换
- 09-28单目相机校正和Mat、Bitmap、Image<Bgr,byte>相互转换
- 09-28BitMap、Drawable、inputStream及byte[] 互转
- 09-28Image与Bitmap的区别及相互转换
- 09-28Drawable、Bitmap、byte[]之间的转换
- 09-28C# 跨线程调用form控件技巧及byte[]与string型相互转换
- 09-28byte[]和InputStream的相互转换
- 09-28Android Bitmap Drawable byte[] InputStream 相互转换方法
- 09-28Android-Drawable、Bitmap、byte[]、资源文件相互转换
- 09-28Android中 Bitmap和Drawable相互转换的方法