S
S
Stim7772015-09-15 23:47:03
Android
Stim777, 2015-09-15 23:47:03

How to set the camera to landscape orientation when the screen is in portrait?

043b88e0b90b46978d4b0b05faf22aa6.jpg
Tell me how to set up a camera preview, what would be as shown in the screenshot. At the moment, it turns out that the image is stretched in width (that is, a vertical preview). If you just change the width and height, then the application crashes at the maximum resolution.

private void resumeCamera() {
        prevScannedCode = "";

        mCamera = getCameraInstance();
        mPreview = new CameraPreview(rootView.getContext(), mCamera, previewCb, autoFocusCB);
        preview.removeAllViews();
        preview.addView(mPreview);
        if (mCamera != null) {
            Camera.Parameters parameters = mCamera.getParameters();
            List<Size> previewSizes = parameters.getSupportedPreviewSizes();
            Size size = previewSizes.get(0);
            for (int i=0; i<previewSizes.size(); i++){
                if (previewSizes.get(i).width > size.width)
                size = previewSizes.get(i);
            }

            parameters.setPreviewSize(size.width, size.height);
            parameters.set("jpeg-quality", 100);
            mCamera.setParameters(parameters);

            codeImage = new Image(size.width, size.height, "Y800");
            previewing = true;
            mPreview.refreshDrawableState();
        }
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question