嗨,我在我的应用程序中使用自定义相机视图,它在某些设备上运行良好,但在 1+3t 设备中它只捕获屏幕的一部分。我已经搜索了很多,但无法得到答案。请帮我解决这个问题。
代码:
@Override
protected void prepareCameraOutputs() {
try {
if (configurationProvider.getMediaQuality() == Configuration.MEDIA_QUALITY_AUTO) {
camcorderProfile = CameraHelper.getCamcorderProfile(currentCameraId, configurationProvider.getVideoFileSize(), configurationProvider.getMinimumVideoDuration());
} else
camcorderProfile = CameraHelper.getCamcorderProfile(configurationProvider.getMediaQuality(), currentCameraId);
final List<Size> previewSizes = Size.fromList(camera.getParameters().getSupportedPreviewSizes());
final List<Size> pictureSizes = Size.fromList(camera.getParameters().getSupportedPictureSizes());
List<Size> videoSizes;
if (Build.VERSION.SDK_INT > 10)
videoSizes = Size.fromList(camera.getParameters().getSupportedVideoSizes());
else videoSizes = previewSizes;
videoSize = CameraHelper.getSizeWithClosestRatio(
(videoSizes == null || videoSizes.isEmpty()) ? previewSizes : videoSizes,
camcorderProfile.videoFrameWidth, camcorderProfile.videoFrameHeight);
photoSize = CameraHelper.getPictureSize(
(pictureSizes == null || pictureSizes.isEmpty()) ? previewSizes : pictureSizes,
configurationProvider.getMediaQuality() == Configuration.MEDIA_QUALITY_AUTO
? Configuration.MEDIA_QUALITY_HIGHEST : configurationProvider.getMediaQuality());
if (configurationProvider.getMediaAction() == Configuration.MEDIA_ACTION_PHOTO
|| configurationProvider.getMediaAction() == Configuration.MEDIA_ACTION_UNSPECIFIED) {
previewSize = CameraHelper.getSizeWithClosestRatio(previewSizes, photoSize.getWidth(), photoSize.getHeight());
} else {
previewSize = CameraHelper.getSizeWithClosestRatio(previewSizes, videoSize.getWidth(), videoSize.getHeight());
}
} catch (Exception e) {
Log.e(TAG, "Error while setup camera sizes.");
}
}
并调用此相机 = Camera.open(cameraId); 准备相机输出();if(futurFlashMode != null) { setFlashMode(futurFlashMode); 未来闪光模式=空;我正在使用https://github.com/florent37/CameraFragment/tree/master/camerafragment