原文链接:https://blog.csdn.net/yu_duan_hun/article/details/79388195
1.删除bundle传bitmap的部分直接改为全屏识别
(1)全屏扫样式更改
CameraManager.java
需要更改buildLuminanceSource()方法:
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) { return new PlanarYUVLuminanceSource(data, width, height, 0, 0, width, height); }
ViewfinderView.java
需要更改onDraw():
public void onDraw(Canvas canvas) { postInvalidateDelayed(ANIMATION_DELAY, 0, 0, getWidth(), getHeight()); }
(2)去掉传递图片(一般只需要扫码的条码号或者网址,扫码图片本身我们不关心,如果需要这部分需要对这个图片进行压缩处理,不然会出错)
MipActivityCapture.java
这里需要删掉handleDecode里面的bundle.putParcelable("bitmap", barcode);
,barcode这个参数也可以不用传递了。
相应的在CaptureActivityHandler.java的handleMessage中只需要传递msg.obj,下面这句可以删掉:
Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);
然后把DecodeHandler.java的decode()方法也改一下:
删掉下面的部分
Bundle bundle = new Bundle(); bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap()); message.setData(bundle);