2013-08-31 144 views

回答

0

您可以通过下面的代码绘制位图:

ImageView mImage = (ImageView) findViewById(R.id.iv_coloring_figure); 
    BitmapDrawable drawable = (BitmapDrawable) mImage.getDrawable(); 
    Bitmap bmp = drawable.getBitmap(); 
    Bitmap bitmap = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), Bitmap.Config.ARGB_8888); 
    Canvas canvas = new Canvas(_alteredBitmap); 
    Paint paint = new Paint(); 
    Matrix matrix = new Matrix(); 
    canvas.drawBitmap(bmp, matrix, paint); 
    mImage.setImageBitmap(bitmap); 

现在用于创建位图时,根据图像的来源不同的方法。在这里,我将图像设置为ImageView,并从该图像创建一个位图并在画布上绘制。

编辑: 好吧,从你最后的评论,我才知道你想要什么。 Here是使用SurfaceView的一个很好的例子。如果你是游戏编程的初学者,你可以一步一步地通过这个tutorial

+0

如果我需要移动画布中的位图图像,那么我应该如何在这种情况下使用线程? – Paramita

+0

你是什么意思移动位图,请多解释一下。 – 2013-08-31 09:22:43

+0

意思是我想移动位图中包含的图像。在任何游戏中,游戏主题的背景都会自动移动。我只是想不断移动背景...... – Paramita