views:

1183

answers:

1

I posted this on the android dev forums, but wanted to reach out here.

One of the activities in our app was taking a picture. The picture preview shows the correct way on screen in 1.5 & 1.6, but when it is saved, it saves the jpg 90 rotated.

I can rotate it realtime when displaying, and I guess I could re-save it once saved. My issue is I would like to save it correctly when taking the picture.

My app while compiled in 1.5 works fine. I had some memory issues w/ 1.6 due to image size, which was strange b/c the image size increased when taking photos by taking a picture w/ surfaceholder/imagecapture callback. I seem to have fixed re-displaying those images by resizing them using a bitmapfactory matrix. But my camera is now rotating everything 90 degrees. It appears that my Override of surfaceChanged does nothing, which is where I was setting rotation at 90 (I can't remember why, it was 10 months ago!). I have tried at rotating the camera parameters paramters at 90 degrees, 0 degrees. It does not seem to do anything... any thoughts?

+2  A: 

Camera drivers do not know the orientation of the device. In 1.5 and 1.6, you need to call parameters.set("rotation", degree) to tell drivers about rotation before calling takePicture(). In 2.0, there is a new API setRotation (see below). Note that some devices rotate the entire pictures for you and some just set the orientation in EXIF header.

http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setRotation(int)

Sets the orientation of the device in degrees. For example, suppose the natural position of the device is landscape. If the user takes a picture in landscape mode in 2048x1536 resolution, the rotation should be set to 0. If the user rotates the phone 90 degrees clockwise, the rotation should be set to 90. Applications can use OrientationEventListener to set this parameter. The camera driver may set orientation in the EXIF header without rotating the picture. Or the driver may rotate the picture and the EXIF thumbnail. If the Jpeg picture is rotated, the orientation in the EXIF header will be missing or 1 (row #0 is top and column #0 is left side).
Parameters
rotation The orientation of the device in degrees. Rotation can only be 0, 90, 180 or 270

Garfield