Q:为什么使用微信SDK分享信息给微信好友,有的消息发送成功,有的消息发送失败(打不开微信)?(New)
A:这是因为SDK协议中对缩略图的大小作了限制,大小不能超过32K。另外限制的还有title、description等参数的大小。iOS开发者请在微信开放平台网站iOS手册搜索“thumbData”, Android开发者请见微信开放平台网站Android手册的“WXMediaMessage”页面。
原因是分享的缩略图超过了32k
==============
图片压缩示例如下(也可用其他方法压缩):
- 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, 0, 0, width, height,
- matrix, true);
- return newBitMap;
- }