I am making a rather special camera application for a device that will always physically be stored in landscape orientation. Part of the specification is that it can optionally be viewed and photographed in portrait orientation - see Configuration “A” below. 
(Now, before anyone votes to close this question, suggesting it to repeat this other SO question , let me indicate that another question was simply about whether it was possible or not, to which the stated answer is yes. This the question is how to do this.)
I already set up TextureView for preview and called camera.setPreviewTexture (), so I see the camera image on the screen. I also have the code and it works, which makes the landscape version of what I need, see Configuration "B" below.
To configure camera settings, I first read my own camera settings using getParameters (), and then change only the ones I want to change. Therefore, in the case of configuration "B" it is just a matter of executing the following code:
camera_parameters = camera.getParameters(); camera_parameters.setPreviewSize(640,480); camera_parameters.setPictureSize(640,480); camera.setParameters(camera_parameters);
( EDIT: I already checked that 640x480 is available for both preview and image). Then the application works as I expected.
The problem occurs when you try to configure configuration "A". This time I set the texture look wider than tall, and execute the following code:
camera_parameters = camera.getParameters(); camera_parameters.set("orientation", "portrait"); camera_parameters.setPreviewSize(640,480); camera_parameters.setPictureSize(640,480); camera.setParameters(camera_parameters);
Unfortunately, this does not quite do the job. What I get when the application is running looks more like:
As you can see, the image displayed in this preview is essentially an image that is wider than it is tall, which was deformed into a rectangle that is larger than its width. The resulting saved jpeg image file is also wider than tall.
I thought that maybe I needed to change the code to the following:
camera_parameters = camera.getParameters(); camera_parameters.set("orientation", "portrait"); camera_parameters.setPreviewSize(480,640); camera_parameters.setPictureSize(480,640); camera.setParameters(camera_parameters);
But this throws a setParameters failed exception.
So my question is: what parameters should be set for which values, between camera.getParameters(); and setParameters(camera_parameters); ?