我嘗試了下面的代碼。但是,它始終會生成160 * 160尺寸的圖像。通過在Android中傳遞圖像文件路徑來裁剪圖像
try {
//call the standard crop action intent (the user device may not support it)
Intent cropIntent = new Intent("com.android.camera.action.CROP");
//indicate image type and Uri
cropIntent.setDataAndType(Uri.fromFile(pictureFile), "image/*");
//set crop properties
cropIntent.putExtra("crop", "true");
//indicate aspect of desired crop
cropIntent.putExtra("aspectX", 100);
cropIntent.putExtra("aspectY", 100);
cropIntent.putExtra("scale", true);
//indicate output X and Y
cropIntent.putExtra("outputX", 500);
cropIntent.putExtra("outputY", 500);
//retrieve data on return
cropIntent.putExtra("return-data", true);
//start the activity - we handle returning in onActivityResult
startActivityForResult(cropIntent, CROP_IMAGE);
} catch(ActivityNotFoundException anfe) {
//display an error message
String errorMessage = "Whoops - your device doesn't support the crop action!";
Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
toast.show();
}
我想通過傳遞路徑來裁剪圖像。 我不想捕捉/從默認相機應用程序或畫廊中挑選。請幫助我。
如果這是你的首選解決方案,那麼請標記爲這樣,並關閉問題 –
我可以標記爲回答2天后才按照SO規則。 :( – Noundla
經過幾天的努力終於運轉良好,tnx。多麼愚蠢的錯誤!>: – Sdghasemi