我在这里发布我的代码, 首先将捕获的图像保存到本地目录和 从目录和裁剪中获取它。我需要捕捉图像,然后立即将其拍摄。 是否可以将捕获的图像保存在Bundle / Intent Extra中,然后调用裁剪功能?
camera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory()+File.separator + "img.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intent, 1);
}
});
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==1){
File file = new File(Environment.getExternalStorageDirectory()+File.separator + "img.jpg");
try {
cropCapturedImage(Uri.fromFile(file));
}
catch(ActivityNotFoundException aNFE){
String errorMessage = "Sorry - your device doesn't support the crop action!";
Toast toast = Toast.makeText(getContext(), errorMessage, Toast.LENGTH_SHORT);
toast.show();
}
}
if(requestCode==2){
Bundle extras = data.getExtras();
Bitmap thePic = extras.getParcelable("data");
proofImage.setImageBitmap(thePic);
}
}
public 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("return-data", true);
startActivityForResult(cropIntent, 2);
}
答案 0 :(得分:0)
你可以这样做:
您可以从网址而不是URI中选择图片,然后使用滑行
裁剪图片<强> Glide.with(本).load(值) .crossFade() .thumbnail(0.5F) .diskCacheStrategy(DiskCacheStrategy.ALL) .into(callerimg); 强>
您可以使用.bitmapTransform(新的CircleTransform(this))来圆圈形状。 CircleTransform是一个用圆圈形状选取图像的类。