I have an Android app that opens the camera, starts preview and streams it on screen. Important note: there is no real SurfaceView
associated with the camera. There's only a dummy SurfaceTexture
:
m_previewTexture = new SurfaceTexture(58346);
camera.setPreviewTexture(m_previewTexture);
Now, I'm getting the image using the Camera.PreviewCallback
. It is irrelevant what I'm doing with it further. So far I'm displaying it on the screen, but I might as well be saving it on the memory card.
Now, the problem. I set preview size to 320x240. I get the image of 320x240 size, all seems fine. But as soon as real life objects come into the frame, I can clearly see that the image is stretched.
My activity's orientation is locked, it doesn't rotate. As I rotate the device relative to a fixed object, I can very clearly see and confirm that the image is stretched. Why could this be and how to avoid stretching?