自己遇到的问题:/**

   * 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. 微信小程序 setData 的坑(转)

    最近在使用微信小程序的setData时,遇到了以下问题.如下: 官网文档在使用setData()设置数组对象的某个元素的属性时,是这么使用的: Page({ data: { array: [{text ...

  2. Ansible:遇到错误 "sudo: /etc/sudoers is world writable\r\nsudo: no valid sudoers sources found, quitting

    执行ansible-playbook时,遇到该错误: 经过检查发现是因为在Linux中 /etc/sudoers该文件必须是只读权限的才行,故我们需要修改其权限为440,到root账户下修改,直接ch ...

  3. python中len 小练习:获取并输出集合中的索引及对应元素

    len()用来获取长度.字节等数值 1 a = ["hello", "world", "dlrb"] 2 b = len(a) 3 for ...

  4. flex学习笔记 使用函数,显示实时更新的标签

    <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...

  5. RestTemplate的异步使用

    参考:https://blog.csdn.net/yezhuanxu/article/details/53643248 支持异步调用AsyncRestTemplate @RequestMapping( ...

  6. 浅析USB HID ReportDesc (HID报告描述符)

    在USB中,USB Host是通过各种描述符来识别识别设备的,一般在设备枚举的过程将会获取有设备描述符/配置描述符/接口描述符/端点描述符/字符串描述符等 现在我们来介绍一下HID ReportDes ...

  7. eclipse插件spket安装

    1.

  8. HTML学习-2标记标签-1

    大致可以分为以下6类学习: 1.通用标签. 2.常用标签. 3.表格标签. 4.表单元素. 5.框架. 6.其他. 一.通用标签.及属性 1.<body></body>标签,主 ...

  9. Java快速开发平台,JEECG 3.7.7闪电版本发布,增加多套主流UI代码生成器模板

    JEECG 3.7.7 闪电版本发布,提供5套主流UI代码生成器模板 导读 ⊙平台性能优化,速度闪电般提升           ⊙提供5套新的主流UI代码生成器模板(Bootstrap表单+Boots ...

  10. Hadoop 基本原理

    Hadoop 有2大核心HDFS  (Hadoop Distributed File System)分布式文件系统  , MapRedurce 归约计算 HDFS  把文件按块存储, NameNode ...