# FocusSurfaceView **Repository Path**: Fly2God/FocusSurfaceView ## Basic Information - **Project Name**: FocusSurfaceView - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-01-09 - **Last Updated**: 2021-01-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # FocusSurfaceView 该库大部分参考IsseiAoki的SimpleCropView https://github.com/IsseiAoki/SimpleCropView
实现了在相机的预览界面指定一个区域的大小,形状和位置,只拍摄该指定区域里的图像
支持 API Level 10 and above.
![](https://github.com/CGmaybe10/FocusSurfaceView/blob/master/screenshots/demo.gif)
![](https://github.com/CGmaybe10/FocusSurfaceView/blob/master/screenshots/circle.png) ![](https://github.com/CGmaybe10/FocusSurfaceView/blob/master/screenshots/circle_pre.png) ![](https://github.com/CGmaybe10/FocusSurfaceView/blob/master/screenshots/square.png) ![](https://github.com/CGmaybe10/FocusSurfaceView/blob/master/screenshots/square_pre.png) ##使用方法:
在工程和module里的build.gradle分别添加 ```groovy allprojects { repositories { ... maven { url 'https://jitpack.io' } } } dependencies { compile 'com.github.CGmaybe10:FocusSurfaceView:v1.0.1' } ``` ```xml ``` ```java private FocusSurfaceView previewSFV = (FocusSurfaceView) findViewById(R.id.preview_sv); mCamera.autoFocus(new Camera.AutoFocusCallback() { @Override public void onAutoFocus(boolean success, Camera camera) { mCamera.takePicture(new Camera.ShutterCallback() { @Override public void onShutter() { } }, null, null, new Camera.PictureCallback() { @Override public void onPictureTaken(byte[] data, Camera camera) { Bitmap cropBitmap = previewSFV.getPicture(data); } }); } } }); ```