优化代码

main
Matthew 8 months ago
parent 280f0055f6
commit afefe0027f

@ -706,9 +706,11 @@ public class Camera2RawFragment extends Fragment
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
// For still image captures, we use the largest available size. // For still image captures, we use the largest available size.
Size largestJpeg = Collections.max( Size[] resolutions = map.getHighResolutionOutputSizes(ImageFormat.JPEG);
Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)), if (resolutions == null) {
new CompareSizesByArea()); resolutions = map.getOutputSizes(ImageFormat.JPEG);
}
Size largestJpeg = Collections.max(Arrays.asList(resolutions), new CompareSizesByArea());
synchronized (mCameraStateLock) { synchronized (mCameraStateLock) {
// Set up ImageReaders for JPEG and RAW outputs. Place these in a reference // Set up ImageReaders for JPEG and RAW outputs. Place these in a reference
@ -1057,22 +1059,18 @@ public class Camera2RawFragment extends Fragment
} }
// Find the best preview size for these view dimensions and configured JPEG size. // Find the best preview size for these view dimensions and configured JPEG size.
final Size previewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), final Size previewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class),
rotatedViewWidth, rotatedViewHeight, maxPreviewWidth, maxPreviewHeight, rotatedViewWidth, rotatedViewHeight, maxPreviewWidth, maxPreviewHeight,
largestJpeg); largestJpeg);
mMessageHandler.postDelayed(new Runnable() { if (swappedDimensions) {
@Override mTextureView.setAspectRatio(
public void run() { previewSize.getHeight(), previewSize.getWidth());
if (swappedDimensions) { } else {
mTextureView.setAspectRatio( mTextureView.setAspectRatio(
previewSize.getHeight(), previewSize.getWidth()); previewSize.getWidth(), previewSize.getHeight());
} else { }
mTextureView.setAspectRatio(
previewSize.getWidth(), previewSize.getHeight());
}
}
}, 0);

Loading…
Cancel
Save