为什么使用摄像头拍摄的图像会在Android上的某些设备上旋转?
public void captureImage() { Intent intentCamera = new Intent("android.media.action.IMAGE_CAPTURE"); File filePhoto = new File(Environment.getExternalStorageDirectory(), "Pic.jpg"); imageUri = Uri.fromFile(filePhoto); MyApplicationGlobal.imageUri = imageUri.getPath(); intentCamera.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intentCamera, TAKE_PICTURE);}@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent intentFromCamera) { super.onActivityResult(requestCode, resultCode, intentFromCamera); if (resultCode == RESULT_OK && requestCode == TAKE_PICTURE) { if (intentFromCamera != null) { Bundle extras = intentFromCamera.getExtras(); if (extras.containsKey("data")) { bitmap = (Bitmap) extras.get("data"); } else { bitmap = getBitmapFromUri(); } } else { bitmap = getBitmapFromUri(); } // imageView.setImageBitmap(bitmap); imageView.setImageURI(imageUri); } else { }}public Bitmap getBitmapFromUri() { getContentResolver().notifyChange(imageUri, null); ContentResolver cr = getContentResolver(); Bitmap bitmap; try { bitmap = android.provider.MediaStore.Images.Media.getBitmap(cr, imageUri); return bitmap; } catch (Exception e) { e.printStackTrace(); return null; }}
犯罪嫌疑人X
相关分类