GithubHelp home page GithubHelp logo

luoyiqi / focussurfaceview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cgmaybe10/focussurfaceview

0.0 1.0 0.0 10.62 MB

拍照时在相机的预览界面指定一个区域的大小,形状和位置,只拍摄该指定区域里的图像

Java 100.00%

focussurfaceview's Introduction

FocusSurfaceView

该库大部分参考IsseiAoki的SimpleCropView https://github.com/IsseiAoki/SimpleCropView
实现了在相机的预览界面指定一个区域的大小,形状和位置,只拍摄该指定区域里的图像
支持 API Level 10 and above.

##使用方法:
在工程和module里的build.gradle分别添加

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
dependencies {
	        compile 'com.github.CGmaybe10:FocusSurfaceView:v1.0.1'
	}
<com.cymaybe.foucsurfaceview.FocusSurfaceView
        android:id="@+id/preview_sv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent"
        android:visibility="visible"
        app:focus_crop_height="267dp"
        app:focus_crop_width="200dp"
        app:focus_frame_can_change="true"
        app:focus_frame_color="@android:color/holo_green_dark"
        app:focus_frame_stroke_weight="1dp"
        app:focus_guide_color="@android:color/holo_green_dark"
        app:focus_guide_show_mode="not_show"
        app:focus_guide_stroke_weight="1dp"
        app:focus_handle_color="@android:color/holo_green_dark"
        app:focus_handle_show_mode="not_show"
        app:focus_handle_size="14dp"
        app:focus_min_frame_size="50dp"
        app:focus_mode="circle"
        app:focus_overlay_color="#66000000"
        app:focus_touch_padding="8dp"/>
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);                       
                        }
                    });
                }
            }
        });

focussurfaceview's People

Contributors

cgmaybe10 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.