Shreyash Mahajan
Shreyash Mahajan

Reputation: 23606

Is it possible to Draw/paint on to image and also to erase it in android?

In My Application i am using this canvas code to paint.

 @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);

    }

But while i am going to save this mBitmap, it is not saving the bitmap that i have put on the mBitmap. I mean it is not saved with the kangoo bitmap.

So whats the wrong in this code ? Thanks.

Upvotes: 2

Views: 488

Answers (1)

rDroid
rDroid

Reputation: 4945

if you want to save the image after editing it, you want to do something like this :

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 .

Upvotes: 1

Related Questions