Rotating a Camera SurfaceView to portrait

前端 未结 7 1014
日久生厌
日久生厌 2020-12-14 04:37

I have looked up a few posts on changing the orientation of the camera with a surface view, but I have taken my code from the examples at:

http://developer.android.c

7条回答
  •  庸人自扰
    2020-12-14 04:59

    Try this out, but I tried in Samsung Galaxy Tab

    public void surfaceCreated(SurfaceHolder holder)
    {
       // The Surface has been created, acquire the camera and tell it where to draw.
       mCamera = Camera.open();
    
       Parameters params = mCamera.getParameters();
    
       if (this.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE)
       {
        params.set("orientation", "portrait");
        mCamera.setDisplayOrientation(90);
       }
    
        try
          {
          mCamera.setPreviewDisplay(holder);
          }
          catch (IOException exception)
          {
            mCamera.release();
            mCamera = null;
          }
    
    }
    

提交回复
热议问题