如何从相机预览(表面视图)裁剪图像并保存它而不是像 instagram 应用程序这样的 bt 相机捕获的实际图像?
How to crop image from camera preview (surface view) and save it instead of actual image captured bt camera like instagram app?
我有一个 activity 表面视图(匹配父匹配父),其中一半被按钮隐藏。是否可以仅保存捕获图片的可见部分?我试图缩小表面视图,但在这种情况下预览要么旋转要么拉伸。我正在使用 android.hardware.camera1 btw
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="uz.pages.yangiuz10.activity.CameraActivity">
<SurfaceView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/surface_camera"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/colorBackgroundText">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button_shot"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/shot_btn"
android:background="@null"
android:onClick="onPictureCapture"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
低于 Link 与您的要求相同。
请检查:
https://kylewbanks.com/blog/tutorial-square-camera-with-preview-on-android
希望这能解决您的问题...(:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="uz.pages.yangiuz10.activity.CameraActivity">
<SurfaceView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/surface_camera"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/colorBackgroundText">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button_shot"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/shot_btn"
android:background="@null"
android:onClick="onPictureCapture"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
低于 Link 与您的要求相同。
请检查:
https://kylewbanks.com/blog/tutorial-square-camera-with-preview-on-android
希望这能解决您的问题...(: