不出去有可能的原因–图片过大
//把图片网址转换成bitmap,微信分享要用的
Glide.with(NewsDetsilsActivity.this).load(imgUrl).asBitmap().into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
//由于微信分享的图片要求在32k一下,所以要转换成缩略图
mBitmap = BitmapUtils.createBitmapThumbnail(resource, false);
}
});
/**
* 设置缩略图
*
* @param bitMap
* @param needRecycle
* @return
*/
public static Bitmap createBitmapThumbnail(Bitmap bitMap, boolean needRecycle) {
int width = bitMap.getWidth();
int height = bitMap.getHeight();
// 设置想要的大小
int newWidth = 80;
int newHeight = 80;
// 计算缩放比例
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// 取得想要缩放的matrix参数
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
// 得到新的图片
Bitmap newBitMap = Bitmap.createBitmap(bitMap, 0, 0, width, height,
matrix, true);
if (needRecycle) bitMap.recycle();
return newBitMap;
}
原文链接:https://blog.csdn.net/dl10210950/article/details/53125589