Android-RTEditor
Android-RTEditor copied to clipboard
How to resize the width and height of the image before insert into the edittext? Some picture is too large
Really like your awesome richtext.
I want to resize the image's width and height when I choose one image from local gallery system.
Could you help me with my question?
Yes, 1gravity is right. Cropping the image is very easy. All you need to do is add more action
` @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 if(mMediaAction==MediaAction.PICK_PICTURE){//Feliks added
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();
}
}
});
}`