标签:android blog os java ar for 文件 div log
/** * 将图片转换成十六进制字符串 * @param photo * @return */ public static String sendPhoto(ImageView photo) { Drawable d = photo.getDrawable(); Bitmap bitmap=((BitmapDrawable)d).getBitmap(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);// (0 - 100)压缩文件 byte[] bt = stream.toByteArray(); String photoStr = byte2hex(bt); return photoStr; } /** * 二进制转字符串 * @param b * @return */ public static String byte2hex(byte[] b) { StringBuilder sb = new StringBuilder(); String stmp = ""; for (int n = 0; n < b.length; n++) { stmp = Integer.toHexString(b[n] & 0XFF); if (stmp.length() == 1) { sb.append("0" + stmp); } else { sb.append(stmp); } } return sb.toString(); }
标签:android blog os java ar for 文件 div log
原文地址:http://www.cnblogs.com/xxdc/p/3954332.html