参考:https://blog.csdn.net/dl10210950/article/details/53125589
https://blog.csdn.net/yaya_soft/article/details/11077155
这是因为微信对缩略图做了限制,最大不超过32K
所以可以先通过图片加载工具获取bitmap,然后进行压缩,压缩方法如下:
//压缩图片
public Bitmap createBitmapThumbnail(Bitmap bitMap) {
int width = bitMap.getWidth();
int height = bitMap.getHeight();
// 设置想要的大小
int newWidth = 99;
int newHeight = 99;
// 计算缩放比例
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// 取得想要缩放的matrix参数
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
// 得到新的图片
Bitmap newBitMap = Bitmap.createBitmap(bitMap,