Bitmap 生成微信分享图标

时间:2015-02-15 11:57:16   收藏:0   阅读:623

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!