我尝试了下面的代码。但是,它始终会生成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