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