Skip to content

Commit 8c3fd35

Browse files
committed
Merge branch 'mbergou-master' into camera_id_support
2 parents 5f3608d + a987955 commit 8c3fd35

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

core/src/main/java/me/dm7/barcodescanner/core/BarcodeScannerView.java

+9-14
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,20 @@ public void stopCamera() {
6565
}
6666
}
6767

68-
public synchronized Rect getFramingRectInPreview(int width, int height) {
68+
public synchronized Rect getFramingRectInPreview(int previewWidth, int previewHeight) {
6969
if (mFramingRectInPreview == null) {
7070
Rect framingRect = mViewFinderView.getFramingRect();
71-
if (framingRect == null) {
71+
int viewFinderViewWidth = mViewFinderView.getWidth();
72+
int viewFinderViewHeight = mViewFinderView.getHeight();
73+
if (framingRect == null || viewFinderViewWidth == 0 || viewFinderViewHeight == 0) {
7274
return null;
7375
}
74-
Rect rect = new Rect(framingRect);
75-
Point screenResolution = DisplayUtils.getScreenResolution(getContext());
76-
Point cameraResolution = new Point(width, height);
7776

78-
if (cameraResolution == null || screenResolution == null) {
79-
// Called early, before init even finished
80-
return null;
81-
}
82-
83-
rect.left = rect.left * cameraResolution.x / screenResolution.x;
84-
rect.right = rect.right * cameraResolution.x / screenResolution.x;
85-
rect.top = rect.top * cameraResolution.y / screenResolution.y;
86-
rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y;
77+
Rect rect = new Rect(framingRect);
78+
rect.left = rect.left * previewWidth / viewFinderViewWidth;
79+
rect.right = rect.right * previewWidth / viewFinderViewWidth;
80+
rect.top = rect.top * previewHeight / viewFinderViewHeight;
81+
rect.bottom = rect.bottom * previewHeight / viewFinderViewHeight;
8782

8883
mFramingRectInPreview = rect;
8984
}

core/src/main/java/me/dm7/barcodescanner/core/CameraUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ public static boolean isFlashSupported(Camera camera) {
4545

4646
return true;
4747
}
48-
}
48+
}

0 commit comments

Comments
 (0)