View dView = "需要截屏的view";
dView.setDrawingCacheEnabled(true);
dView.buildDrawingCache();
//获得图片bitmap
Bitmap bitmap = Bitmap.createBitmap(dView.getDrawingCache());
//本地图片转Bitmap
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.corp);
//根本屏幕宽度缩放图片达到与截取图片同宽度
int secreenWidth = getActivity().getWindowManager().getDefaultDisplay().getWidth();
float scaleWidth = ((float) secreenWidth) / width;
// 取得想要缩放的matrix参数
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleWidth);
Bitmap visiableBitmap = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(),
bmp.getHeight(), matrix, true);
//获取的拼接之后的图片
Bitmap bitmap1 = splitVertical(visiableBitmap, bitmap);
//拼接两张图片 垂直方向
public static Bitmap splitVertical(Bitmap first, Bitmap second) {
int width = Math.max(first.getWidth(), second.getWidth());
int height = first.getHeight() + second.getHeight();
Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(result);
canvas.drawBitmap(first, 0, 0, null);
canvas.drawBitmap(second, 0, first.getHeight(), null);
return result;
}