Android: Camera preview Rotated

早过忘川 提交于 2019-12-24 09:16:11

问题


i am facing a problem in my application, i am using this for the camera preview, but in the camera preview even the person standing vertically is appearing to stand horizontally... , it seems i am missing something in my preview

mSurfaceView = (SurfaceView)findViewById(R.id.surface);
    mSurfaceHolder = mSurfaceView.getHolder();
    mSurfaceHolder.addCallback(this);
    mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

plz help me out , thanx


回答1:


Give this a try: http://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation(int)

I'm not sure if you are saying that the preview is incorrect, or if the preview looks good and the saved picture is wrong. That link above should fix the preview problem.

If the saved JPEG isn't right try this: http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setRotation(int)

I just copied and pasted both hunks of code, it helped a lot.




回答2:


when you getSupportedPreviewSizes from Camera.Parameters if you see supported previewSize have height <= width , it means that the camera driver does not support previewSize for portrait mode (height > width). you can refer this to get more info



来源:https://stackoverflow.com/questions/10278155/android-camera-preview-rotated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!