竖直拍照
if (Integer.parseInt(Build.VERSION.SDK) >= 8) {
camera.setDisplayOrientation(90);
} else {
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
parameters.set("orientation", "portrait");
parameters.set("rotation", 90);
}
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
parameters.set("orientation", "landscape");
parameters.set("rotation", 90);
}
}
获取竖直方向照片
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, params[0].length);
Matrix matrix = new Matrix();
matrix.setRotate(90);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
FileOutputStream fos = new FileOutputStream(picture.getPath());
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.close();