繁体   English   中英

如何从相机预览(表面视图)中裁剪图像并保存它,而不是像instagram app这样捕获bt相机的实际图像?

[英]How to crop image from camera preview (surface view) and save it instead of actual image captured bt camera like instagram app?

这是Instagram应用程序 我有一个带有表面视图的活动(匹配父级-匹配父级),其中一半被按钮隐藏。 是否可以仅保存拍摄图片的可见部分? 我试图使表面视图变小,但是在这种情况下预览是旋转的或拉伸的。 我正在使用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> 

只需要保存图像的可见部分

下面的链接与您的要求相同。

请检查 :

https://kylewbanks.com/blog/tutorial-square-camera-with-preview-on-android

希望这能解决您的问题...(:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM