Crop an image from gallery in android

☆樱花仙子☆ 提交于 2019-12-06 16:04:38
buttonGallery.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
// call android default gallery
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
// ******** code for crop image
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 0);
intent.putExtra("aspectY", 0);
intent.putExtra("outputX", 200);
intent.putExtra("outputY", 150);

try {

intent.putExtra("return-data", true);
startActivityForResult(Intent.createChooser(intent,
"Complete action using"), PICK_FROM_GALLERY);

} catch (ActivityNotFoundException e) {
// Do nothing for now
}
}
});

or Refer these sites for more help:

http://www.londatiga.net/featured-articles/how-to-select-and-crop-image-on-android/ http://www.androidhub4you.com/2012/07/how-to-crop-image-from-camera-and.html

I think this will address the issue.

http://www.londatiga.net/featured-articles/how-to-select-and-crop-image-on-android/

PS: This code may or may not work on all devices. This bit of code relies on code that is not part of the API. The only way to do cropping is to put the code directly in your app.

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