原文:http://wuxiaolong.me/2015/08/10/Drawable-to-Bitmap/
Drawable互转Bitmap
Drawable转Bitmap
1 | Resources res = getResources(); |
1 | public static Bitmap drawableToBitmap(Drawable drawable) { |
Bitmap转Drawable
1 | Bitmap bm=xxx; //xxx根据你的情况获取 |
String与InputStream相互转换
String to InputStream
1 | String str = "String与InputStream相互转换"; |
InputStream to String
这里提供几个方法。
方法1:
1 | public String convertStreamToString(InputStream is) { |
方法2:
1 | public String inputStream2String (InputStream in) throws IOException { |
方法3:
1 | public static String inputStream2String(InputStream is) throws IOException{ |
Bitmap 和 byte[]互转
Bitmap → byte[]
1 | private byte[] Bitmap2Bytes(Bitmap bm){ |
byte[] → Bitmap
1 | private Bitmap Bytes2Bimap(byte[] b){ |