我已经添加三个不同的bitmap
到一个ImageView
如下图所示。但问题是我无法编辑Bitmap
设置为ImageView
后。 我要拖动,滚动&放大个人Bitmap
在ImageView
。三角形ImageView与拖动,滚动和缩放onTouch Android
我对获得合并bitmap
代码:
Bitmap setBitmapInTriangleShape(Bitmap bitmap1, Bitmap bitmap2,
Bitmap bitmap3) {
/*
* int[] values= new int[2]; mImageView.getLocationOnScreen(values);
*/
double screenHeightAspect = 2.5;
Bitmap drawnBitmap = null;
bitmap1 = Bitmap.createScaledBitmap(bitmap1, screenWidth,
(int) (screenHeight/screenHeightAspect), true);
bitmap2 = Bitmap.createScaledBitmap(bitmap2, screenWidth,
(int) (screenHeight/screenHeightAspect), true);
bitmap3 = Bitmap.createScaledBitmap(bitmap3, screenWidth,
(int) (screenHeight/screenHeightAspect), true);
try {
drawnBitmap = Bitmap
.createBitmap(screenWidth,
(int) (screenHeight/screenHeightAspect),
Config.ARGB_8888);
Canvas canvas = new Canvas(drawnBitmap);
canvas.drawColor(Color.TRANSPARENT);
// ---------------------------------------------------------------
Paint paint = new Paint();
paint.setStrokeWidth(4);
paint.setColor(getResources().getColor(
R.color.gray_divider_reg_edit_grid_1));
paint.setStyle(Paint.Style.FILL_AND_STROKE);
Path path = new Path();
BitmapShader bms = new BitmapShader(bitmap1, TileMode.CLAMP,
TileMode.CLAMP);
paint.setStyle(Style.FILL);
paint.setShader(bms);
// bms.setLocalMatrix(matrix);
// -----------------=for photo 1-----------------------------
path.reset();
path.setFillType(Path.FillType.EVEN_ODD);
path.lineTo(0, 0);
path.lineTo((int) (screenWidth * 0.80), 0);
// path.lineTo(0, 15);
path.lineTo(0, (int) (screenHeight * 0.8706/screenHeightAspect));
path.close();
canvas.drawPath(path, paint);
Matrix mt = new Matrix();
canvas.drawBitmap(bitmap1, new Matrix(), null);
// -------------------for photo 3-----------------------------
BitmapShader bmsUo = new BitmapShader(bitmap3, TileMode.CLAMP,
TileMode.CLAMP);
paint.setStyle(Style.FILL);
paint.setShader(bmsUo);
// bms.setLocalMatrix(matrix);
path.reset();
path.setFillType(Path.FillType.EVEN_ODD);
path.moveTo((int) (screenWidth * 0.80), 0);
path.lineTo((int) (screenWidth * 0.80), 0);
path.lineTo(screenWidth, 0);
path.lineTo(screenWidth, (int) (screenHeight/screenHeightAspect));
// path.lineTo(800,800);
path.lineTo((int) (screenWidth * 0.88),
(int) (screenHeight/screenHeightAspect));
path.lineTo((int) (screenWidth * 0.50),
(int) (screenHeight * 0.32/screenHeightAspect));
path.close();
canvas.drawPath(path, paint);
// ---------------------for photo 2-------------------------
BitmapShader bmsUop = new BitmapShader(bitmap2, TileMode.CLAMP,
TileMode.CLAMP);
paint.setStyle(Style.FILL);
paint.setShader(bmsUop);
// bmsUop.setLocalMatrix(matrix);
path.reset();
path.setFillType(Path.FillType.EVEN_ODD);
path.moveTo((int) (screenWidth * 0.50),
(int) (screenHeight * 0.32/screenHeightAspect));
path.lineTo((int) (screenWidth * 0.50),
(int) (screenHeight * 0.32/screenHeightAspect));
path.lineTo((int) (screenWidth * 0.88),
(int) (screenHeight/screenHeightAspect));
path.lineTo(0, (int) (screenHeight/screenHeightAspect));
path.lineTo(0, (int) (screenHeight/screenHeightAspect * 0.8706));
path.close();
canvas.drawPath(path, paint);
} catch (Exception e) {
e.printStackTrace();
}
return drawnBitmap;
}
任何帮助表示赞赏。
是此画在画布上,并获取位图,然后将bitmpa设置为imageView – Triode
你可以使用蒙版和画布来实现: http://stackoverflow.com/questions/14801075/android-how-to-apply-mask-on-imageview –
你能显示在画布上绘制三角形图像的示例代码? @Rajesh CP – OAEI