Issues taking picture with Android (Vertical Camera | Portrait)

后端 未结 4 1556
心在旅途
心在旅途 2021-01-06 06:25

With the following code shows a preview of the camera vertically and it\'s works.. BUT!! I get a photo in landscape! :(

How I can build it vertically? I\'ve the prev

4条回答
  •  粉色の甜心
    2021-01-06 06:38

    Camera.Parameters param;
    param = camera.getParameters();
    
    Display display = ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
    if(display.getRotation() == Surface.ROTATION_0)
    {
        camera.setDisplayOrientation(90);
        param.setRotation(90);
    }
    if(display.getRotation() == Surface.ROTATION_270)
    {
        camera.setDisplayOrientation(180);
        param.setRotation(180);
    }
    
    camera.setParameters(param);
    camera.takePicture(shutterCallback, rawCallback, jpegCallback);
    

提交回复
热议问题