标签:
android开发调用微信分享接口在设置分享图标时,必须对原图进行压缩处理,否则分享出来的图标会不清晰。据本人了解,微信分享的图标大小是132px*132px的。
下面给出方法
1 public static Bitmap crateWeixinShareIcon(Bitmap bmp, int target) { 2 int width = bmp.getWidth(); 3 int height = bmp.getHeight(); 4 5 if (width < target || height < target) 6 return bmp; 7 8 Bitmap bmpnew; 9 if (width > height) { 10 bmpnew = Bitmap.createBitmap(bmp, (width - height) / 2, 0, height, 11 height); 12 } else { 13 bmpnew = Bitmap.createBitmap(bmp, 0, (height - width) / 2, width, 14 width); 15 } 16 17 Bitmap result = Bitmap.createScaledBitmap(bmpnew, target, target, true); 18 bmpnew.recycle(); 19 return result; 20 }
调用
1 Bitmap shareIcon = Common.crateWeixinShareIcon(bmp, 132);
标签:
原文地址:http://www.cnblogs.com/lxp1314/p/4292601.html