簡體   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