0

I need to figure out a way to get a bitmap cropped without creating another bitmap that is already present.

I have two bitmaps

int width = 50;
int height = 50;

//Bitmap A
bitmapA = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bitmapA.copyPixelsFromBuffer(buffer);

//Bitmap B
bitmapB = Bitmap.createBitmap(45, 45, Bitmap.Config.ARGB_8888);

bitmapA has an image data, while bitmapB has no image data. I need a cropped image of bitmapA starting from (5, 5) and put it into bitmapB without creating another new Bitmap.

While I can do

bitmapC = Bitmap.createBitmap(bitmapA, 5, 5, 45, 45);

this will create another Bitmap object. I need to copy the data of bitmapA into the already created bitmapB without creating another Bitmap / calling createBitmap

Can this be done by using Rect?

Any ideas? thanks.

Jack Smother
  • 207
  • 1
  • 8
  • 32

0 Answers0