Android camera 竖直拍照 获取竖直方向照片

时间:2014-07-17 14:35:06   收藏:0   阅读:508

 

竖直拍照

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 camera 竖直拍照 获取竖直方向照片,布布扣,bubuko.com

原文:http://www.cnblogs.com/kobe8/p/3850884.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!