Code Monkey home page Code Monkey logo

android-cutout's Introduction

✂️ Android-CutOut

Android image background cutting library

Version Build

Usage

Add Gradle dependency:

implementation 'com.github.gabrielbb:cutout:0.1.2'

Start the CutOut screen with this single line:

CutOut.activity().start(this);

 

Getting the result

@Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        if (requestCode == CutOut.CUTOUT_ACTIVITY_REQUEST_CODE) {

            switch (resultCode) {
                case Activity.RESULT_OK:
                    Uri imageUri = CutOut.getUri(data);
                    // Save the image using the returned Uri here
                    break;
                case CutOut.CUTOUT_ACTIVITY_RESULT_ERROR_CODE:
                    Exception ex = CutOut.getError(data);
                    break;
                default:
                    System.out.print("User cancelled the CutOut screen");
            }
        }
    }

Features

   

Options

You can use one or more options from these:

            CutOut.activity()
                    .src(uri)
                    .bordered()
                    .noCrop()
                    .intro()
		    .saveType(CutOutSaveTypes.SAVE_TO_STORAGE)
                    .start(this);
  • src

By default the user can select images from camera or gallery but you can also pass an android.net.Uri of an image that is already saved:

Uri uri = Uri.parse("/images/cat.jpg");

CutOut.activity().src(uri).start(this);
  • bordered

CutOut.activity().bordered().start(this);

This option makes the final PNG have a border around it. The default border color is White. You can also pass the android.graphics.Color of your choice.

  • noCrop

CutOut.activity().noCrop().start(this);

By default and thanks to this library: Android-Image-Cropper, the user can crop or rotate the image. This option disables that cropping screen.

  • intro

CutOut.activity().intro().start(this);

Display an intro explaining every button usage. The user can skip the intro and it is only shown once. The images displayed in the intro are the same you saw in the "Features" section of this document.

Change log

0.1.2

  • Removed Admob Ads automatic integration. I will probably add it later. For now, it was causing problems.
  • Images are now saved as temporary files in the cache directory. This guarantees that these images will be deleted when users uninstall your app or when the disk memory is low. If you want the images to live forever on the Gallery, you should take the returned Uri and save the image there by yourself.

License

Copyright (c) 2018 Gabriel Basilio Brito

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, merge, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

1 - You cannot use this software to make an Android app that its main goal is to remove background from images and publish it to the Google Play Store, but you can use it to integrate the functionality in an existing app or a new app that does more than just this.

2 - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

android-cutout's People

Contributors

amir-shiati avatar gabrielbb avatar

Stargazers

 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.