android 图片与byte数组间的转换

http://lzqfree.blog.163.com/blog/static/7875376320117294372687/
1、Bitmap → byte[]
private byte[] Bitmap2Bytes(Bitmap bm){   
    ByteArrayOutputStream baos = new ByteArrayOutputStream();     
    bm.compress(Bitmap.CompressFormat.PNG, 100, baos);     
    return baos.toByteArray();   
} 

 

2、byte[] → Bitmap

private Bitmap Bytes2Bimap(byte[] b){   
    if(b.length!=0){
        return BitmapFactory.decodeByteArray(b, 0, b.length);
    } else {
        return null;
    }
}


你可能感兴趣的:(Android)