How to increase the size of the scan area in zxing

Hi to everyone who is currently working on scanning qr code from my application, and I used the zxing library, and it works well, and my problem is in my s4 mobile galaxy. The scan area is very small. enter image description here

Please help me

early

+6
source share
4 answers

The CameraManager class has two constants defined by MIN_FRAME_WIDTH and MIN_FRAME_HEIGHT . You must change them as you wish, and everything should work:

 private static final int MIN_FRAME_WIDTH = 240; // (your desired value here) private static final int MIN_FRAME_HEIGHT = 240; // (your desired value here) 
+2
source

I know it's too late, but to help others just go to the camera manager class and paste this code when replacing this method, it works for all types of screens

  public Rect getFramingRect() { if (framingRect == null) { if (camera == null) { return null; } Point screenResolution = configManager.getScreenResolution(); int width = screenResolution.x * 3 / 4; int height = screenResolution.y * 3 / 4; Log.v("Framing rect is : ", "width is "+width+" and height is "+height); int leftOffset = (screenResolution.x - width) / 2; int topOffset = (screenResolution.y - height) / 2; framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height); Log.d(TAG, "Calculated framing rect: " + framingRect); } return framingRect; } 
+7
source
 public Rect getFramingRect() { if (framingRect == null) { if (camera == null) { return null; } Point screenResolution = configManager.getScreenResolution(); int screenx = screenResolution.x; int screeny = screenResolution.y; int width, height, left, top; if (screenx > screeny) { width = (int) (screenx * 12.5 / 100); height = (int) (screeny * 25 / 100); left = (int) screenx * 83 / 100; top = (int) screeny * 75 / 100; } else { left = (int) (screenx * 12.5 / 100); top = (int) (screeny * 25 / 100); width = (int) screenx * 83 / 100; height = (int) screeny * 75 / 100; } framingRect = new Rect(left,top, width, height); Log.d(TAG, "Calculated framing rect: " + framingRect); } return framingRect; } 

Replace the above code in CameraManager.java file this worked for me, try this

+2
source

If you call it from another Android application, use the additional settings SCAN_WIDTH and SCAN_HEIGHT for this.

If you use phonegap-plug-barcodescanner (3.0.0 or later), transferring the same intentions as xxxxx.scan (onSuccessFunc, onFailFunc, {SCAN_HEIGHT: 111, SCAN_WIDTH: 222}) will produce the same result. 111 is the height, and 222 is the width.

+1
source

Source: https://habr.com/ru/post/959376/


All Articles