How can crop rectangle area?

Adnan KA picture Adnan KA · Jul 27, 2015 · Viewed 7.3k times · Source

Hi i am working on android application to detect page number using camera preview. After I received frame I draw a rectangle on surface view Using Canvas and I want to crop the rectangle area to put it in a bitmap, so please how can I do it ?as shown here

Answer

Bajji picture Bajji · Jul 27, 2015

If you have the bitmap of the frame, you can use

Bitmap croppedBmp = Bitmap.createBitmap(originalBmp, rectanglePositionX, rectanglePositionY, rectangleWidth, rectangleHeight);

Assuming you know where your rectangle is positioned and its dimensions.