1

In One of my application i need to get bitmap form the canvas....

Actually what is my app is...

There are 2 canvas on view...

I am erasing Bitmap from canvas1 so that image from canvas 2 is displaying... (Put trasperent canvas)

Now when user presses save button it must get bitmap from canvas1 only not from view Actually the code is like this

public void onClick(View v) {

    Bitmap editedImage = Bitmap.createBitmap(drawView
                        .getDrawingCache());
    editedImage = Bitmap.createScaledBitmap(editedImage, 200, 300,
                        true);
    if (editedImage != null) {
        //Intent intent = new Intent();
        //intent.putExtra(ChooseActivity.BITMAP, editedImage);
        // AddReportItemActivity.mPhoto =
        // drawView.getDrawingCache();
        //setResult(SUCCESS, intent);
        //  finish();
        Bitmap bbicon;

But it not Bitmap that i actually want

My question is How to get bitmap from canvas..? Or any other solution?

I have visited this link But not able to understand Plz help

Community
  • 1
  • 1
Android
  • 8,995
  • 9
  • 67
  • 108
  • Your code and/or question makes no sense. I see no code relating to canvas 1 or 2. Or bitmap 1 or 2. It is pure guess work. The canvas is an editing wrapper around the bitmap. If you do something to Canvas, the bitmap that is attached is changed. So just access the correct one. – IAmGroot Aug 06 '14 at 08:45

1 Answers1

3

I am not sure what you specificaly want to achieve, however general pattern is to do it like this:

  1. Create a bitmap Bitmap.createBitmap()
  2. Create a canvas object pointing that bitmap Canvas(Bitmap)
  3. Draw any Bitmap objects to canvas (for ex. canvas.drawBitmap(getResources(), R.drawable.my_drawable), 0f, 0f, null); )
  4. Use the bitmap