uday
uday

Reputation: 1695

How to get ROI of an image in Android

I have an image file (.jpg) which contains image like Face. From my application i want to capture that particular Face part and copy that part into a new bitmap file. I have a rectangular co-ordinates of that Face part, so how do i capture only Face part from the image file and copy that into a bitmap file??

Could any body help me to get rid of this problem....

Upvotes: 0

Views: 1316

Answers (2)

Michiel
Michiel

Reputation: 270

You could use

bitmap1.getPixel(x,y)

on the source image and using

bitmap2.setPixel(x,y,color)

on the destination image.

There is also a respective

bitmap1.getPixels( pixelArray, offset, stride, x, y, width, height)

which is undoubtedly faster.

Upvotes: 0

xandy
xandy

Reputation: 27411

Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height) will do the creation. For save, read this: Save bitmap to location

Upvotes: 2

Related Questions