I am trying to put the camera in a surfaceView in portrait orientation on android phone. I used http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.html to put the camera in the surfaceView. However the camera is rotated 90 degrees, so I tried doing setDisplayOrientation(90) to fix it, but this squashes the image (it Probably isn't resizing the surfaceView properly??). How can I make it so the camera is not squished?
You need to resize the image according to the rotation. See here for an example.
If you were using Android API demos, you need to modify OnLayout()
function.
Basically the Android API demo, sets the preview size in according to the aspect ratio so that the preview image is squished and display in center of screen with small size in portrait mode.
Even if we set-up screen orientation to Portrait mode, preview width and height are not changed. That's why the preview image was squished.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With