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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM