I have two bitmaps and I create them in onCreate().
Bitmap bmp1 = BitmapFactory.decodeResource(getResources(),id);
Bitmap bmp2 = BitmapFactory.decodeResource(getResources(),id);
bmp1 and bmp2 are same. I modify bmp2 in my application. After my job is done, I click "Clear" button. I am trying to copy bmp1 (clean image) to bmp2(changed image) when I click "Clear" button. But I don't want to use createBitmap() or copy() function. Because these are create new Bitmap objects. I want to use only my two bitmaps (bmp1 and bmp2). How can I copy bmp1 to bmp2? I search google but everbody do this with createBitmap() or copy().
Thanks.
I solved my problem
First I created bmp1,bmp2 and canvas for bmp2:
bmp1 = BitmapFactory.decodeResource(cont.getResources(), R.drawable.image);
bmp2 = bmp1.copy(bmp1.getConfig(), true);
canvasBmp2 = new Canvas( bmp2 );
When I want to copy bmp1 to bmp2:
canvasBmp2.drawBitmap(bmp1, 0, 0, null);
@Override
protected void onDraw(Canvas canvas)
{
canvas.drawBitmap(bmp2, 0, 0, null);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With