完整阅读软件客户端app,本项目里面还有扫描功能,搜索本地书籍,不过扫码功能通过c++层实现的。
本项目来自:https://github.com/JayFang1993/ScanBook
CaptureActivity主要是摄像头相关类,CaptureActivityHandler所有扫描消息都发到这个Handler类中
部分代码如下:
private void initCamera(SurfaceHolder surfaceHolder) {
try {
CameraManager.get().openDriver(surfaceHolder);
} catch (IOException ioe) {
return;
} catch (RuntimeException e) {
return;
}
if (handler == null) {
handler = new CaptureActivityHandler(this, decodeFormats,characterSet);
}
}
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
}
public void surfaceCreated(SurfaceHolder holder) {
if (!hasSurface) {
hasSurface = true;
initCamera(holder);
}
}
public void surfaceDestroyed(SurfaceHolder holder) {
hasSurface = false;
}
运行效果:
源码地址:http://www.itlanbao.com/code/20151103/10000/100609.html