android bitmap裁剪圆形,Android 关于图片的处理------->圆形图、Glide、Bitmap的使用

public static Bitmap toConformBitmap(Bitmap head, Bitmap body, Bitmap san) {

if (head == null) {

return null;

}

int headWidth = head.getWidth();

int bodywidth = body.getWidth();

int fotwid = san.getWidth();

int headHeight = head.getHeight();

int bodyheight = body.getHeight();

int footerheight = san.getHeight();

//生成三个图片合并大小的Bitmap

Bitmap newbmp = Bitmap.createBitmap(bodywidth, headHeight + bodyheight + footerheight, Bitmap.Config.ARGB_8888);

Canvas cv = new Canvas(newbmp);

cv.drawBitmap(head, 0, 0, null);// 在 0,0坐标开始画入headBitmap

//因为手机不同图片的大小的可能小了 就绘制白色的界面填充剩下的界面

if (headWidth < bodywidth) {

Bitmap ne = Bitmap.createBitmap(kebianwidth - headWidth, headHeight, Bitmap.Config.ARGB_8888);

Canvas canvas = new Canvas(ne);

canvas.drawColor(Color.WHITE);

cv.drawBitmap(ne, headWidth, 0, null);

}

cv.drawBitmap(body, 0, headHeight, null);// 在 0,headHeight坐标开始填充课表的Bitmap

cv.drawBitmap(san, 0, headHeight + bodyheight, null);// 在 0,headHeight +bodyheight坐标开始填充课表的Bitmap

//因为手机不同图片的大小的可能小了 就绘制白色的界面填充剩下的界面

if (fotwid < bodywidth) {

Bitmap ne = Bitmap.createBitmap(bodywidth - fotwid, footerheight, Bitmap.Config.ARGB_8888);

Canvas canvas = new Canvas(ne);

canvas.drawColor(Color.WHITE);

cv.drawBitmap(ne, fotwid, headHeight + bodyheight, null);

}

cv.save(Canvas.ALL_SAVE_FLAG);// 保存

cv.restore();// 存储

//回收

head.recycle();

body.recycle();

san.recycle();

return newbmp;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值