[英]How to crop image from camera preview (surface view) and save it instead of actual image captured bt camera like instagram app?
I have an activity with surface view (match parent-match parent), half of which is hidden by button.
我有一个带有表面视图的活动(匹配父级-匹配父级),其中一半被按钮隐藏。 Is it possible to save only visible part of captured picture?
是否可以仅保存拍摄图片的可见部分? I've tried to make the surface view smaller, but preview is either rotated in this case or stretched.
我试图使表面视图变小,但是在这种情况下预览是旋转的或拉伸的。 I'm using android.hardware.camera1 btw
我正在使用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>
Below Link is Same as your Requirement's. 下面的链接与您的要求相同。
Please Check : 请检查 :
https://kylewbanks.com/blog/tutorial-square-camera-with-preview-on-android https://kylewbanks.com/blog/tutorial-square-camera-with-preview-on-android
Hope this will solve your problem...(: 希望这能解决您的问题...(:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.