Мне нужно захватить изображение внутри прямоугольника камеры.Например, как показано ниже:
![enter image description here](https://i.stack.imgur.com/3ddNk.jpg)
Ниже приведен макет XML
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.view.SurfaceView
android:id="@+id/surface"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<View
android:id="@+id/rectangleView"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_gravity="center"
android:background="@drawable/rectangle"
/>
<Button
android:id="@+id/button_capture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:text="Capture" />
Так что мне нужнозахватить часть внутри прямоугольника.Я попробовал ниже фрагмент
Bitmap imageOriginal = BitmapFactory.decodeByteArray(data, 0, data.length);
int[] customViewPosition = new int[2];
customView.getLocationInWindow(customViewPosition);
int[] surfacePosition = new int[2];
preview.getLocationInWindow(surfacePosition);
float scale = imageOriginal.getWidth() / (float) preview.getWidth();
int left = (int) ((int) scale * (customViewPosition[0] +
customView.getWidth() / 6F - surfacePosition[0]));
int top = (int) ((int) scale * (customViewPosition[1] +
customView.getHeight() / 6F - surfacePosition[1]));
int width = (int) scale * customView.getWidth() * 2 / 3;
int height = (int) scale * customView.getHeight() * 2 / 3;
Bitmap imageCropped = Bitmap.createBitmap(imageOriginal,
customView.getBottom(), customView.getTop(), customView.getWidth(),
customView.getHeight(), null, false);
Приведенный выше код не является полезным для захвата необходимой части изображения.Пожалуйста, помогите!