According to the documentation, setRotation(90) should rotate the captured JPEG picture (takePicture in landscape mode.
This works fine on a HTC phone, but does not work on Samsung Google Nexus S and Samsung Galaxy S3. Is this a bug?
I know that I can use the matrix transform rotation, but wish the OS can do this more efficiently, and don't want to risk over-rotating on some other devices.
edit
Setting camera.setDisplayOrientation(90);
made the preview to be in portrait mode, however it did not have any affect on the picture taken.
Further, Besides setRotation
, I have also tried to set the picture size - where I flip h
with w
: parameters.setPictureSize(1200, 1600);
. This also did not have any affect.
solution
Apparently Samsung phones set the EXIF orientation tag, rather than rotating individual pixels. As ariefbayu
suggested, reading the Bitmap using BitmapFactory
does not support this tag. His code sample is the solution, and this solution is also compatible with using inSampleSize
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…