1、缩放图片尺寸:
Bitmap bitmap = ThumbnailUtils.extractThumbnail(share_bitmap, 200, 200);
2、调用这个方法:
public static byte[] bmpToByteArray(Bitmap bmp, boolean needRecycle) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
int options = 100;
bmp.compress(Bitmap.CompressFormat.JPEG, options, output);
byte[] result = output.toByteArray();
while (result.length > 32768) {
output.reset();
options -= 5;
bmp.compress(Bitmap.CompressFormat.JPEG, options, output);
result = output.toByteArray();
}
if (needRecycle) {
bmp.recycle();
}
try {
output.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
错误不足之处或相关建议欢迎大家评论指出,谢谢!如果觉得内容可以的话麻烦喜欢(♥)一下