Android-RTEditor
Android-RTEditor copied to clipboard
Image resize and crop
Thanks for this library!
Not an issue per se, but is it possible to resize and crop the image inserted in editor?
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 >.<
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();
}
}
});
}