Skip to content

lolobosse/CropDroid

This branch is 8 commits ahead of tediscript/CropDroid:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Laurent Meyer
Jul 15, 2014
be3276e · Jul 15, 2014

History

10 Commits
Jan 21, 2014
Jul 15, 2014
Jan 21, 2014
Sep 12, 2013
Sep 12, 2013
Sep 12, 2013
Jan 21, 2014
Jan 21, 2014
Sep 12, 2013
Sep 12, 2013
Sep 12, 2013
Sep 12, 2013
Jan 21, 2014

Repository files navigation

CropDroid

Android crop image library. Modified from https://github.com/biokys/cropimage and remove some warnings.

Call this method to run CropImage activity

private void runCropImage() {

    // create explicit intent
    Intent intent = new Intent(this, CropImage.class);
    
    // tell CropImage activity to look for image to crop 
    String URI = ...;
    intent.putExtra(CropImage.IMAGE_URI, URI.toString());
    
    // allow CropImage activity to rescale image
    intent.putExtra(CropImage.SCALE, true);
    
    // if the aspect ratio is fixed to ratio 3/2
    intent.putExtra(CropImage.ASPECT_X, 3);
    intent.putExtra(CropImage.ASPECT_Y, 2);
    
    // start activity CropImage with certain request code and listen
    // for result
    startActivityForResult(intent, REQUEST_CODE_CROP_IMAGE);
}

Waiting for result

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (resultCode != RESULT_OK) {

        return;
    }  

    switch (requestCode) {

        case REQUEST_CODE_CROP_IMAGE:

            String uri = data.getStringExtra(CropImage.IMAGE_URI);
            
            // if nothing received
            if (uri == null) {

                return;
            }

            // cropped bitmap
            Bitmap b = MediaStore.Images.Media.getBitmap(this.getContentResolver(), Uri.parse(uri));
            
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

About

Android Crop Library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 99.2%
  • Groovy 0.8%