Answer the question
In order to leave comments, you need to log in
How to set the camera to landscape orientation when the screen is in portrait?
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 questionAsk a Question
731 491 924 answers to any question