2013-08-31 68 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