无法在 android 中裁剪图像
Not able to crop image in android
我必须从图库中选择图像或从相机中捕获图像,我想裁剪我得到的图像,
所以,我使用下面的代码来调用裁剪意图,
Intent cropIntent = new Intent("com.android.camera.action.CROP");
//indicate image type and Uri
cropIntent.setDataAndType(imageUri, "image/*");
//set crop properties
cropIntent.putExtra("crop", "true");
//retrieve data on return
cropIntent.putExtra("return-data", true);
try {
startActivityForResult(cropIntent, REQUEST_CODE_FOR_CROP_DONE);
} catch (ActivityNotFoundException actionNotFoundException) {
Log.e(TAG, actionNotFoundException.getMessage(), actionNotFoundException);
Toast.makeText(fragment.getActivity(), fragment.getResources().getString(R.string.crop_not_available), Toast.LENGTH_SHORT).show();
}
我正在使用 Nexus 6p 设备,似乎只有在这个设备上我才会遇到这个问题。
这给了我 Toast 消息说不能裁剪低于 50 x 50 的图像。
我可以知道我错过了什么吗?
我不知道你是否可以通过裁剪意图来裁剪图像!!
错误提示您选择的图像宽度 x 高度小于 50x50
尝试选择更大的图像进行裁剪。
PS:尝试使用此库进行裁剪 Android-Image-Cropper
此 com.android.camera.action.CROP
Intent 不适用于所有设备,您应该使用库进行裁剪
我必须从图库中选择图像或从相机中捕获图像,我想裁剪我得到的图像,
所以,我使用下面的代码来调用裁剪意图,
Intent cropIntent = new Intent("com.android.camera.action.CROP");
//indicate image type and Uri
cropIntent.setDataAndType(imageUri, "image/*");
//set crop properties
cropIntent.putExtra("crop", "true");
//retrieve data on return
cropIntent.putExtra("return-data", true);
try {
startActivityForResult(cropIntent, REQUEST_CODE_FOR_CROP_DONE);
} catch (ActivityNotFoundException actionNotFoundException) {
Log.e(TAG, actionNotFoundException.getMessage(), actionNotFoundException);
Toast.makeText(fragment.getActivity(), fragment.getResources().getString(R.string.crop_not_available), Toast.LENGTH_SHORT).show();
}
我正在使用 Nexus 6p 设备,似乎只有在这个设备上我才会遇到这个问题。
这给了我 Toast 消息说不能裁剪低于 50 x 50 的图像。
我可以知道我错过了什么吗?
我不知道你是否可以通过裁剪意图来裁剪图像!!
错误提示您选择的图像宽度 x 高度小于 50x50
尝试选择更大的图像进行裁剪。
PS:尝试使用此库进行裁剪 Android-Image-Cropper
此 com.android.camera.action.CROP
Intent 不适用于所有设备,您应该使用库进行裁剪