GetSupportedPreviewSize returns the inverse width and height

I use DroidX to develop an application that uses a camera preview image. The code I use can be found in many places on the Internet, but I noticed that the general method getBestPreviewSize (width, height, camera.parameters) "returns such a small size that the standard decodeYUV420SP method fails with the exception of a null pointer.

Some debugging shows that the supported viewsPreviewSizes for my DroidX:

  • 144h x 176w
  • 240h ​​x 320w
  • 288h x 352w
  • 480h x 640w
  • 480h x 720w
  • 448h x 800w
  • 720h x 1280w

Note that the height and width values ​​provide a landscape perspective. This does not change with the orientation of the camera. The width and height of the surface extending to getBestSupportedPreviewSizesis 480w x 778h.

When I pass the camera.parameters parameters to getBestSupportedPreviewSizes(), it returns a size of 288 x 352. Here is the call code - I am sorry if the format is off, but here it goes:

      if (!cameraConfigured) {
        Camera.Parameters parameters=camera.getParameters();
        Camera.Size size=getBestPreviewSize(pwidth, pheight, parameters);
        if (size!=null) {
          parameters.setPreviewSize(size.width, size.height);
          camera.setParameters(parameters);
          cameraConfigured=true;
        }
    }

pwidthand pheightrelate to the width and height parameters of the callback surfaceChanged. I tried camera.setDisplayOrientation (90); in onResume (). I also indicated the orientation (“Portrait”) in the manifest - none of these four combinations of these attempts changed this behavior.

- , . , , , , , . - ?

.

+5
1

, , , "".

getBestPreviewSize( w, h, p ) - getSupportedPreviewSizes() Camera.Parameters, bestPreviewSize.

+3

All Articles