Skip to content

Image cropping

Alex Vasilkov edited this page Feb 5, 2016 · 4 revisions

To implement image cropping screen you should use GestureImageView with next configuration:

gestureImageView.getController().getSettings()
        .setFitMethod(Settings.Fit.OUTSIDE)
        .setFillViewport(true)
        .setMovementArea(areaW, areaH)
        .setRotationEnabled(true);

Where areaW and areaH is a size of cropping area within the viewport.

When you are ready to crop image just call:

Bitmap cropped = gestureImageView.crop();

Resulting bitmap will be a cropped area (as specified with setMovementArea(areaW, areaH)) of currently shown image.

You can also use FinderView to draw cropping area overlay. It uses Settings object from corresponding GestureImageView and can animate cropping area bounds changes.

See also sample activity.

Clone this wiki locally