如何在相机 Intent 上获取全尺寸图像
how to get full size image on camera Intent
我想从 camera
intent
获取全尺寸图像。我试过下面的代码,但我得到的图像尺寸非常 small.following 是我的代码
Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent , PICK_IMAGE_REQUEST2);
onActivityResult
代码
if(requestCode == PICK_IMAGE_REQUEST2)
{
//filePath = data.getData();
bitmap = (Bitmap) data.getExtras().get("data");
iv_upload.setImageBitmap(bitmap);
check=true;
// CALL THIS METHOD TO GET THE URI FROM THE BITMAP
filePath = getImageUri(getApplicationContext(), bitmap);
}
通过这样做,您可以获得提到的缩略图预览 here
data.getExtras().get("data");
如果你想要全尺寸,你需要创建一个抗冲突的文件名并像这样调用你的意图
Uri photoURI = FileProvider.getUriForFile(this,
"com.example.android.fileprovider",
photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
我想从 camera
intent
获取全尺寸图像。我试过下面的代码,但我得到的图像尺寸非常 small.following 是我的代码
Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent , PICK_IMAGE_REQUEST2);
onActivityResult
代码
if(requestCode == PICK_IMAGE_REQUEST2)
{
//filePath = data.getData();
bitmap = (Bitmap) data.getExtras().get("data");
iv_upload.setImageBitmap(bitmap);
check=true;
// CALL THIS METHOD TO GET THE URI FROM THE BITMAP
filePath = getImageUri(getApplicationContext(), bitmap);
}
通过这样做,您可以获得提到的缩略图预览 here
data.getExtras().get("data");
如果你想要全尺寸,你需要创建一个抗冲突的文件名并像这样调用你的意图
Uri photoURI = FileProvider.getUriForFile(this,
"com.example.android.fileprovider",
photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);