Android 安卓摄像头意图动作\图像\捕获导致图像90度定向
我正在用相机拍照。但我要在Imageview上看到大图像。 我的问题是-- 我的代码如下Android 安卓摄像头意图动作\图像\捕获导致图像90度定向,android,android-camera-intent,Android,Android Camera Intent,我正在用相机拍照。但我要在Imageview上看到大图像。 我的问题是-- 我的代码如下 Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); try { // place where to store camera taken picture
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
try
{
// place where to store camera taken picture
tempPhoto = createTemporaryFile("picture", ".png");
tempPhoto.delete();
}
catch(Exception e)
{
return ;
}
mImageUri = Uri.fromFile(tempPhoto);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
startActivityForResult(cameraIntent, 6);
在活动结果中---
我正在尝试使用
//位图照片=(位图)数据.getExtras().get(“数据”)代码>
这将导致空指针异常。。
如何解决这个问题?我得到了问题的答案
1.要通过相机获得全尺寸图像,请使用
mImageUri = Uri.fromFile(tempPhoto);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
//tempPhoto is file location here you are storing camera photo in a temp file.
要维护ImageView
size,请使用android:adjustViewBounds=“true”
有关图像方向,请使用ExifOrientaion
请检查此链接以了解ExifOrientaion
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
ContentResolver cr = getApplicationContext().getContentResolver();
Bitmap photo=null;
if (resultCode == RESULT_OK) {
try {
photo = android.provider.MediaStore.Images.Media.getBitmap(cr, Uri.fromFile(tempPhoto));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ImageView imageView = (ImageView)this.findViewById(R.id.imageView1);
imageView.setImageBitmap(photo);
}
mImageUri = Uri.fromFile(tempPhoto);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
//tempPhoto is file location here you are storing camera photo in a temp file.