Skip to content
forked from biokys/cropimage

Replacement for deprecated official Android crop image function

Notifications You must be signed in to change notification settings

juleZZZ/cropimage

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cropimage

  • Replacement for deprecated official Android crop image function
  • 2.2 API

  • Easy to integrate to your app.
  • Enjoy ;-)

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 filePath = ...;
    intent.putExtra(CropImage.IMAGE_PATH, filePath);
    
    // 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 path = data.getStringExtra(CropImage.IMAGE_PATH);
            
            // if nothing received
            if (path == null) {

                return;
            }

            // cropped bitmap
            Bitmap bitmap = BitmapFactory.decodeFile(mFileTemp.getPath());
            
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

About

Replacement for deprecated official Android crop image function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%