Zxing is a QR code scanning project provided by Google
The default sweep area of the demo itself is the largest only 360*480 need to pull a long distance to scan the entire QR code
So we need to adjust the size of the map ourselves.
Make adjustments in the Cameramanager.java class
The default size is the following 4 parameters
private static final int min_frame_width = 240;// private static final int min_frame_height = 240;// privat e static final int max_frame_width = 480;// private static final int max_frame_height = 360;
depending on the screen size , you can increase these values: the minimum width and height; Maximum width and height
Parameters actually work in the Getframingrect () method
The following is the original demo provided in the
/** * Calculates the framing rect which the UI should draw to show the user where to place the * barcode. This target helps with alignment as well as forces the user to hold the device * far enough away to ensure the image wil l am in focus. * * @return the rectangle to draw on screen in window coordinates. */Public Rect Getframingrect () {Point screenresolution = Configmanager.getscreenresolution (); if (Framingrect = = null) {if (camera = = null) {return null; }//native int width = screenresolution.x * 3/4; if (Width < min_frame_width) {width = min_frame_width; } else if (Width > max_frame_width) {width = max_frame_width; } int height = screenresolution.y * 3/4; if (height < min_frame_height) {height = min_frame_height; } else if (height > max_frame_height) {height = max_frame_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; }
I changed the code to fit a different screen size
Public Rect Getframingrect () {point screenresolution = Configmanager.getscreenresolution (); if (Framingrect = = null) { if (camera = = null) { return null; } After modification int width = screenresolution.x * 7/10; int height = screenresolution.y * 7/10; int leftoffset = (screenresolution.x-width)/2; int topoffset = (screenresolution.y-height)/3; Framingrect = new Rect (LeftOffset, Topoffset, LeftOffset + width, topoffset + height); LOG.D (TAG, "calculated framing Rect:" + framingrect); } return framingrect; }
I occupy 7/10 of the screen.
Of course... Take the picture to change so the assembly occupies a little bit of memory .... The corresponding scan is much faster.
The above is the actual size of the image read
The actual interface is painted in the Viewfinderview class.
Please leave a message below thank you
Want to be useful to you
Resources : http://download.csdn.net/detail/aaawqqq/7281577