android 自定义相机画面倒立解决方案

有部分手机的影像是倒立的,如何解决这个问题呢? 请看下面

public static void setCameraDisplayOrientation(Activity activity,
         int cameraId, android.hardware.Camera camera) {
     android.hardware.Camera.CameraInfo info =
             new android.hardware.Camera.CameraInfo();
     android.hardware.Camera.getCameraInfo(cameraId, info);
     int rotation = activity.getWindowManager().getDefaultDisplay()
             .getRotation();
     int degrees = 0;
     switch (rotation) {
         case Surface.ROTATION_0: degrees = 0; break;
         case Surface.ROTATION_90: degrees = 90; break;
         case Surface.ROTATION_180: degrees = 180; break;
         case Surface.ROTATION_270: degrees = 270; break;
     }

     int result;
     if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
         result = (info.orientation + degrees) % 360;
         result = (360 - result) % 360;  // compensate the mirror
     } else {  // back-facing
         result = (info.orientation - degrees + 360) % 360;
     }
     camera.setDisplayOrientation(result);
 }

@Override
	public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
		// TODO Auto-generated method stub
		<pre name="code" class="html">                setCameraDisplayOrientation(this,0,camera)

}


android 自定义相机画面倒立解决方案

时间: 2024-07-29 11:27:17

android 自定义相机画面倒立解决方案的相关文章

Android自定义相机超详细讲解

Android自定义相机超详细讲解 转载请标明出处: http://blog.csdn.net/vinicolor/article/details/49642861: 由于网上关于Android自定义相机的文章写得不是太详细,Google官方的文档又说得不太容易理解,所以今天我来详细讲解一下Android自定义相机. 这篇文章主要写给一些刚刚接触Android的那些看官方API困难以及不太了解Android机制的同学们,所以熟练开发者可以绕道了. 最近在使用Camera类的时候发现居然被弃用了,

Android 自定义相机Demo源码

Github源码:https://github.com/LinJZong/AndroidProject.git 模仿360相机,图片资源来源于360相机,仅供学习使用.截图如下: 目前完成了拍照.保存.图片压缩.触摸聚焦.拍照成功附带动画效果.闪光灯切换.手势缩放等功能,功能持续更新中. 最近更新的较频繁,就不放csdn了,等功能全做完了再传csdn.介绍下目前主要几个功能类凑够200字. public class CameraView extends SurfaceView implement

Android—实现自定义相机倒计时拍照

这篇博客为大家介绍Android自定义相机,并且实现倒计时拍照功能 首先自定义拍照会用到SurfaceView控件显示照片的预览区域,以下是布局文件: 两个TextView是用来显示提示信息和倒计时的秒数的 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" androi

android开发——自定义相机开发总结

最近这段时间我一直在开发自定义相机,谷歌了些网上的demo,发现有很多各种各样的问题.最终还是从API的camera类开始学习,进行改进.下面对之前的实现进行一些总结. 官方camera API: http://developer.android.com/guide/topics/media/camera.html 中文翻译: http://www.cnblogs.com/over140/archive/2011/11/16/2251344.html 自定义相机大致实现流程: 预览Camera这

Android 手把手带你玩转自定义相机

概述 相机几乎是每个APP都要用到的功能,万一老板让你定制相机方不方?反正我是有点方.关于相机的两天奋斗总结免费送给你. 启动相机的两种方式 1.直接启动系统相机 Intent intent = new Intent(); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); startActivity(intent); 或者指定返回图片的名称mCurrentPhotoFile Intent intent = new Intent(MediaSto

Android Multimedia框架总结(十四)Camera框架初识及自定义相机案例

转载请把头部出处链接和尾部二维码一起转载,本文出自逆流的鱼yuiop:http://blog.csdn.net/hejjunlin/article/details/52738492 前言:国庆节告一段落,又是新一月,上月主要是围绕MediaPlayer相关展开,从今天开始,开始分析多媒体框架中的Camera模块,看下今天的Agenda: Camera拍照 Camera录像 新API android.hardware.camera2 新旧API特点对比 Camera自定义相机 新API andro

Android调用系统相机、自定义相机、处理大图片

Android调用系统相机和自定义相机实例 本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显示出来,该例子也会涉及到Android加载大图片时候的处理(避免OOM),还有简要提一下有些人SurfaceView出现黑屏的原因. Android应用拍照的两种方式,下面为两种形式的Demo展示出来的效果.    知识点: 一.调用系统自带的相机应用 二.自定义我们自己的拍照界面 三.关于计算机解析图片原理(如何正确加载图片到Android应用中) 所需

[原创] Android 自定义AlertDialog 去黑边终极解决方案(亲测有效!)

问题:自定义AlertDialog出现黑边 运行代码段: View view = View.inflate(context, R.layout.dialog_common, null); mDialog = new AlertDialog.Builder(context).create(); mDialog.setView(view); mDialog.show(); dialog_common.xml <?xml version="1.0" encoding="utf

Android 自定义AlertDialog 去黑边终极解决方案(亲测有效!)

问题:自定义AlertDialog出现黑边 运行代码段: View view = View.inflate(context, R.layout.dialog_common, null); mDialog = new AlertDialog.Builder(context).create(); mDialog.setView(view); mDialog.show(); dialog_common.xml <?xml version="1.0" encoding="utf