Cropping Shape of Square Image Android In App

两盒软妹~` 提交于 2019-12-06 01:24:57

问题


I want to create an application which allows the user to resize an image in shape of square (length = width).

I know that it is possible to use the gallery to make that in this way:

private void crop(Uri photoUri) {
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setData(photoUri);
    intent.putExtra("outputX", 200);
    intent.putExtra("outputY", 200);
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);
    intent.putExtra("scale", true);
    intent.putExtra("return-data", true);
    startActivityForResult(intent, RESULT_CROP);
}

But I would like to know if there is a library which allows to make that directly in the application?

Thank you in advance !!


回答1:


I found my solution here but I accept other answers!!




回答2:


I used this library https://arthurhub.github.io/Android-Image-Cropper/

See the example code in sample project in addition to that you have to fix the aspect ratio and set the scale to 1.

cropImageView.setFixedAspectRatio(true);
cropImageView.setScaleX(1.0f);
cropImageView.setScaleY(1.0f);


来源:https://stackoverflow.com/questions/16593156/cropping-shape-of-square-image-android-in-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!