I have an app which uses the Camera, sending the preview to a SurfaceHolder. Everything works fine on the HTC Desire that I have been developing on, but when I run it on a Samsung Galaxy S the image from the preview is rotated 90 degrees.
The code attempts to match the best Size returned from the parameters.getSupportedPreviewSizes(), with the width and height of the Surface (as passed into SurfaceChanged as width开发者_运维知识库 and height).
(the image is also rotated on the Galaxy when an image is taken from the app).
Has anyone else had problems with the preview on the Galaxy? Or better yet got around the problems?
Yes, had exactly the same, see: Camera preview on Android - strange on Samsung Galaxy S
In order to have the final image in the right rotation as well as the cam preview, I do a manual rotation on the captured image like this
..
final Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
matrix.preRotate(degrees);
// recreate the new Bitmap
final Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, x, y, width,
height, matrix, true);
..
精彩评论