1

I'm building an application in android which uses the camera.I have built my own camera but the problem is that once I open my camera this way:

 public void surfaceCreated(SurfaceHolder holder) {
        Log.e(TAG, "surfaceCreated");
        mCamera = Camera.open();

    }

Both my preview and the picture taken are rotated 90 degrees when the phone is in portrait mode, when the phone is turned in the landscape mode everything looks great.Does anyone know how could this be solved.

Thank you!

adrian
  • 4,574
  • 17
  • 68
  • 119
  • I had asked the same question here: http://stackoverflow.com/questions/4645960/how-to-set-android-camera-orientation-properly – Abhinav Aug 23 '11 at 10:19
  • BUT HOW DID U DO THAT???I read your accepted answer... – adrian Aug 23 '11 at 11:21
  • There was an accepted answer for this kind of question. Probably you want to check [this](https://stackoverflow.com/questions/3852154/android-camera-unexplainable-rotation-on-capture-for-some-devices-not-in-exif/4939319#4939319) out. – Kristiono Setyadi Aug 23 '11 at 10:18

1 Answers1

0

setRotation(int rotation) of Camara.Parameters is your friend here.

Edit:

Did you see the reference code in the docs :

public void public void onOrientationChanged(int orientation) {
     if (orientation == ORIENTATION_UNKNOWN) return;
     android.hardware.Camera.CameraInfo info =
            new android.hardware.Camera.CameraInfo();
     android.hardware.Camera.getCameraInfo(cameraId, info);
     orientation = (orientation + 45) / 90 * 90;
     int rotation = 0;
     if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
         rotation = (info.orientation - orientation + 360) % 360;
     } else {  // back-facing camera
         rotation = (info.orientation + orientation) % 360;
     }
     mParameters.setRotation(rotation);
 }
pumpkee
  • 3,357
  • 3
  • 27
  • 34