Apache license 2.0 open-source zxing Project
There are too many things for zxing Android projects, many of which we don't need. We need to create another project to simplify it.
Before you begin, let's briefly introduce the responsibilities of various packages and classes used to simplify zxing.
Captureactivity. This is to start the activity, that is, the scanner (if it is the first installation, it will jump to the help interface ).
Captureactivityhandler decoding class, which calls another thread for decoding.
The decodethread decoding thread.
Com. Google. zxing. Client. Android. Camera package and camera control package.
The custom view of viewfinderview is the frame in the middle of the shooting.
Solution:
1. Modify the decode method in decodehandler. java.
Planaryuvluminancesource source = cameramanager. Get (). buildluminancesource (data, width, height );
Is
Byte [] rotateddata = new byte [data. Length];
For (INT y = 0; y For (INT x = 0; x <width; X ++)
Rotateddata [x * height + height-y-1] = data [x + y * width];
}
Int TMP = width; // here we are swapping, that's the difference to #11
Width = height;
Height = TMP;
Planaryuvluminancesource source = cameramanager. Get (). buildluminancesource (rotateddata, width, height );
2. In cameramanager. Java, comment on the Code:
// Rect. Left = rect. Left * cameraresolution. X/screenresolution. X;
// Rect. Right = rect. Right * cameraresolution. X/screenresolution. X;
// Rect. Top = rect. Top * cameraresolution. Y/screenresolution. Y;
// Rect. Bottom = rect. Bottom * cameraresolution. Y/screenresolution. Y;
Change
Rect. Left = rect. Left * cameraresolution. Y/screenresolution. X;
Rect. Right = rect. Right * cameraresolution. Y/screenresolution. X;
Rect. Top = rect. Top * cameraresolution. X/screenresolution. Y;
Rect. Bottom = rect. Bottom * cameraresolution. X/screenresolution. Y;
3. In cameraconfigurationmanager. Java, add a sentence in the setdesiredcameraparameters method.
Camera. setdisplayorientation (90 );
4. In androidmanifest. XML, set the activity attribute Android: screenorientation = "Landscape"
Change
Android: screenorientation = "portrait"
Compile and run it!
Refer:
Http://code.google.com/p/zxing/issues/detail? Id = 178 # c46
Code:
Https://github.com/pplante/zxing-android