2016-11-10 30 views
1

我有選擇的圖像無論是從畫廊或捕捉的相機圖像,我想裁剪圖像我所得到的,無法裁切的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設備,似乎只有在這個設備上我面臨這個問題。

這給我敬酒消息說,可以在下面50×50

不作物圖像可能我知道我缺少什麼?

+1

請查看本博客:https://commonsware.com/博客/ 2013/01/23 /無的Android此結果不具備的,作物intent.html –

回答

1

com.android.camera.action.CROP的意圖並不在所有設備上工作,你應該使用庫croping

1

我不知道你是否可以通過傳遞作物意圖裁剪圖像!

誤差表示U的選擇具有寬度x高度小於50×50

嘗試選擇較大的圖像用於裁剪工作的圖像。

PS:嘗試使用這個庫裁剪Android-Image-Cropper