我正在开发一个关于paint的应用程序。我的要求是,每当用户触摸画布时,它应该在屏幕上添加一个位图。
我正在尝试这样的事情: -
case MotionEvent.ACTION_DOWN:
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.star);
Canvas mcanvas=new Canvas();
mcanvas.drawBitmap(bmp, 100, 100, null);
答案 0 :(得分:0)
这是一种在每个
上绘制两个位图的方法 public Bitmap PutoverBmp(Bitmap all, Bitmap scaledBorder) {
Paint paint = new Paint();
final int width = bmp.getWidth();
final int height = bmp.getHeight();
all = Bitmap.createScaledBitmap(bmp, width, height, true);
Bitmap mutableBitmap = all.copy(Bitmap.Config.ARGB_8888, true);
Canvas canvas = new Canvas(mutableBitmap);
scaledBorder = Bitmap.createScaledBitmap(bitmap_border, width, height,
true);
canvas.drawBitmap(scaledBorder, 0, 0, paint);
return mutableBitmap;
}
如下面的简单调用
Bitmap bmp1 = BitmapFactory.decodeResource(getResources(), R.drawable.star);
bmp = PutoverBmp(bmp,bmp1);