自己遇到的问题:/**

   * Like {@link #getFramingRect} but coordinates are in terms of the preview frame,
* not UI / screen.
*/
public Rect getFramingRectInPreview() {
if (framingRectInPreview == null) {
Rect rect = new Rect(getFramingRect());
Point cameraResolution = configManager.getCameraResolution();
Point screenResolution = configManager.getScreenResolution();
// 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; /*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;*/
/***lyl TODO 修改识别区域为全屏***/
    //自己傻乎乎的把这里的参数改了以后,在自己跟部分手机上运行,识别,都可以实现全屏识别。但是没想到发版本后,好多手机都出现了崩溃问题。
    
rect.left = 0;
rect.right =screenResolution.x;
rect.top = 0;
rect.bottom =screenResolution.y;
framingRectInPreview = rect;
}
return framingRectInPreview;
}

出错的位置是:

  /**
* A factory method to build the appropriate LuminanceSource object based on the format
* of the preview buffers, as described by Camera.Parameters.
*
* @param data A preview frame.
* @param width The width of the image.
* @param height The height of the image.
* @return A PlanarYUVLuminanceSource instance.
*/
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) {
Rect rect = getFramingRectInPreview();
int previewFormat = configManager.getPreviewFormat();
String previewFormatString = configManager.getPreviewFormatString();
switch (previewFormat) {
// This is the standard Android format which all devices are REQUIRED to support.
// In theory, it's the only one we should ever care about.
case PixelFormat.YCbCr_420_SP:
// This format has never been seen in the wild, but is compatible as we only care
// about the Y channel, so allow it.
case PixelFormat.YCbCr_422_SP:
return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
rect.width(), rect.height());
default:
// The Samsung Moment incorrectly uses this variant instead of the 'sp' version.
// Fortunately, it too has all the Y data up front, so we can read it.
if ("yuv420p".equals(previewFormatString)) {
return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
rect.width(), rect.height());
}
}
throw new IllegalArgumentException("Unsupported picture format: " +
previewFormat + '/' + previewFormatString);
}
 public PlanarYUVLuminanceSource(byte[] yuvData, int dataWidth, int dataHeight, int left, int top,
int width, int height) {
super(width, height);
  //报错的是这里。
if (left + width > dataWidth || top + height > dataHeight) {
throw new IllegalArgumentException("Crop rectangle does not fit within image data.");
} this.yuvData = yuvData;
this.dataWidth = dataWidth;
this.dataHeight = dataHeight;
this.left = left;
this.top = top;
}

原文链接: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);

zxing全屏识别(v2.5.0崩溃问题记录)的更多相关文章

  1. 在VC++6.0开发中实现全屏显示

    全屏显示是一些应用软件程序必不可少的功能.比如在用VC++编辑工程源文件或编辑对话框等资源时,选择菜单“View\Full Screen”,即可进入全屏显示状态,按“Esc”键后会退出全屏显示状态. ...

  2. UI: 窗口全屏, 窗口尺寸

    窗口全屏 窗口尺寸 示例1.窗口全屏UI/FullScreen.xaml <Page x:Class="Windows10.UI.FullScreen" xmlns=&quo ...

  3. 背水一战 Windows 10 (3) - UI: 窗口全屏, 窗口尺寸

    [源码下载] 背水一战 Windows 10 (3) - UI: 窗口全屏, 窗口尺寸 作者:webabcd 介绍背水一战 Windows 10 之 UI 窗口全屏 窗口尺寸 示例1.窗口全屏UI/F ...

  4. MFC 带Ribbonbar的窗口 实现全屏和取消全屏

    void CMainFrame::FullScreen(){    m_wndRibbonBar.ShowWindow(SW_HIDE);//隐藏工具栏         m_wndStatusBar. ...

  5. js控制全屏及退出全屏

    js控制全屏及退出全屏,网上很多代码例子,我这里需求和标准的有点出入: 1.当用户点击某按钮,触发iframe下的页面全屏. 2.不允许用户退出全屏. 解决第一点,触发全屏可以按照网上的例子,代码如下 ...

  6. Android全屏(包含3种隐藏顶部状态栏及标题栏和一种隐藏Android 4.0平板底部状态栏的方法)

    http://www.xuebuyuan.com/558284.html 方法一 public class MainActivity extends Activity { @Override prot ...

  7. Phonegap 3.0 设置APP是否全屏

    Phonegap 3.0 默认是全屏,如需要取消全屏,可手动修改config, 在APP/res/xml/config.xml文件可设置preference: <?xml version='1. ...

  8. Android6.0 源码修改之 仿IOS添加全屏可拖拽浮窗返回按钮

    前言 之前写过屏蔽系统导航栏功能的文章,具体可看Android6.0 源码修改之屏蔽导航栏虚拟按键(Home和RecentAPP)/动态显示和隐藏NavigationBar 在某些特殊定制的版本中要求 ...

  9. Android学习之Android 5.0分享动画实现微信点击全屏效果

    Android5.0过渡动画,请看 http://blog.csdn.net/qq_16131393/article/details/51112772 今天用分享动画实现微信点击全屏效果 本文源代码下 ...

随机推荐

  1. RBAC表

    --权限管理1 CREATE TABLE SystemLog--日志表 ( Id ,) PRIMARY KEY,--主键id UserName ) NOT NULL,--用户名称,创建日志的用户名称 ...

  2. js 原生图片上传

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. threading的join功能

    you can go here to see the details. 我的理解:使用join后,使主线程执行完后(挂起),子线程再执行完后,主线程才结束.否则主线程会直接结束导致子线程不会执行. i ...

  4. iar stm32 启动代码片段分析

    今天查看了 iar 上面的启动文件,好奇堆栈指针到底是什么时候赋值的,所以就仔细的阅读了代码和相关手册,找到了答案. 首先,芯片启动后,会从ROM的首地址处进行执行,那么我们从 linker 里面找找 ...

  5. CouldnotcreatetheJavaVirtualMachine/1709

    Section A: symptom --------------------   SWPM1024 S/4hana 1709 安装过程中遇到error, 错误提示错误信息在/tmp/sapinst_ ...

  6. Java HttpClient PostMethod

    import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.PostMe ...

  7. python 3.4 error: Microsoft Visual C++ 10.0 is required(Unable to find vcvarsall.bat)

    一些小技巧 我是在windows 64下安装的python3.4 Python 我在安装theano时报这个错,网上找了不少资料.自己摸索着解决了. 你先打开dos界面.我用set命令查看一下: 发现 ...

  8. requirements.txt 的使用与创建

    1. requirements.txt  主要是记录你的python 解释器安装了那些第三方模块,这样好方便项目迁移,自动解决掉项目的依赖关系 2. 网上找的那些关于 requirements 的文档 ...

  9. SRM-相关资料路径

    SRM采购管理平台功能介绍 https://wenku.baidu.com/view/b05cff5930b765ce0508763231126edb6f1a763c.html https://wen ...

  10. deploy service on swarm

    转自:https://www.cnblogs.com/jsonhc/p/7852530.html swarm集群配置完成后,查看一些基本的信息: [root@manager1 ~]# docker-m ...