lxp1314

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

 

分类:

技术点:

相关文章:

  • 2021-07-30
  • 2021-08-26
  • 2021-11-23
  • 2021-09-27
  • 2021-12-01
  • 2021-10-13
  • 2021-11-19
  • 2021-12-28
猜你喜欢
  • 2021-11-13
  • 2021-12-15
  • 2021-11-22
  • 2021-11-02
  • 2021-11-10
  • 2021-11-18
  • 2021-11-23
相关资源
相似解决方案