Android camera 竖直拍照 获取竖直方向照片
竖直拍照
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();
更多相关文章
- android动态申请拍照获取照片权限
- Android 禁止屏幕旋转 & 屏幕旋转不刷新 Activity & 动态更改屏
- Android 屏幕方向以及UI界面状态的保存
- Android进阶:实现android系统自带查看照片动画效果 类似Gallery手
- Android 手动设置屏幕方向后不能自动转屏问题
- android camera以时间来命名照片文件
- Android开发提高篇之“多方向”抽屉