0

the camera orientation in android with portrait mode gives view with an rotated angle of 90 degrees. the link says here as a bug in android and I am using sdk 2.2. http://code.google.com/p/android/issues/detail?id=1193

I have tried all the methods in the link but could not set right the issue. Any answers on this issue would be helpful. Looking forward for your reply. thanks.

kablu
  • 629
  • 1
  • 7
  • 26
Mukunda
  • 1,593
  • 3
  • 26
  • 45
  • 1
    Have a look - http://stackoverflow.com/questions/10259299/force-a-camera-to-always-open-in-portrait-mode-in-android/10259572#10259572 – Suvam Roy Apr 22 '12 at 06:32

1 Answers1

1

I am not sure how you are going to use those captured image further . . . so if you are going to capture and just display it in an Imageview better rotate it to 90 degree and set the bitmap using the following code

public static Bitmap rotate(Bitmap b, int degrees) 
{
    if (degrees != 0 && b != null) 
    {
        Matrix m = new Matrix();

        m.setRotate(degrees, (float) b.getWidth() / 2, (float) b.getHeight() / 2);
        try {
            Bitmap b2 = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), m, true);
            if (b != b2) 
            {
                b.recycle();
                b = b2;
            }
        } catch (OutOfMemoryError ex) 
        {
           throw ex;
        }
    }
    return b;
}

or if you are going to save it to the SDcard and use it , after taking picture rotate the bitmap using former code and then save it in sdcard .

VIGNESH
  • 2,023
  • 8
  • 31
  • 46