2011-11-22 83 views
2

在我的應用程序中,我使用此畫布代碼進行繪製。是否可以在圖像上繪製/繪製並在Android中擦除它?

@Override 
    protected void onDraw(Canvas canvas) { 
     Bitmap kangoo = BitmapFactory.decodeResource(getResources(),R.drawable.icon); 

     canvas.drawColor(0xFF00FF00); 
     //canvas.drawBitmap (kangoo, 200, 200, null); 
     canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint); 

     canvas.drawPath(mPath, mPaint); 

    } 

但是當我要救這個mBitmap,它不節能,我穿上了mBitmap位圖。我的意思是它沒有保存在kangoo位圖中。

那麼這段代碼有什麼錯? 謝謝。

+0

的正是你正試圖在這裏實現很不清楚 - 試圖向我們展示更多的代碼的(例如,你在哪裏嘗試廣告保存位圖),並解釋你想實現什麼 – Elemental

+0

@PolamReddyRajaReddy:你做了什麼新的?您只需從這裏複製粘貼來自開發者網站的示例:http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.html –

+0

@PolamReddyRajaReddy:Please仔細閱讀問題然後做評論或回答。我想在圖像上繪畫並對該繪畫進行擦除。這是這個演示應用程序不可能的。 –

回答

1

,如果你想在編輯之後保存圖像,你想要做這樣的事情:

view.setDrawingCacheEnabled(true); 
Bitmap bitmap=view.getDrawingCache(); 
// this creates a bitmap with whatever the drawing state of the view currently is (with your edits that is) 
//you can now save the image . 
+0

我認爲你沒有正確理解我。我的意思是我想繪製任何圖像上的油漆,然後想要保存該編輯後的圖像。而且還應該有圖像擦除的功能,但不包括圖像。 –

+0

編輯我的答案。 – rDroid

+0

在我的代碼我已經採取mBitmap保存圖像。那麼,爲什麼我必須採取另一個位圖? –