- public synchronized Rect getFramingRect() {
- if (framingRect == null) {
- if (camera == null) {
- return null;
- }
- Point screenResolution = configManager.getScreenResolution();
- if (screenResolution == null) {
- // Called early, before init even finished
- return null;
- }
- // int width = findDesiredDimensionInRange(screenResolution.x,
- // MIN_FRAME_WIDTH, MAX_FRAME_WIDTH);
- // int height = findDesiredDimensionInRange(screenResolution.y,
- // MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT);
- /* 扫描框修改 */
- DisplayMetrics metrics = context.getResources().getDisplayMetrics();
- int width = (int) (metrics.widthPixels * 0.6);
- int height = (int) (width * 0.9);
- int leftOffset = (screenResolution.x - width) / 2;
- int topOffset = (screenResolution.y - height) / 4;
- framingRect = new Rect(leftOffset, topOffset, leftOffset + width,
- topOffset + height);
- Log.d(TAG, "Calculated framing rect: " + framingRect);
- }
- return framingRect;
- }
Android zxing二维码扫描 扫描框适应各种分辨率
最新推荐文章于 2022-07-05 14:45:13 发布