优化代码

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,13 +1059,11 @@ 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() {
@Override
public void run() {
if (swappedDimensions) { if (swappedDimensions) {
mTextureView.setAspectRatio( mTextureView.setAspectRatio(
previewSize.getHeight(), previewSize.getWidth()); previewSize.getHeight(), previewSize.getWidth());
@ -1071,8 +1071,6 @@ public class Camera2RawFragment extends Fragment
mTextureView.setAspectRatio( mTextureView.setAspectRatio(
previewSize.getWidth(), previewSize.getHeight()); previewSize.getWidth(), previewSize.getHeight());
} }
}
}, 0);

Loading…
Cancel
Save