Code Monkey home page Code Monkey logo

gampil-camera's Introduction

Gampil Camera

A simple library to make it easier for you to embed a camera and surfaceview in an activity in your application.

Setup

Gradle

allprojects {
    repositories {
    	...
	maven { url 'https://jitpack.io' }
    }
}
dependencies {
    implementation 'com.github.hangga:Gampil-Camera:v1.1.2'
}

How to use

1. Add GampilPreview to your activity layout

<id.hangga.gampil.GampilPreview
    android:id="@+id/gampilPreview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

2. Initialization

Initiate object in your java code.

GampilPreview gampilPreview = findViewById(R.id.gampilPreview);

3. Method

The methods in Gampil you can use.

3.1. Set Camera Facing

setFacing(int facing)
Param : facing = Facing.FRONT_CAMERA or Facing.BACK_CAMERA

You can choose front or back camera easily. If you don't call this method, it will use the front camera by default.

Example :

gampilPreview.setFacing(Facing.FRONT_CAMERA); // Default
gampilPreview.setFacing(Facing.BACK_CAMERA);

3.2. Take Picture

This is a method for capturing photos from the camera which results in Bitmaps and Files.

takePhoto(int quality, TakePhotoListener takePhotoListener)
Params: quality : (int) Compress bitmap quality. TakePhotoListener : CallBack after takePicture

An example of how to capture a photo is like the code below.

gampilPreview.takePhoto(80, new TakePhotoListener() {
    @Override
    public void onPhotoTaken(Bitmap bitmap, File file) {
        // your code
    }

    @Override
    public void onPhotoError(String message) {
        // your code
    }
});

Sample Project

- checkout

gampil-camera's People

Contributors

hangga avatar

Stargazers

 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.