简体   繁体   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应用程序 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.

相关问题 是否可以在不返回到应用程序的情况下裁剪从Android上的Camera捕获的图像? - Is it possible to crop an image captured from the Camera on Android without returning to the app? 如何在 android 中保存从相机拍摄的图像 - How to save captured image from camera in android 从相机裁剪图像并保存 - Crop image from camera and save it 是否可以像Vertex Shader和Fragment Shader一样生效到Android Camera Preview,并使用OpenGLES保存捕获的图像? - Is it Possible to give effect like Vertex Shader and Fragment Shader to the Android Camera Preview , and Save the Captured image with OpenGLES? 如何在相机拍摄的图像上添加相框并保存 - how to add a frame to camera captured image and save it 如何将相机拍摄的图像保存在特定文件夹中 - How to save image captured with camera in specific folder 如何从相机和图库中选取图像、裁剪并设置为图像视图 - How to pick image from camera and gallery , crop it and set to image view 保存相机拍摄的图像JPG - Save image JPG captured by the camera 如何通过相机将捕获的图像发送到下一个视图 - how to send captured image by camera to a next view 调整相机拍摄的图像大小而不会裁剪 - Resize image captured by camera without crop
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM