@capgo/camera-preview 6.2.3 → 6.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -877,17 +877,26 @@ public class CameraActivity extends Fragment {
|
|
|
877
877
|
double targetRatio = (double) previewSize.width / previewSize.height;
|
|
878
878
|
Camera.Size optimalSize = null;
|
|
879
879
|
double minDiff = Double.MAX_VALUE;
|
|
880
|
+
long maxPixels = 0;
|
|
880
881
|
|
|
881
882
|
for (Camera.Size size : supportedSizes) {
|
|
882
883
|
double ratio = (double) size.width / size.height;
|
|
883
884
|
if (Math.abs(ratio - targetRatio) > 0.1) continue;
|
|
884
|
-
|
|
885
|
+
|
|
886
|
+
long pixels = (long) size.width * size.height;
|
|
887
|
+
if (pixels > maxPixels) {
|
|
888
|
+
maxPixels = pixels;
|
|
885
889
|
optimalSize = size;
|
|
886
|
-
|
|
890
|
+
} else if (pixels == maxPixels) {
|
|
891
|
+
if (Math.abs(size.height - height) < minDiff) {
|
|
892
|
+
optimalSize = size;
|
|
893
|
+
minDiff = Math.abs(size.height - height);
|
|
894
|
+
}
|
|
887
895
|
}
|
|
888
896
|
}
|
|
889
897
|
|
|
890
898
|
if (optimalSize == null) {
|
|
899
|
+
Log.d(TAG, "No picture size matches the aspect ratio");
|
|
891
900
|
minDiff = Double.MAX_VALUE;
|
|
892
901
|
for (Camera.Size size : supportedSizes) {
|
|
893
902
|
if (Math.abs(size.height - height) < minDiff) {
|