效果图:
第一种:
第二种:
第一种是通过canvas画出来的效果:
public void first(View v) {
// 防止出现Immutable bitmap passed to Canvas constructor错误
Bitmap bitmap1 = BitmapFactory.decodeResource(getResources(),
R.drawable.apple).copy(Bitmap.Config.ARGB_8888, true);
Bitmap bitmap2 = ((BitmapDrawable) getResources().getDrawable(
R.drawable.go)).getBitmap();
Bitmap newBitmap = null;
newBitmap = Bitmap.createBitmap(bitmap1);
Canvas canvas = new Canvas(newBitmap);
Paint paint = new Paint();
int w = bitmap1.getWidth();
int h = bitmap1.getHeight();
int w_2 = bitmap2.getWidth();
int h_2 = bitmap2.getHeight();
paint.setColor(Color.GRAY);
paint.setAlpha(125);