Zxing is a QR code scanning project provided by Google
The demo itself is the default sweep area of the largest only 360*480 need to pull up a very long distance ability to scan the entire QR code to
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 of the 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 smallest width and height; Maximum width and height
The number of references actually works 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 the change 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; }
Wide height I occupied the screen of the 7/10
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 beautified in the Viewfinderview class where it is drawn
Please leave a message below thank you
I hope to be useful to you
Resources : http://download.csdn.net/detail/aaawqqq/7281577