最近在搞一个关于条形码扫描的软件,需求需要扫描时是竖屏。
最后在zxing官方wiki上面找到解决办法。基本思路如下。
There are 4 relative files:
1, manifest.xml, you need to make CaptureActivity portrait.
2, DecodeHandler.java, rotate data before buildLuminanceSource, it works becuase in YCbCr_420_SP and YCbCr_422_SP, the Y channel is planar and appears first
平板视图
打印 ?
1
byte[] rotatedData =new byte[data.length];
2
for (int y =0; y < height; y++) {
3
for (int x =0; x < width; x++)
4
rotatedData[x * height + height - y -1] = data[x + y * width];
5
}
3, CameraManager.java, getFramingRectInPreview() need to be modified.
平板视图
打印 ?
1
rect.left = rect.left * cameraResolution.y / screenResolution.x;
2
rect.right = rect.right * cameraRes