First to show you the effect of the picture:
The scan is the following one, and the two-dimensional code is generated using the Zxing library.
Because of the change of several classes, or last year's things are almost forgotten, so only on the code of this class, the main is to change the Captureactivity.java
Package com.zxing.activity;
Import java.io.IOException;
Import Java.util.Vector;
Import android.app.Activity;
Import android.content.
Now when the two-dimensional code is so popular, you must also know how the two-dimensional code is generated. Now let's take a look at how it was built.
In fact, the main use of the goggle released by the jar: This article to turn to open the link 1, two-dimensional code generation
Add the Zxing-core.jar package to the classpath. The generation of two-dimensional code needs the help of Matrixtoimagewriter class, this class is provided by Google, can
first download the corresponding jar package, this example uses the Zxing2.2jar
Download Address: http://download.csdn.net/detail/gao36951/8161861
Zxing is a Google-provided analytical tool for barcode (one-dimensional code, two-dimensional code), which provides a method for generating and parsing two-dimensional codes,See zxing example below Code:
Package com.zxing.create;
Import Java.awt.image.Buffered
notes, Google zxing two-dimensional code, with data flow output to the page display
Two-dimensional code has been very popular, today practiced a bit, requirements are generated for the different parameters of the address link two-dimensional code, and displayed on the page, if the use of generated pictures to save the local return to the relative path, will produce a heap of garbage picture files, but also to remove the late is really trouble, think
Zxing is a QR code scanning project provided by GoogleThe 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 toSo we need to adjust the size of the map ourselves.Make adjustments in the Cameramanager.java classThe 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;//
As follows:The production process is very simple is to add a logn icon in the original two-dimensional code image, the code of the comments written in detail, it will not give you a long-windedPackage Com.example.day44_02_qrcodewithlogin;import Java.util.hashmap;import Java.util.map;import Android.app.activity;import Android.graphics.bitmap;import Android.graphics.bitmap.config;import Android.graphics.bitmapfactory;import Android.graphics.canvas;import Android.os.bundle;import Android.view.Menu;
width = display. GetWidth();int height = display. GetHeight();if (width ;width = height;Height = Temp;} screenresolution = new Point (height, width);Cameraresolution = findbestpreviewsizevalue (Parameters, new point (width, height));Step 4:add following line to rotate Camera insetdesiredcameraparameters (...)Cameraconfigurationmanager.javacamera.setDisplayOrientation(90);Step 5:do not forget to set orientation of activity to portrait. I.e:manifest Copyright NOTICE: This article for Bo Master or
Http://cache.baidu.com/C? M = listen P = 83759a46d0c906f450ed903a00009cc70 newp = Comment User = Baidu fm = SC query = zxing % D0 % de % B8 % c4 % B4 % F3 % D0 % A1 qid = be19cfbe16976dec p1 = 2
After I use the method described in the above article, the screen is blurred, just because Step 5 does not change the parameters affected by Step 5, so I changed getframingrectinpreview in cameramanager:
Rect = new rect (framingrect );Point cameraresolu
Android QR code scanning (zxing usage summary)
There are three main points:
1. Draw the interface, including four corners, scrolling up and down, and adding text to the canvas
2. Adjust the position of the QR code scan box.
3. Solve the Problem of image deformation.
1. Draw the onDraw () method in ViewfinderView. java on the page
@ Overridepublic void onDraw (Canvas canvas) {// scan box in the middle. Modify the size of the scan box and modify Rect fr
This simple question bothered me for nearly two hours, the main is the official document did not find the demo, that can only use search engines, see other programmers to write the program, but found everywhere is a pit, see four or five examples, no one can be normal operation, all the error, after one hours of trial, only to finish. Not much to say, directly on the screenshot and code.
First, add the Zxing.dll reference to the project (zxing.dll download address http://www.jb51.net/dll/zxing.
For a few days Android, feeling zxing very large, a lot of bags,
Personal recommendation: Java EE display two-dimensional code, or upload to two-dimensional code to parse or .... Android Build scan Parse two-dimensional code
Download Address
http://download.csdn.net/detail/hejias/5891099
-------------------------------------------------------------------Gorgeous split Line------------------------------------------------ -----------------------------
First, add the jar pack
com.google.zxing
core
3.0.0
com.google.zxing
javase
3.0.0
First, the operation of the bar code
Import Java.awt.image.BufferedImage;
Import Java.io.File;
Import
First, download zxing.net
The address is: http://zxingnet.codeplex.com/releases/view/117068
Then drag the corresponding version. dll into the project, and then refer to it.
Mainly used Barcodewriter, Barcodereader.
Two, generate two dimensional
The first is simple coding, the code is as follows
/**
* Two-dimensional encoding based on strings *
@param str needs to encode the string
* @param widthandheight the height of the bitmap that needs to be generated
@return
*
/Public
Viewfinderview customizes the view and implements a simple scanning interface. This article record my understanding of Android camera in the code process. Since I started to write a technical blog, there are many shortcomings in the first two
Error:Indexoutofrangeexception:array Index is out of range.ZXing.Color32Renderer.Render (ZXing.Common.BitMatrix Matrix, barcodeformat format, System.String content, ZXing.Common.EncodingOptions options)Zxing.barcodewritergeneric ' 1[toutput]. Write (
Zxing is an open source repository for Google. can be used to generate two-dimensional code, scan two-dimensional code. The first part is described in this article.First Up:Zxing related various documents Official:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.