You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.js
+29-21Lines changed: 29 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
/**
2
2
* EasyQRCodeJS-NodeJS
3
3
*
4
-
* NodeJS QRCode generator. Save image to file. Support Dot style, Logo, Background image, Colorful, Title, etc.(Running without DOM on server side)
4
+
* NodeJS QRCode generator. Can get standard base64 image data url text or save image to file. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. Support binary(hex) data mode. (Running without DOM on server side)
5
5
*
6
-
* Version 3.6.0
6
+
* Version 3.7.0
7
7
*
8
8
* @author [ inthinkcolor@gmail.com ]
9
9
*
@@ -25,7 +25,7 @@ var {
25
25
26
26
varfs=require('fs');
27
27
28
-
functionQR8bitByte(data){
28
+
functionQR8bitByte(data,binary){
29
29
this.mode=QRMode.MODE_8BIT_BYTE;
30
30
this.data=data;
31
31
this.parsedData=[];
@@ -35,20 +35,24 @@ function QR8bitByte(data) {
35
35
varbyteArray=[];
36
36
varcode=this.data.charCodeAt(i);
37
37
38
-
if(code>0x10000){
39
-
byteArray[0]=0xF0|((code&0x1C0000)>>>18);
40
-
byteArray[1]=0x80|((code&0x3F000)>>>12);
41
-
byteArray[2]=0x80|((code&0xFC0)>>>6);
42
-
byteArray[3]=0x80|(code&0x3F);
43
-
}elseif(code>0x800){
44
-
byteArray[0]=0xE0|((code&0xF000)>>>12);
45
-
byteArray[1]=0x80|((code&0xFC0)>>>6);
46
-
byteArray[2]=0x80|(code&0x3F);
47
-
}elseif(code>0x80){
48
-
byteArray[0]=0xC0|((code&0x7C0)>>>6);
49
-
byteArray[1]=0x80|(code&0x3F);
50
-
}else{
38
+
if(binary){
51
39
byteArray[0]=code;
40
+
}else{
41
+
if(code>0x10000){
42
+
byteArray[0]=0xF0|((code&0x1C0000)>>>18);
43
+
byteArray[1]=0x80|((code&0x3F000)>>>12);
44
+
byteArray[2]=0x80|((code&0xFC0)>>>6);
45
+
byteArray[3]=0x80|(code&0x3F);
46
+
}elseif(code>0x800){
47
+
byteArray[0]=0xE0|((code&0xF000)>>>12);
48
+
byteArray[1]=0x80|((code&0xFC0)>>>6);
49
+
byteArray[2]=0x80|(code&0x3F);
50
+
}elseif(code>0x80){
51
+
byteArray[0]=0xC0|((code&0x7C0)>>>6);
52
+
byteArray[1]=0x80|(code&0x3F);
53
+
}else{
54
+
byteArray[0]=code;
55
+
}
52
56
}
53
57
54
58
this.parsedData.push(byteArray);
@@ -84,8 +88,8 @@ function QRCodeModel(typeNumber, errorCorrectLevel) {
84
88
}
85
89
86
90
QRCodeModel.prototype={
87
-
addData: function(data){
88
-
varnewData=newQR8bitByte(data);
91
+
addData: function(data,binary){
92
+
varnewData=newQR8bitByte(data,binary);
89
93
this.dataList.push(newData);
90
94
this.dataCache=null;
91
95
},
@@ -1046,7 +1050,7 @@ function _getTypeNumber(sText, _htOption) {
quality: 0.75,// An object specifying the quality (0 to 1). default is 0.75. (JPGs only)
1504
1508
1505
1509
// ==== Versions
1506
-
version: 0// The symbol versions of QR Code range from Version 1 to Version 40. default 0 means automatically choose the closest version based on the text length.
1510
+
version: 0,// The symbol versions of QR Code range from Version 1 to Version 40. default 0 means automatically choose the closest version based on the text length.
1511
+
1512
+
// ==== binary(hex) data mode
1513
+
binary: false// Whether it is binary mode, default is text mode.
0 commit comments