优化代码

main
Matthew 8 months ago
parent 280f0055f6
commit afefe0027f

@ -706,9 +706,11 @@ public class Camera2RawFragment extends Fragment
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
// For still image captures, we use the largest available size.
Size largestJpeg = Collections.max(
Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)),
new CompareSizesByArea());
Size[] resolutions = map.getHighResolutionOutputSizes(ImageFormat.JPEG);
if (resolutions == null) {
resolutions = map.getOutputSizes(ImageFormat.JPEG);
}
Size largestJpeg = Collections.max(Arrays.asList(resolutions), new CompareSizesByArea());
synchronized (mCameraStateLock) {
// Set up ImageReaders for JPEG and RAW outputs. Place these in a reference
@ -1028,7 +1030,7 @@ public class Camera2RawFragment extends Fragment
int deviceRotation = activity.getWindowManager().getDefaultDisplay().getRotation();
Point displaySize = new Point();
activity.getWindowManager().getDefaultDisplay().getSize(displaySize);
// Find the rotation of the device relative to the camera sensor's orientation.
int totalRotation = sensorToDeviceRotation(mCharacteristics, deviceRotation, getRotationAdjustment());
@ -1057,22 +1059,18 @@ public class Camera2RawFragment extends Fragment
}
// Find the best preview size for these view dimensions and configured JPEG size.
final Size previewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class),
rotatedViewWidth, rotatedViewHeight, maxPreviewWidth, maxPreviewHeight,
largestJpeg);
mMessageHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (swappedDimensions) {
mTextureView.setAspectRatio(
previewSize.getHeight(), previewSize.getWidth());
} else {
mTextureView.setAspectRatio(
previewSize.getWidth(), previewSize.getHeight());
}
}
}, 0);
if (swappedDimensions) {
mTextureView.setAspectRatio(
previewSize.getHeight(), previewSize.getWidth());
} else {
mTextureView.setAspectRatio(
previewSize.getWidth(), previewSize.getHeight());
}

Loading…
Cancel
Save