Reputation: 6177
in my app I have a preview screen. On one device (LG, with Android 2.2, 320x480 screen) and another one (HTC, with Android 2.3, 480x800 screen) everything is OK. In both cases the list of supported preview sizes include one that fits the screen size exactly, I choose it and the image is perfect. The problem comes with yet another device, having a screen similar to the first one (Samsung, Android 2.3, 320x480 screen). Regardless of the fact that I select a preview size that fits the screen size, as in previous cases, the image doe not preserve its aspect ratio; circles appear oval; the image is squeezed along the short axis of the screen. It seems the hardware itself, in order to obtain a 320x480 preview, squeezes the image (the camera has a form factor 4:3, while the screen has a form factor 3:2). So I have altered the layout params of the view where the preview appears, in order to fit the form factor of the camera (size: 360x480. This PARTIALLY solves the problem; actually, to solve it completely I had to set 380x480 (!!!). The fact is that I can't possibly find any API that tells me about this different behavior, so that I can automatically compensate for it. Not even the Camera.Parameters.getHorizontalViewAngle and Camera.Parameters.getHorizontalViewAngle seem to be helpful; they give the same values on all of the three devices! Can anyone help me?
Upvotes: 1
Views: 650
Reputation: 6177
After deeper investigation, that included writing ad-hoc code to check how the preview is actually shown on the screen, this is what I found out.
On one device (LG E-720), the preview image is cropped in order to obtain a 3:2 form factor, then it is resized to fit on the screen. Aspect ratio is preserved:
On the second device (Samsung ACE), the preview image appears to be cropped in a different way, resulting in a 5:4 image (!?), that is then resized to fit on screen. Due to the different form factors, the image on screen appears squeezed.:
I have checked whether a software update was available for the second device, but this wansn't the case. So in order to get a more or less correct image on screen, I have defined the target view as being 384 pixels tall; this actually causes a cropping that restores the correct aspect ratio. It doesn't compensate, though, a small horizontal shift due to the fact that the original cropping is horizontally asymmetric.
Upvotes: 3