上次使用QRCode.js可以来生成二维码,但是我没有找到有文档说明可以对存在的二维码进行扫描解析其中的内容。

幸亏查找到了可行的解决方案,而且很好使哦!就是reqrcode.js

地址:https://gitee.com/weijunw/erweima/tree/master

 reqrcode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
,)),ne
w _a2(
)),n
ew _a2(,
){return new _ae(c-d,b-c,d,m-p
,k-m,p,,d+k);var e=new _ak(this.image,h,b,i-h,c-b,g,this._am);return e.find()};this.createTransform=function(l,h,k,
b,g){)]};_ax._ci=function(a){var
 b=_ax._cj(a);)}}}}function _dl(a,b){this._dv=a;this._dw=b;this.__defineGetter__("_du",function(){return this._dv});this.__defineGetter__("Codewords",function(){return this._dw})}_dl._gn=function(c,h,r)
{}}}}n^=true}if(m!=o.
_dp){){throw"ReedSolomonException Bad error location"}j[h]=_az._bd(j[
h],e[g])}};;k<l;k++){j=_az._bd(this._fa.multiply(h,j),t
his._dd[k])}){return zero}var h=new Array(j+
);return}else{qrcode.canvas_qr
,i.width,i.height);qrcode.width=i.width;qrcode.height=i.height;try{qrcode
.imagedata=h.getImageData(+qrcod
e.imagedata.data[a+;this._aj=b;this.__defineGetter__("
_ei",function(){return this._aj});this.__defineGetter__("Count",function(){return this.count});this.__defineGetter__("X",function(){return this.x});this.__defineGetter__("Y",function(){return this.y});this._ek=function(){this.count++};this._ev=function(f,e,d){if(Math.abs(e-this.y)<=f&&Math.abs(d-this.x)<=f){var g=Math.abs(f-this._aj);return g<=1||g/this._aj<=1}return false}}function _es(a){this._go=a[0];this._gu=a[1];this._gr=a[2];this.__defineGetter__("_gp",function(){return this._go});this.__defineGetter__("_gq",function(){return this._gu});this.__defineGetter__("_gs",function(){return this._gr})}function _cc(){this.image=null;this._cv=[];this._ge=false;this._al=new Array(0,0,0,0,0);this._am=null;this.__defineGetter__("_da",function(){this._al[0]=0;this._al[1]=0;this._al[2]=0;this._al[3]=0;this._al[4]=0;return this._al});this._ao=function(f){var b=0;for(var d=0;d<5;d++){var e=f[d];if(e==0){return false}b+=e}if(b<7){return false}var c=Math.floor((b<<_el)/7);var a=Math.floor(c/2);return Math.abs(c-(f[0]<<_el))<a&&Math.abs(c-(f[1]<<_el))<a&&Math.abs(3*c-(f[2]<<_el))<3*a&&Math.abs(c-(f[3]<<_el))<a&&Math.abs(c-(f[4]<<_el))<a};this._an=function(b,a){return(a-b[4]-b[3])-b[2]/2};this._ap=function(a,j,d,g){var c=this.image;var h=qrcode.height;var b=this._da;var f=a;while(f>=0&&c[j+f*qrcode.width]){b[2]++;f--}if(f<0){return NaN}while(f>=0&&!c[j+f*qrcode.width]&&b[1]<=d){b[1]++;f--}if(f<0||b[1]>d){return NaN}while(f>=0&&c[j+f*qrcode.width]&&b[0]<=d){b[0]++;f--}if(b[0]>d){return NaN}f=a+1;while(f<h&&c[j+f*qrcode.width]){b[2]++;f++}if(f==h){return NaN}while(f<h&&!c[j+f*qrcode.width]&&b[3]<d){b[3]++;f++}if(f==h||b[3]>=d){return NaN}while(f<h&&c[j+f*qrcode.width]&&b[4]<d){b[4]++;f++}if(b[4]>=d){return NaN}var e=b[0]+b[1]+b[2]+b[3]+b[4];if(5*Math.abs(e-g)>=2*g){return NaN}return this._ao(b)?this._an(b,f):NaN};this._ej=function(b,a,e,h){var d=this.image;var i=qrcode.width;var c=this._da;var g=b;while(g>=0&&d[g+a*qrcode.width]){c[2]++;g--}if(g<0){return NaN}while(g>=0&&!d[g+a*qrcode.width]&&c[1]<=e){c[1]++;g--}if(g<0||c[1]>e){r
*c};this._ce=function(e){var o=false;this.image=e;var n=qrcode.height;var k=qrcode.
width;
]+l[}else{return
 ;i<m.length;i++){k[i]=m.charCodeAt(i)}h.push(k);break;case d:var n=this.get8bitByteArray(g);h.push(n);break;case o:var m=this.getKanjiString(g);h.push(m);break}}while(true);return h})};
 
解析实例:

 qrcodeRD.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>QRCode Reader</title>
    <script src="jquery.min.js"></script>
    <script src="reqrcode.js"></script>
</head>

<body>
    <input type="file" id="newfile">
</body>

<script>
    var newfile = document.getElementById('newfile');
    var getObjectURL = function (file) {
        var url = null;
        if (window.createObjectURL != undefined) {          // basic
          url = window.createObjectURL(file);
        } else if (window.URL != undefined) {               // mozilla(firefox)
        url = window.URL.createObjectURL(file);
        } else if (window.webkitURL != undefined) {         // webkit or chrome
          url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }

newfile.onchange = function () {
        //   console.log(newfile[0]);
        console.log(getObjectURL(this.files[0]));           // newfile[0]是通过input file上传的二维码图片文件
        qrcode.decode(getObjectURL(this.files[0]));
        qrcode.callback = function (imgMsg) {
            alert("二维码解析:" + imgMsg)
        }
    }
</script>

</html>

运行

注意:reqrcode.js格式是不是不好看,但是格式化后就不好使了  ~

二维码解析:使用 JavaScript 库reqrcode.js解析二维码的更多相关文章

  1. 二维码生成:使用 JavaScript 库QRCode.js生成二维码

    QRCode.js:跨浏览器的javascript二维码生成库,支持html5的Canvas画布,没有任何依赖. Github 地址:https://github.com/davidshimjs/qr ...

  2. 使用医学影像开源库cornerstone.js解析Dicom图像显示到HTML中

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

  3. HTML5 Canvas JavaScript库 Fabric.js 使用经验

    首先,表明我的态度:采用 Flash 才是最优方案,不建议使用 HTML 5 的 Canvas 做一些生产/工业级的网页应用. Flash的优势一是浏览器支持好,二是代码成熟稳定.而HTML5 的 C ...

  4. 网页3D效果库Three.js学习[二]-了解照相机

    camera 上篇大致了解了three.js ,并可以创建一个简单的可动的立方体.下来我们着重了解下camera (照相机),照相机其实就是视角,就像你的眼睛.Three.js有两种不同的相机模式:直 ...

  5. 一个用于格式化和处理数字的javascript库----Numeral.js

    npm地址:https://www.npmjs.com/package/numeral 1.转化成百分比: numeral(num).format('0.00%')

  6. 脸部识别JavaScript类库Tracking.js

    作者 王文刚 发布于 2014年8月10日 |   对Web开发者而言,开源的JavaScript库Tracking.js正在使计算机视觉和增强现实技术变得简单, 使用它可以展示效果类似Kinect或 ...

  7. QRCode.js一个生成二维码的javascript库

    前言 最近在开发中遇到一个需求:将后端返回的链接转换成二维码,那么如何来实现呢?我们可以使用QRCode.js来解决这一问题 什么是 QRCode.js? QRCode.js 是一个用于生成二维码的 ...

  8. 你不可错过的二维码生成与解析-java后台与前端js都有

    1.二维码分类   二维条码也有许多不同的码制,就码制的编码原理而言,通常分为三种类型. 线性堆叠式二维码 编码原理: 建立在一维条码基础之上,按需要堆积成两行或多行. 图示: 矩阵式二维码 最常用编 ...

  9. QRCode.js生成二维码

    QRCode的GitHub地址: https://github.com/KeeeX/qrcodejs 该版本解决了主版本(https://github.com/davidshimjs/qrcodejs ...

随机推荐

  1. jsPatch.qq.com呵呵

    jsPach.qq.comhtml, body {overflow-x: initial !important;}html { font-size: 14px; } body { margin: 0p ...

  2. C语言 · 判断回文

    算法提高 判断回文   时间限制:1.0s   内存限制:512.0MB      编程判断一个字符串是否是回文,当字符串是回文时,输出字符串:yes!,否则输出字符串:no!.所谓回文即正向与反向的 ...

  3. 【oneday_onepage】——美国主食吃什么

    Cocktail 鸡尾酒 It is quite usual to drink cocktails before lunch and dinner in America and somewhat le ...

  4. Java知多少(17)强调一下编程风格

    讲完了Java的基础语法,大家就可以编写简单的程序代码了,这里有必要强调一下编程风格. 代码风格虽然不影响程序的运行,但对程序的可读性却非常重要.自己编写的程序要让别人看懂,首先在排版方面要非常注意. ...

  5. 解决同时共用MOB公司的shareSDK和SMSSDK的冲突问题

    现在mob的SDK版本升级到3.0,跟之前的版本不兼容,尤其是在 同时使用shareSDK和SMSSDK的时候会发生冲突,报NoSuchMethodException的错误. 只需要将所有的jar包和 ...

  6. shell中调用R语言并传入参数的两种步骤

    shell中调用R语言并传入参数的两种方法 第一种: Rscript myscript.R R脚本的输出 第二种: R CMD BATCH myscript.R # Check the output ...

  7. 安卓程序代写 网上程序代写[原]ViewGroup(容器组件)详解(API解析)

    一. ViewGroup简介 1.View和ViewGroup关系 UI组件在Android中的位置 : Android中的UI组件大部分都放在android.widget 或者 android.vi ...

  8. 10、QT分析之WebKit

    该文章整理自 网易博客 http://blog.163.com/net_worm/blog/static/12770241920101831312381/ 转载请注明出处 WebKit是QT4新整合的 ...

  9. 关于Unity中物理检测的准备

    1.要确定每个物体的碰撞类型,是有碰撞效果的碰撞还是没有碰撞效果的碰撞(is trigger),带不带刚体. 2.给每个物体分层,再设置哪些层会发生碰撞,哪些完全不产生碰撞. 3.给每个物体设置标记, ...

  10. Python模拟Linux的Crontab, 写个任务计划需求

    Python模拟Linux的Crontab, 写个任务计划需求 来具体点 需求: 执行一个程序, 程序一直是运行状态, 这里假设是一个函数 当程序运行30s的时候, 需要终止程序, 可以用python ...