竖直拍照

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();

相关文章:

  • 2022-12-23
  • 2021-12-14
  • 2021-08-20
  • 2022-12-23
  • 2022-01-25
  • 2021-11-16
  • 2021-11-12
猜你喜欢
  • 2021-12-01
  • 2022-12-23
  • 2021-11-06
  • 2021-11-06
  • 2022-12-23
  • 2021-11-24
相关资源
相似解决方案