这是我的相机应用程序,我想在其中捕获图像并裁剪它,但它拍照保存在我的“myimage”目录中,但不执行裁剪功能。请我需要帮助,我是这个领域的新人
这是我的相机开源代码
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory().getAbsoluteFile() + "/MyImage");
file.mkdir();
String timestmp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File images = new File(file, "QR_" + timestmp + ".jpg");
Urisavedmsg=Uri.fromFile(images);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Urisavedmsg);
startActivityForResult(intent, REQUEST_Code);
这是我的活动结果代码,否则执行的是其他任何事情
if (requestCode == REQUEST_Code && resultCode==Activity.RESULT_OK )
if (Urisavedmsg!=null)
{
File file = new File(Environment.getExternalStorageDirectory().getAbsoluteFile() + "/Myimage");
if (Urisavedmsg!=null){
try {
Uri getImage;
getImage=data.getData();
cropCapturedImage(Uri.fromFile(file));
cropCapturedImage(getImage);
} catch (ActivityNotFoundException ex) {
String msg = "sorry your device does't support the crop the action!";
Toast toast = Toast.makeText(this, msg, Toast.LENGTH_LONG);
toast.show();
}}
if (requestCode == 2) {
Bundle bundle = data.getExtras();
Bitmap thepic = bundle.getParcelable("data");
mImageView.setImageBitmap(thepic);
}
} else {
Toast.makeText(getApplicationContext(), "some thing worng", Toast.LENGTH_LONG).show();
}
}
这是我的裁剪方法......
private void cropCapturedImage(Uri picUri) {
Intent cropIntent = new Intent("com.android.camera.action.CROP");
cropIntent.setDataAndType(picUri, "image/*");
cropIntent.putExtra("crop", "true");
cropIntent.putExtra("aspectX", 1);
cropIntent.putExtra("aspectY", 1);
cropIntent.putExtra("outputX", 256);
cropIntent.putExtra("outputY", 256);
cropIntent.putExtra("scale", true);
cropIntent.putExtra("return-data", true);
startActivityForResult(cropIntent, Crop_pic);
}