Android-RTEditor icon indicating copy to clipboard operation
Android-RTEditor copied to clipboard

Image resize and crop

Open yan5 opened this issue 8 years ago • 2 comments

Thanks for this library!

Not an issue per se, but is it possible to resize and crop the image inserted in editor?

yan5 avatar Jan 02 '17 13:01 yan5

I think that no, but you can to do a activity where you crop the image after you selected the image from the gallery. After croped the image, you can insert it in the RTEditor This library is good for this : https://github.com/IsseiAoki/SimpleCropView . I used it in my last project and worked very good.

Sorry for my english >.<

borjaMorilla avatar Feb 21 '17 08:02 borjaMorilla

The library has crop functionality included but it's applied only when an image is captured using the camera. For images picked from the file system, it doesn't call the crop but you can easily add that.

Check out MediaChooserActivity, especially the onImageChosen:

 @Override
    /* ImageChooserListener */
    public void onImageChosen(final RTImage image) {
        mSelectedMedia = image;

        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (mMediaAction == MediaAction.CAPTURE_PICTURE) {
                    String filePath = image.getFilePath(RTFormat.SPANNED);

                    Intent intent = new Intent(MediaChooserActivity.this, CropImageActivity.class)

                            // tell CropImage activity to look for image to crop
                            .putExtra(CropImageActivity.IMAGE_SOURCE_FILE, filePath)
                            .putExtra(CropImageActivity.IMAGE_DESTINATION_FILE, filePath)

                                    // allow CropImage activity to re-scale image
                            .putExtra(CropImageActivity.SCALE, true)
                            .putExtra(CropImageActivity.SCALE_UP_IF_NEEDED, false)

                                    // no fixed aspect ratio
                            .putExtra(CropImageActivity.ASPECT_X, 0)
                            .putExtra(CropImageActivity.ASPECT_Y, 0);

                    // start activity CropImageActivity
                    startActivityForResult(intent, Constants.CROP_IMAGE);
                } else {
                    EventBus.getDefault().postSticky( new MediaEvent(mSelectedMedia) );
                    finish();
                }
            }
        });
    }

1gravity avatar Feb 21 '17 16:02 1gravity