How can I set boundaries for a custom Android camera?

I am trying to get a region of the Android camera demarcated for a picture (as in the image below). I want only the marked area to appear in the picture.

  1. How can I create a custom camera that shows the marked region when I open the camera (within my app)?

  2. How can I take a picture only of the marked area?

Answers


Since the SurfaceView takes more space than you inner-rectangle, you'll have to crop the obtained image.

Use Bitmap.createBitmap():

Returns an immutable bitmap from the specified subset of the source bitmap. The new bitmap may be the same object as source, or a copy may have been made. It is initialized with the same density as the original bitmap.

Pass it a bitmap, and define the rectangle from which the new bitmap will be created:

// Take 42 pixels off 4 sides
Bitmap croppedBmp = Bitmap.createBitmap(originalBmp, 42, 42, originalBmp.getWidth() - 42, originalBmp.getHeight() - 42);

Need Your Help

Find out what exactly XMLHttpRequest is requesting

ajax windows-phone-7 cordova

We're developing a cross-platform application using PhoneGap. At one point, it makes an AJAX request to a relative path, which works fine on both Android and iOS, but not Windows Phone - it gets a ...