首页 > 微信 > 详细

Bitmap 生成微信分享图标

时间:2015-02-15 11:57:16      阅读:621      评论:0      收藏:0      [点我收藏+]

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);

 

Bitmap 生成微信分享图标

原文:http://www.cnblogs.com/lxp1314/p/4292601.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!