zoukankan      html  css  js  c++  java
  • 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();

  • 相关阅读:
    第九章
    第十章
    第八章
    第七章
    第六章
    第五章
    第四章
    第三章
    第二章
    第一章
  • 原文地址:https://www.cnblogs.com/kobe8/p/3850884.html
Copyright © 2011-2022 走看看