android 动态设置比重,如何将android camera2设置为18.5:9的比例
我尝试在Samsung Note 8上将camera2应用到我的应用程序,然而,预览中的图像会变形 .预览尺寸:2220x1080(比例18.5:9)相机尺寸:1920x1080(比例16:9)它似乎适合从1920x1080到2220x1080的图像大小如何全屏预览和捕捉图像(2220x1080)?public void createCameraPreviewSession() {try {Sur
我尝试在Samsung Note 8上将camera2应用到我的应用程序,然而,预览中的图像会变形 .
预览尺寸:2220x1080(比例18.5:9)
相机尺寸:1920x1080(比例16:9)
它似乎适合从1920x1080到2220x1080的图像大小
如何全屏预览和捕捉图像(2220x1080)?
public void createCameraPreviewSession() {
try {
SurfaceTexture texture = this.getSurfaceTexture();
assert texture != null;
texture.setDefaultBufferSize(previewSize.getWidth(), previewSize.getHeight());
Surface surface = new Surface(texture);
previewBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
previewBuilder.addTarget(surface);
cameraDevice.createCaptureSession(Arrays.asList(surface, reader.getSurface()),
new CameraCaptureSession.StateCallback() {
@Override
public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) {
if (null == cameraDevice) {
return;
}
previewSession = cameraCaptureSession;
thread = new HandlerThread("CameraPreview");
thread.start();
backgroundHandler = new Handler(thread.getLooper());
try {
previewBuilder.set(CaptureRequest.CONTROL_AF_MODE,CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
previewSession.setRepeatingRequest(previewBuilder.build(), null, backgroundHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
@Override
public void onConfigureFailed(
@NonNull CameraCaptureSession cameraCaptureSession) {
}
}, null
);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
更多推荐
所有评论(0)