0

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....

Rais Alam
  • 6,970
  • 12
  • 53
  • 84
uday
  • 1,625
  • 3
  • 14
  • 16

2 Answers2

2

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

Community
  • 1
  • 1
xandy
  • 27,357
  • 8
  • 59
  • 64
  • That is way easier than what I suggested. You should do that. – Michiel Jan 12 '11 at 09:06
  • Thanks Xandy and Michiel for the information.. How do i get the x and y positions from the rectangle coordinates?? – uday Jan 12 '11 at 09:21
  • What's the type of object you hold the coordinates? – xandy Jan 12 '11 at 10:35
  • The type of object is Rect. I can able to get left, top, right, bottom from this object. and i dont know how to get x and y coordinates from the Rect object?? – uday Jan 12 '11 at 11:19
0

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.

Michiel
  • 270
  • 1
  • 3
  • 11