@@ -65,25 +65,20 @@ public void stopCamera() {
65
65
}
66
66
}
67
67
68
- public synchronized Rect getFramingRectInPreview (int width , int height ) {
68
+ public synchronized Rect getFramingRectInPreview (int previewWidth , int previewHeight ) {
69
69
if (mFramingRectInPreview == null ) {
70
70
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 ) {
72
74
return null ;
73
75
}
74
- Rect rect = new Rect (framingRect );
75
- Point screenResolution = DisplayUtils .getScreenResolution (getContext ());
76
- Point cameraResolution = new Point (width , height );
77
76
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 ;
87
82
88
83
mFramingRectInPreview = rect ;
89
84
}
0 commit comments