Initial Commit

This commit is contained in:
Merricx 2017-04-13 15:56:27 +07:00
commit 4eb1f981b2
71 changed files with 9638 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
ref/
TODO

734
css/style.css Normal file
View file

@ -0,0 +1,734 @@
body {
color: #FFFFFF;
background-color: #eceff1;
padding: 0;
margin: 0;
overflow: auto !important;
}
/* ----- FONT ----- */
@font-face {
font-family: 'Droid Sans';
src: url('../font/DroidSans.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Droid Sans';
src: url('../font/DroidSans-Bold.ttf') format('truetype');
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: 'Fredoka One';
src: url('../font/FredokaOne-Regular.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
* { font-family: "Droid Sans";}
h1 {font-size: 48px; margin: 5px;}
h2 {font-size: 32px; margin: 5px;}
h3 {font-size: 24px; margin: 5px;}
h4 {font-size: 20px; margin: 5px;}
h5 {font-size: 16px; margin: 5px;}
h6 {font-size: 12px; margin: 5px;}
p {font-size: 14px; margin: 5px;}
p.alert {font-size: 12px; color: red; margin: 0}
li {font-size: 16px; font-weight:bold;}
a {text-decoration: none; color: inherit;}
p a {color: #4D90FE;}
p a:hover {text-decoration: underline;}
h1.bold,h2.bold,h3.bold,h4.bold,h5.bold,h6.bold,p.bold {font-weight: bold;}
h1.light,h2.light,h3.light,h4.light,h5.light,h6.light,p.light {font-weight: lighter;}
ul {list-style: none;}
.left {float: left;}
.right {float: right;}
.clear {clear: both;}
.clear.left {clear: left;}
.clear.right {clear: right;}
.space {margin-top: 25px;}
.space.small {margin-top: 5px;}
.hide {display: none;}
.invisible {visibility: hidden;}
.separate {border-bottom: solid 2px #434A54;}
.bot {height: 100px;}
.noselect {-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}
.title {font-family: "Fredoka One"; font-size: 72px; color: #03a9f4; border-bottom: solid 3px #03a9f4}
.header {
top: 0;
left: 0;
width: 100%;
height: 40px;
padding: 10px 0 10px 25px;
position: fixed;
overflow: hidden;
background-color: #4fc3f7;
-webkit-box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
z-index: 999;
}
.header .icon {
width: 40px;
height: auto;
float: left;
}
.header h3 {
padding-left: 20px;
font-family: "Fredoka One";
color: #FFFFFF;
float: left;
}
.header .right {
margin-right: 50px;
}
.header h4 {
float: left;
margin: 3px;
padding: 5px 25px;
}
.header a:hover > h4 {
border: solid thin 0px;
border-radius: 5px;
background: #03a9f4;
}
.side-box {
margin: 20px;
background: #4fc3f7;
border-radius: 5px;
min-width: 200px;
padding: 20px;
-webkit-box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
z-index: 999;
}
.side-box.right {
left: auto;
width: 250px;
}
.side-box input[type=text] {
padding: 5px;
width: 120px;
font-size: 16px;
background: #ffffff;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
border: 0;
border-color: #b3e5fc;
float: left;
}
.side-box button {
padding: 5px 15px;
border-radius: 3px;
border: 0;
background: #FFFFFF;
color: #000000;
font-size: 16px;
cursor: pointer;
}
.side-box button.toggle.active {
background-color: #455a64;
color: #fff;
}
.side-box .toolbox {
background-color: #fff;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
float: left;
}
.side-box .toolbox div {
float: left;
cursor: pointer;
}
.side-box .toolbox div:hover {
background-color: #e0e0e0;
}
.side-box .toolbox img {
width: 29px;
height: auto;
}
.side-box .painter-box {
margin-right: 10px;
padding: 0;
background-color: #fff;
border-radius: 3px;
overflow: auto;
float: left;
}
.side-box .painter-box div {
float: left;
padding: 5px 10px;
cursor: pointer;
}
.side-box .painter-box div:hover {
background-color: #e0e0e0;
}
.side-box .painter-box div.active {
background-color: #455a64;
}
.side-box .painter-box div.active img {
filter: invert(1);
}
.side-box .painter-box img {
width: 24px;
height: auto;
}
.side-box .sample-box {
border: solid thin #fafafa;
background-color: #fff;
width: 100%;
min-height: 200px;
overflow: hidden;
}
.side-box .sample-box img {
width: 100%;
height: auto;
display: none;
}
.side-box label.sample-btn {
padding: 5px 10px;
font-size: 16px;
color: #000;
background-color: #fff;
border-radius: 3px;
cursor: pointer;
}
.left-box {
position: fixed;
top: 0;
left: 0;
width: 280px;
height: 100%;
overflow-y: scroll;
z-index: 10;
background-color: #eceff1;
}
.right-box {
position: fixed;
top: 0;
right: 0;
width: 340px;
height: 100%;
overflow-y: scroll;
z-index: 10;
background-color: #eceff1;
}
.main {
display: table;
margin: 100px auto 40px auto;
}
.side-box button:hover {
background: #eceff1;
}
.qr-box {
padding: 0 350px;
position: relative;
}
.qr-tab {
border-collapse: collapse;
}
.qr-tab tr td {
border: solid 1px #434A54;
min-width: 15px; width: 15px;
min-height: 15px; height: 15px;
cursor: pointer;
background: #bdbdbd;
}
.qr-tab tr td.static, .qr-tab tr td.static.white {
background: #ff5252;
cursor: default;
}
.qr-tab tr td.black {
background: #000000;
}
.qr-tab tr td.white {
background: #ffffff;
}
.qr-tab tr td.yellow {
background-color: #ffc400;
opacity: 0.6;
}
.qr-tab tr td.static.black {
background: #b71c1c;
cursor: default;
}
.qr-tab tr td.info {
background: #8c9eff;
}
.qr-tab tr td.info.black {
background: #1a237e;
}
.qr-tab tr td.blue {
background: #8c9eff;
}
.qr-tab tr td.blue.black {
background: #1a237e;
}
.qr-tab tr td.green.white {
background-color: #81c784;
}
.qr-tab tr td.green.black {
background-color: #1b5e20;
}
#qr-mask-table {
pointer-events: none;
position: absolute;
top: 0;
}
#qr-mask-table tr td {
background: #00c853;
opacity: .5;
}
.overlay {
top: 0;
left: 0;
width: 100%;
height: 100%;
position: fixed;
z-index: 999999;
background-color: rgba(0,0,0,0.5);
overflow-y: auto;
}
.overlay .box {
margin-top: 70px;
margin-bottom: 20px;
padding: 20px;
max-width: 600px;
min-height: 100px;
background-color: #fff;
border-radius: 5px;
color: #000;
}
.overlay .box.large {
margin-top: 40px;
max-width: 800px;
}
.overlay .box.large .preview-box {
padding: 10px;
border: solid thin #9e9e9e;
border-radius: 3px;
width: 400px;
height: 400px;
overflow: auto;
margin-right: 20px;
pointer-events: none;
}
.overlay .box h3 {
padding-bottom: 10px;
margin: 5px;
border-bottom: solid 2px #000;
}
.overlay .box button {
margin: 5px;
padding: 3px 15px;
border-radius: 3px;
border: 0;
background: #4fc3f7;
color: #ffffff;
font-size: 20px;
cursor: pointer;
}
.overlay .box h5 {
margin-bottom: 10px;
text-align: left;
}
.overlay .box .slider {
border-radius: 3px;
border: solid thin #434A54;
overflow: auto;
float: left;
}
.overlay .box .slider div {
border: solid thin #434A54;
width: 20px;
height: 20px;
float: left;
padding: 3px;
cursor: pointer;
}
.overlay .box .slider div:hover {
background-color: #bdbdbd;
}
.overlay .box .slider div.active {
background-color: #039be5;
color: #fff;
}
.overlay .box button.big {
width: 350px;
font-size: 24px;
border-radius: 5px;
color: #fff;
}
.overlay .box button.big:hover {
background-color: #03a9f4;
}
.overlay .box button.small {
font-size: 18px;
}
.overlay .box button.big.yellow {
background-color: #ffc107;
color: #000;
}
.overlay .box button.big.yellow:hover {
background-color: #ffa000;
}
.overlay .box button.big.green {
background-color: #4caf50;
color: #000;
}
.overlay .box button.big.green:hover {
background-color: #388e3c;
}
.overlay .box input[type=text] {
margin: 5px;
padding: 5px;
float: left;
width: 400px;
background-color: #fff;
border-radius: 3px;
font-size: 16px;
border: solid thin #9e9e9e;
}
.overlay .box label.big {
margin-top: 10px;
padding: 3px 70px;
font-size: 24px;
background: #4fc3f7;
border-radius: 5px;
color: #fff;
cursor: pointer;
}
.overlay .box label.big:hover {
background-color: #03a9f4;
}
.overlay .box input[type=text].small {
width: 150px;
}
.overlay .box .project-list {
text-align: left;
margin: 5px;
overflow: auto;
max-height: 230px;
}
.overlay .box .project-list#list-tools {
max-height: none;
}
.overlay .box .project-list div {
margin: 0;
padding: 7px;
width: 90%;
border: solid 2px #03a9f4;
border-radius: 5px;
cursor: pointer;
position: relative;
}
.overlay .box .project-list div:hover {
background-color: #e1f5fe;
}
.overlay .box .project-list div.active {
background-color: #b3e5fc;
}
.overlay .box .project-list div h5 {
margin: 0;
margin-bottom: 5px;
}
.overlay .box .project-list div h6 {
margin: 0;
font-weight: normal;;
}
.overlay .box .project-list div span {
position: absolute;
top: 15px;
right: 10px;
font-size: 18px;
font-weight: bold;
}
.overlay .box .project-list div span:hover {
color: #f44336;
}
.div-extract {
width: 800px;
margin-left: 20px;
text-align: left;
color: #000;
overflow: auto;
border: solid 2px #03a9f4;
}
.div-extract h5 {
font-weight: normal;
}
.div-extract h5 span {
font-weight: bold;
}
.paging {
}
.paging button {
float: left;
font-weight: bold;
}
.paging h5 {
float: left;
margin: 10px;
}
textarea {
margin: 5px;
padding: 5px;
width: 100%;
background-color: #fff;
border: solid thin #9e9e9e;
border-radius: 3px;
resize: none;
}
.history {
overflow-y: auto;
max-height: 150px;
border-radius: 3px;
}
.history div {
margin: 0;
width: 95%;
border: solid thin #9e9e9e;
height: 30px;
background-color: #e0e0e0;
cursor: pointer;
}
.history div.active, .history div:hover {
background-color: #fff;
}
.history div * {
margin:0 ;
padding: 8px 5px;
color: #000;
}
.search {
margin: 5px;
padding: 5px 8px;
border: solid thin #e0e0e0;
border-radius: 5px;
width: 250px;
overflow: hidden;
background-color: #fff;
}
.search img {
margin-top: 2px;
float: right;
width: 18px;
height: auto;
}
.search input {
border: none;
background-color: #fff;
font-size: 16px;
width: 90%;
}
.select {
margin: 5px;
font-size: 16px;
}
.help-menu {
margin-bottom: 25px;
color: #03a9f4;
list-style: circle;
}
.help-menu .help-menu {
padding-left: 25px;
}
.help-menu a:hover li {
text-decoration: underline;
}
.help-menu a li {
margin: 10px 0;
font-weight: normal;
}
.help-menu a.selected li {
font-weight: bold;
}
.help {
margin: 100px 40px 40px 300px;
background-color: #fff;
color: #000;
border-bottom: solid thin #4fc3f7;
}
.help .breadcrumbs {
margin: 10px 0 15px 0;
padding: 0 5px 10px 5px;
border-bottom: solid thin #81d4fa;
}
.help .breadcrumbs span {
margin: 0 10px;
font-size: 16px;
}
.help .breadcrumbs a {
color: #4fc3f7;
}
.help .help-index p:before {
margin-left: 10px;
content: '-';
font-weight: bold;
}
.help .help-index p a {
margin-left: 20px;
font-size: 16px;
}
.help .nav {
margin: 5px 10px;
}
.help .nav button {
padding: 5px 15px;
border-radius: 3px;
border: 0;
background: #4fc3f7;
color: #fff;
font-size: 16px;
cursor: pointer;
font-weight: bold;
}
.help .nav button:hover {
opacity: .8;
}
.help .nav button.left:before {
margin-right: 8px;
content: '«';
font-size: 18px;
}
.help .nav button.right:after {
margin-left: 8px;
content: '»';
font-size: 18px;
}
.help ul li {
list-style: disc;
font-weight: normal;
}
.help ul li a {
color: #4fc3f7;
}
.help table {
border-collapse: collapse;
}
.help table tr td, .help table tr th {
border: solid thin #000;
padding: 5px;
}

BIN
font/DroidSans-Bold.ttf Normal file

Binary file not shown.

BIN
font/DroidSans.ttf Normal file

Binary file not shown.

BIN
font/FredokaOne-Regular.ttf Normal file

Binary file not shown.

202
font/LICENSE.txt Normal file
View file

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -0,0 +1,52 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="../../css/style.css">
<link rel="icon" href="../../img/icon.png">
<title>QRazyBox - Help Page</title>
</head>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/script.js"></script>
<body style="background:white;">
<div class="header noselect">
<div class="left">
<img src="../../img/icon.png" class="icon">
<h3>QRazyBox Help</h3>
</div>
<div class="right">
<div class="search">
<img src="../../img/search.png">
<input type="text" placeholder="Search here...">
</div>
</div>
</div>
<div class="left-box" style="overflow-x:auto;">
<div style="height:80px;"></div>
<div id="help-menu">
</div>
</div>
<div class="help">
<div class="breadcrumbs noselect">
<h6><a href="../index.html">Help</a> <span>&rsaquo;</span> Editor &amp; Painter</h6>
</div>
<h2>Editor &amp; Painter</h2>
<br>
<div class="space"></div>
<div class="nav">
<button class="left" onclick="window.location='../getting-started/drawing-and-decoding-qr-code.html';">Prev : Drawing and Decoding QR code</button>
<button class="right" onclick="window.location='painter-basic-usage.html';">Next : Painter Basic Usage</button>
</div>
<div class="clear"></div>
<div class="space"></div>
</div>
</body>
</html>

View file

@ -0,0 +1,140 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="../../css/style.css">
<link rel="icon" href="../../img/icon.png">
<title>QRazyBox - Help Page</title>
</head>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/script.js"></script>
<body style="background:white;">
<div class="header noselect">
<div class="left">
<img src="../../img/icon.png" class="icon">
<h3>QRazyBox Help</h3>
</div>
<div class="right">
<div class="search">
<img src="../../img/search.png">
<input type="text" placeholder="Search here...">
</div>
</div>
</div>
<div class="left-box" style="overflow-x:auto;">
<div style="height:80px;"></div>
<div id="help-menu">
</div>
</div>
<div class="help">
<div class="breadcrumbs noselect">
<h6><a href="../index.html">Help</a> <span>&rsaquo;</span> <a href="index.html">Getting Started</a> <span>&rsaquo;</span> About QR Code</h6>
</div>
<h2>About QR Code</h2>
<br>
<p><b>QR code</b> (abbreviated from <b>Quick Response Code</b>) is the trademark for a type of matrix barcode (or two-dimensional barcode) first designed for the automotive industry in Japan. A QR code uses four standardized encoding modes (numeric, alphanumeric, byte/binary, and kanji) to efficiently store data. <i>(Wikipedia)</i></p>
<p>The QR code format was created in 1994 by Japanese company Denso-Wave, which is a subsidiary of Toyota that manufactures auto components. The standard is defined in ISO/IEC 18004:2006. The use of QR codes is license-free. <i>(thonky.org)</i></p>
<p>Keep in mind, that in this section, we'll only discuss a summary about QR Code standards. If you want to learn QR Code in detail, you can visit a page that I recommend you before in previous section.</p>
<br>
<h4>QR Code Versions</h4>
<br>
<center><img src="../img/versionVarietyImage.png"></center>
<br>
<p>The size of QR Code is called <b>version</b>. Version of QR Code range from <b>version 1 (21x21 pixels)</b> up to <b>version 40 (177x177 pixels)</b>. These versions is defined by how much data that stored in the QR Code. So, the larger the data stored, the larger the version will be.</p>
<p><i>*Pixel in QR Code is often also called <b>Module</b>.</i></p>
<br>
<h4>Error Correction</h4>
<p>QR Code also has error correction feature, that will automatically restore the data if some of them are damaged or unreadable. This error correction scheme use <i>Reed-Solomon Error Correction</i> algorithm that consists of 4 correction levels: <b>Low (L)</b>, <b>Medium (M)</b>, <b>Quartile (Q)</b>, and <b>High (H)</b>, where each of the level has its own capability of how much the data can be restored.</p>
<br>
<center><table>
<tr>
<th>Error-Correction Level</th>
<th>% of data that can be restored</th>
</tr>
<tr>
<td>Level L</td>
<td>&plusmn; 7%</td>
</tr>
<tr>
<td>Level M</td>
<td>&plusmn; 15%</td>
</tr>
<tr>
<td>Level Q</td>
<td>&plusmn; 25%</td>
</tr>
<tr>
<td>Level H</td>
<td>&plusmn; 30%</td>
</tr>
</table>
<p><i>(The table above show the capabilty of each Error-Correction level)</i></p>
</center>
<br>
<h4>Structure of QR Code</h4>
<p>QR Code always consist of three things, <b>Function pattern</b>, <b>Format &amp; Version Information Pattern</b>, and <b>Data Bits</b>.<br>Function Pattern is a non-data element of the QR Code that is required by the QR Code specification.<br>Format &amp; Version Information Pattern are pattern that describe current specification that being used by QR Code such as Version, Error correction level, and Mask Pattern. And Data Bits itself is an actual data that encoded in the QR Code.<br>
Function pattern often also called <i>Fixed Pattern</i> because their form never changed, but only their position that will change depending on the QR Code version.</p>
<center>
<img src="../img/QRCode-2-Structure.png" style="width:800px;height:auto;">
<p><i>(The image above explains about QR Code structure)</i></p>
</center>
<br>
<h4>Format and Version Information</h4>
<p>As explained in previous part, Format and Version Information are patterns in QR Code that tell about current specification that being used by QR code. Format information is always exist in every version of QR code, but Version information only exist in version 7 or above.<br><br>
Format information consist of 15 bits data that store information about error correction and mask pattern that being used by QR code.<br>Thereafter, Version information consist of 18 bits data that store information about QR code version.<br>Because until now, QRazyBox only support up to version 6 QR code, so we will ignore about version information for now.</p>
<br>
<center>
<img src="../img/576px-QR_Format_Information.svg.png">
<p><i>(The image above explain about how Format information store error correction level and mask pattern)</i></p>
</center>
<br>
<p>The placement of these pattern are shared into 3 places (for Format info) and 2 places (for Version info). Those placement can be see in the image in the previous part that explains QR code structure.</p>
<p>We will discuss about Mask Pattern in the last part of this section.</p>
<br>
<h4>Data Bits Layout</h4>
<p>Data bits is sequence of modules that contained blocks of encoded message and blocks of reed-solomon that will be used as error corrector later. The encoded message itself, is arranged from: <b>Mode Indicator</b>, <b>Character Count Indicator</b>, and <b>main message itself</b>.</p>
<p>Mode indicator is encoding mode codeword (4 bits) that being used to encode the message to binary form. As explained before that QR code has 4 modes for encodes text: <b>Numeric</b>, <b>Alphanumeric</b>, <b>Byte</b>, and <b>Kanji</b>.<br>Character count indicator is a number that tell the length of message.</p>
<p>It is possible to use multiple modes in a single QR code by including the mode indicator before each section of bytes that uses that mode.</p>
<br>
<p>Data bits are placed in QR code from right to left in a zigzag pattern and form a snake flow.<br>The order is : <b>Mode Indicator &rArr; Character Count Indicator &rArr; Main message &rArr; Error correction (reed-solomon block)</b></p>
<center>
<img src="../img/QR_Character_Placement.png">
<p><i>(Example of data bits placement process, encoding text "www.wikipedia.org")</i></p>
</center>
<br>
<p>But, pay attention that for larger QR code, data blocks must be interleaved and broken into smaller blocks according to the version and error correction level that being used. The Image below explain process of placing interleaved data blocks.</p>
<center>
<img src="../img/QR_Ver3_Codeword_Ordering.png" style="width:70%;height:auto;">
</center>
<br>
<h4>Mask Pattern</h4>
<p>Before QR code is finally generated, the data bits must be <b>XOR</b>-ed with mask pattern. There are 8 mask pattern that available in QR code, namely mask pattern 0 to 7 (or 000 to 111 in binary). This process have a purpose of making QR code more readable by QR scanner.</p>
<center>
<img src="../img/40310477-qr-mask.png">
<p><i>(Eight mask patterns)</i></p>
<img src="../img/mask_process.png">
<p><i>(The process of data masking)</i></p>
</center>
<br>
<h4>References :</h4>
<p><a href="https://en.wikipedia.org/wiki/QR_code">https://en.wikipedia.org/wiki/QR_code</a></p>
<p><a href="http://www.thonky.com/qr-code-tutorial/">http://www.thonky.com/qr-code-tutorial</a></p>
<p><a href="http://www.qrcode.com/">http://www.qrcode.com</a></p>
<div class="space"></div>
<div class="nav">
<button class="left" onclick="window.location='index.html';">Prev : Getting Started</button>
<button class="right" onclick="window.location='interface-overview.html';">Next : Interface Overview</button>
</div>
<div class="clear"></div>
<div class="space"></div>
</div>
</body>
</html>

View file

@ -0,0 +1,72 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="../../css/style.css">
<link rel="icon" href="../../img/icon.png">
<title>QRazyBox - Help Page</title>
</head>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/script.js"></script>
<body style="background:white;">
<div class="header noselect">
<div class="left">
<img src="../../img/icon.png" class="icon">
<h3>QRazyBox Help</h3>
</div>
<div class="right">
<div class="search">
<img src="../../img/search.png">
<input type="text" placeholder="Search here...">
</div>
</div>
</div>
<div class="left-box" style="overflow-x:auto;">
<div style="height:80px;"></div>
<div id="help-menu">
</div>
</div>
<div class="help">
<div class="breadcrumbs noselect">
<h6><a href="../index.html">Help</a> <span>&rsaquo;</span> <a href="index.html">Getting Started</a> <span>&rsaquo;</span> Create, Save, and Load Project</h6>
</div>
<h2>Create, Save, and Load Project</h2>
<br>
<p>Create, save, and load project can be done through main menu in the header.</p>
<br>
<h4>Create New Project</h4>
<p>There are two ways to create new project. First, quickly create a blank QR code with template that ready to use. Therefore, you don't need to draw the Function pattern. The second is, you can import it from image file and QRazyBox will try to convert it to bitmatrix array.</p>
<br>
<center>
<img src="../img/new_project.png">
</center>
<br>
<p>But, keep in mind that when you importing new project from image file, there are conditions that should be met besides that the image must contains valid QR code. Those conditions are, the loaded image must contain <b>three Finder patterns</b> and <b>Alignment pattern</b> according to the QR version. When you fail in importing an image, unfortunately you should reconstruct manually.</p>
<center>
<img src="../img/import_image_diff.png">
</center>
<br>
<p>Last, when you importing an image, QRazyBox only accept black and white colors, other than those colors will be transformed to black or white depending on its grayscale value, so you should change it manually when you want to mark it as damaged part of QR code.<br>
</p>
<br>
<h4>Save and Load Project</h4>
<p>QRazyBox use <b>HTML5 Local Storage</b> to store all of your project data. Therefore, if you change to the different new browser, you can't use your saved project from the previous browser.<br>Be careful when you save a project with name that already exist, since it will overwrite the older project.</p>
<p>You can delete your saved project by clicking cross mark (<b>x</b>) in the save or load dialog menu.</p>
<div class="space"></div>
<div class="nav">
<button class="left" onclick="window.location='interface-overview.html';">Prev : Interface Overview</button>
<button class="right" onclick="window.location='drawing-and-decoding-qr-code.html';">Next : Drawing and Decoding QR Code</button>
</div>
<div class="clear"></div>
<div class="space"></div>
</div>
</body>
</html>

View file

@ -0,0 +1,85 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="../../css/style.css">
<link rel="icon" href="../../img/icon.png">
<title>QRazyBox - Help Page</title>
</head>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/script.js"></script>
<body style="background:white;">
<div class="header noselect">
<div class="left">
<img src="../../img/icon.png" class="icon">
<h3>QRazyBox Help</h3>
</div>
<div class="right">
<div class="search">
<img src="../../img/search.png">
<input type="text" placeholder="Search here...">
</div>
</div>
</div>
<div class="left-box" style="overflow-x:auto;">
<div style="height:80px;"></div>
<div id="help-menu">
</div>
</div>
<div class="help">
<div class="breadcrumbs noselect">
<h6><a href="../index.html">Help</a> <span>&rsaquo;</span> <a href="index.html">Getting Started</a> <span>&rsaquo;</span> Drawing and Decoding QR Code</h6>
</div>
<h2>Drawing and Decoding QR Code</h2>
<br>
<p>There are two main working modes in QRazyBox : <b>Editor mode</b> and <b>Decode mode</b>.</p>
<p>To switch working mode, you can use <b>Mode Indicator</b> as explained before in the <a href="interface-overview.html">previous section</a>.</p>
<br>
<h4>Editor Mode</h4>
<p>Editor mode is working mode where you can create, draw, and edit the QR code using painter and other tools.<br>This image below is the main toolbox of Editor Mode that lets you draw QR code and maintain it.<br>
</p>
<br>
<center><img src="../img/editor-toolbox.png"></center>
<p><b>1. Painter</b> : Collection of painter tools that used to draw QR code.</p>
<p><b>2. QR Code version</b> : Change current version of your QR code. Remember that, change version of QR code will cause your work start from beginning, therefore, don't forget to set this before you start to reconstructing the QR code.</p>
<p><b>3. Module size</b> : Change size of each module of the QR code. Use it to zoom in/out your QR code.</p>
<br>
<p>You can draw QR code by clicking the square in the QR canvas which has been provided. Each square represents one module/pixel in QR code with its respective colors. Each color representation can be seen in the following image.</p>
<center>
<img src="../img/qr-canvas.png">
</center>
<br>
<p>Red color modules are fixed pattern. Therefore, they can't be edited.<br>Blue color modules can be edited by clicking the blue area and you will be prompted with a dialog to set Format Information pattern there. Also, by editing only one part of format information, the other parts will change themselves automatically.</p>
<br>
<p>Further details about Painter and drawing QR code will be explained in the <a href="../editor-painter/index.html">next section</a>.</p>
<br>
<h4>Decode Mode</h4>
<p>Decode mode is working mode that used to displays final result of your QR code where you can decode it or export it as image.<br>The image below is the toolbox when Decode mode is active.</p>
<center>
<img src="../img/decode-toolbox.png">
</center>
<br>
<p><b>1. Module Size</b> : Change size of each module of the QR code. Use it to zoom in/out your QR code.</p>
<p><b>2. Grey Modules</b> : Option whether you want to show the grey modules or to show them in white color (this doesn't change the main data of the QR code).</p>
<p><b>3. QR Decoder</b> : Decode your final QR code and read the message.</p>
<br>
<p>When you decode QR code, you will be prompted a dialog and the decoded message will be shown there. If the dialog show blank message, it means that the QR decoder cannot decode it.</p>
<p>You can also save your final result as an image file. Simply right click in the QR code and select <b>Save Image as..</b> (when using <i>Firefox</i> or <i>Chrome</i>).</p>
<div class="space"></div>
<div class="nav">
<button class="left" onclick="window.location='create-save-load-project.html';">Prev : Create, Save, and Load Project</button>
<button class="right" onclick="window.location='../editor-painter/index.html';">Next : Editor &amp; Painter</button>
</div>
<div class="clear"></div>
<div class="space"></div>
</div>
</body>
</html>

View file

@ -0,0 +1,61 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="../../css/style.css">
<link rel="icon" href="../../img/icon.png">
<title>QRazyBox - Help Page</title>
</head>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/script.js"></script>
<body style="background:white;">
<div class="header noselect">
<div class="left">
<img src="../../img/icon.png" class="icon">
<h3>QRazyBox Help</h3>
</div>
<div class="right">
<div class="search">
<img src="../../img/search.png">
<input type="text" placeholder="Search here...">
</div>
</div>
</div>
<div class="left-box" style="overflow-x:auto;">
<div style="height:80px;"></div>
<div id="help-menu">
</div>
</div>
<div class="help">
<div class="breadcrumbs noselect">
<h6><a href="../index.html">Help</a> <span>&rsaquo;</span> Getting Started</h6>
</div>
<h2>Getting Started</h2>
<br>
<p>Before start using QRazyBox, I assumes that you already have basic knowledge about QR Code such as data encoding, the structure, and error correction. If not, I recommend to read a wonderful tutorial from <a href="http://www.thonky.com/qr-code-tutorial/" target="blank">thonky.org</a> that'll covers how to generating QR Code step by step. Though, in the next section, we will discuss a little bit about QR Code as a summary and you just can skip it if you want.</p>
<br>
<h5>Jump to :</h5>
<ul>
<li><a href="getting-started/about-qr-code.html">About QR Code</a></li>
<li><a href="getting-started/interface-overview.html">Interface Overview</a></li>
<li><a href="getting-started/create-save-load-project.html">Create, Save, and Load Project</a></li>
<li><a href="getting-started/drawing-and-decoding-qr-code.html">Drawing and Decoding QR Code</a></li>
</ul>
<div class="space"></div>
<div class="nav">
<button class="left" onclick="window.location='../introduction/index.html';">Prev : Introduction</button>
<button class="right" onclick="window.location='about-qr-code.html';">Next : About QR Code</button>
</div>
<div class="clear"></div>
<div class="space"></div>
</div>
</body>
</html>

View file

@ -0,0 +1,62 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="../../css/style.css">
<link rel="icon" href="../../img/icon.png">
<title>QRazyBox - Help Page</title>
</head>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/script.js"></script>
<body style="background:white;">
<div class="header noselect">
<div class="left">
<img src="../../img/icon.png" class="icon">
<h3>QRazyBox Help</h3>
</div>
<div class="right">
<div class="search">
<img src="../../img/search.png">
<input type="text" placeholder="Search here...">
</div>
</div>
</div>
<div class="left-box" style="overflow-x:auto;">
<div style="height:80px;"></div>
<div id="help-menu">
</div>
</div>
<div class="help">
<div class="breadcrumbs noselect">
<h6><a href="../index.html">Help</a> <span>&rsaquo;</span> <a href="index.html">Getting Started</a> <span>&rsaquo;</span> Interface Overview</h6>
</div>
<h2>Interface Overview</h2>
<br>
<center>
<img src="../img/editor-interface.png" style="width:75%;height:auto;">
</center>
<br>
<p><b>1. Menu</b> : Main menu where you can create new project, save/load project, use sub-tools, etc..</p>
<p><b>2. Mode indicator</b> : The button that lets you switch main workspace mode from Editor mode to Decode mode or otherwise.</p>
<p><b>3. Main Toolbox</b> : Toolbox that does the core commands (such as draw, erase QR code, or decode QR code) and maintain your workspace. This toolbox will change according to the current workspace mode that being used.</p>
<p><b>4. Sample toolbox</b> : Toolbox that store your image sample as a replication, to ease in reconstructing QR code.</p>
<p><b>5. History toolbox</b> : Toolbox that store your drawing history of current QR code, lets you to undo or redo your work.</p>
<p><b>6. Workspace</b> : Your main canvas to drawing and reconstructing QR code.</p>
<div class="space"></div>
<div class="nav">
<button class="left" onclick="window.location='about-qr-code.html';">Prev : About QR Code</button>
<button class="right" onclick="window.location='create-save-load-project.html';">Next : Create, Save, and Load Project</button>
</div>
<div class="clear"></div>
<div class="space"></div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
help/img/decode-toolbox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
help/img/decoder-dialog.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
help/img/editor-toolbox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
help/img/mask_process.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
help/img/new_project.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
help/img/qr-canvas.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
help/img/qr-canvas.xcf Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

113
help/index.html Normal file
View file

@ -0,0 +1,113 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="../css/style.css">
<link rel="icon" href="../img/icon.png">
<title>QRazyBox - Help Page</title>
</head>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<body style="background:white;">
<div class="header noselect">
<div class="left">
<img src="../img/icon.png" class="icon">
<h3>QRazyBox Help</h3>
</div>
<div class="right">
<div class="search">
<img src="../img/search.png">
<input type="text" placeholder="Search here...">
</div>
</div>
</div>
<div class="left-box" style="overflow-x:auto;">
<div style="height:80px;"></div>
<div id="help-menu">
<ul class="help-menu">
<a href="introduction/index.html"><li>Introduction</li></a>
<a href="getting-started/index.html"><li>Getting Started</li></a>
<ul class="help-menu hide">
<a href="getting-started/about-qr-code.html"><li>About QR Code</li></a>
<a href="getting-started/interface-overview.html"><li>Interface Overview</li></a>
<a href="getting-started/create-save-load-project.html"><li>Create, Save, and Load Project</li></a>
<a href="getting-started/drawing-and-decoding-qr-code.html"><li>Drawing and Decoding QR Code</li></a>
</ul>
<a href="editor-painter/index.html"><li>Editor &amp; Painter</li></a>
<ul class="help-menu hide">
<a href="editor-painter/painter-basic-usage.html"><li>Painter Basic Usage</li></a>
<a href="editor-painter/format-info-pattern.html"><li>Format Info Pattern</li></a>
<a href="editor-painter/undo-redo-using-history.html"><li>Undo/Redo using History</li></a>
</ul>
<a href="extension-tools/index.html"><li>Extension Tools</li></a>
<ul class="help-menu hide">
<a href="extension-tools/extract-qr-information.html"><li>Extract QR Information</li></a>
<a href="extension-tools/reed-solomon-decoder.html"><li>Reed-Solomon Decoder</li></a>
<a href="extension-tools/brute-force-format-info-pattern.html"><li>Brute-force Format Info Pattern</li></a>
<a href="extension-tools/data-unmasking.html"><li>Data Unmasking</li></a>
<a href="extension-tools/padding-bits-recovery.html"><li>Padding Bits Recovery</li></a>
</ul>
<a href="examples/index.html"><li>Examples</li></a>
<ul class="help-menu hide">
<a href="examples/basic.html"><li>Basic Example</li></a>
<a href="examples/advanced.html"><li>Advanced Example</li></a>
</ul>
<a href="misc/index.html"><li>Miscellaneous</li></a>
<ul class="help-menu hide">
<a href="misc/qr-code-samples.html"><li>QR Code samples</li></a>
<a href="misc/download.html"><li>Download for Offline Use</li></a>
<a href="misc/license.html"><li>Third-Party &amp; License</li></a>
</ul>
</ul>
</div>
</div>
<div class="help">
<h2>QRazyBox User Guide</h2>
<br><br>
<h4><a href="introduction/index.html">Introduction</a></h4>
<div class="help-index">
<p><a href="introduction/index.html">Introduction of QRazyBox</a></p>
<br>
<h4><a href="getting-started/index.html">Getting Started</a></h4>
<p><a href="getting-started/about-qr-code.html">About QR Code</a></p>
<p><a href="getting-started/interface-overview.html">Interface Overview</a></p>
<p><a href="getting-started/create-save-load-project.html">Create, Save, and Load Project</a></p>
<p><a href="getting-started/drawing-and-decoding-qr-code.html">Drawing and Decoding QR Code</a></p>
<br>
<h4><a href="editor-painter/index.html">Editor &amp; Painter</a></h4>
<p><a href="editor-painter/painter-basic-usage.html">Painter Basic Usage</a></p>
<p><a href="editor-painter/format-info-pattern.html">Format Info Pattern</a></p>
<p><a href="editor-painter/undo-redo-using-history.html">Undo/Redo using History</a></p>
<br>
<h4><a href="extension-tools/index.html">Extension Tools</a></h4>
<p><a href="extension-tools/extract-qr-information.html">Extract QR Information</a></p>
<p><a href="extension-tools/reed-solomon-decoder.html">Reed-Solomon Decoder</a></p>
<p><a href="extension-tools/brute-force-format-info-pattern.html">Brute-force Format Info Pattern</a></p>
<p><a href="extension-tools/data-unmasking.html">Data Unmasking</a></p>
<p><a href="extension-tools/padding-bits-recovery.html">Padding Bits Recovery</a></p>
<br>
<h4><a href="examples/index.html">Examples</a></h4>
<p><a href="examples/basic.html">Basic Example</a></p>
<p><a href="examples/advanced.html">Advanced Example</a></p>
<br>
<h4><a href="misc/index.html">Miscellaneous</a></h4>
<p><a href="misc/qr-code-samples.html">QR Code samples</a></p>
<p><a href="misc/download.html">Download for Offline Use</a></p>
<p><a href="misc/license.html">Third-Party &amp; License</a></p>
</div>
<br>
<div class="space"></div>
<div class="nav">
<button class="right" onclick="window.location='introduction/index.html';">Next : Introduction</button>
</div>
<div class="clear"></div>
<div class="space"></div>
</div>
</body>
</html>

View file

@ -0,0 +1,67 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="../../css/style.css">
<link rel="icon" href="../../img/icon.png">
<title>QRazyBox - Help Page</title>
</head>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/script.js"></script>
<body style="background:white;">
<div class="header noselect">
<div class="left">
<img src="../../img/icon.png" class="icon">
<h3>QRazyBox Help</h3>
</div>
<div class="right">
<div class="search">
<img src="../../img/search.png">
<input type="text" placeholder="Search here...">
</div>
</div>
</div>
<div class="left-box" style="overflow-x:auto;">
<div style="height:80px;"></div>
<div id="help-menu">
</div>
</div>
<div class="help">
<div class="breadcrumbs noselect">
<h6><a href="../index.html">Help</a> <span>&rsaquo;</span> Introduction</h6>
</div>
<h2>Introduction</h2>
<br>
<p>QRazyBox is a web-based application (a toolkit), that used to analyzing and recovering damaged QR Code.<br>QRazyBox lets you recover QR Code by redrawing and reconstructing it with Paint-like editor. It also provides several sub-tools (known as Extension Tools) to help you analyze and recover faster and more efficient.</p>
<br>
<h4>Main Features</h4>
<ul>
<li><p>Reconstruct QR Code by drawing pixel by pixel</p></li>
<li><p>Decode and read unscannable QR Code</p></li>
<li><p>Save and load existing work for later use</p></li>
<li><p>Import/export QR Code from/to Image file</p></li>
<li><p>Currently support up to QR Code Version 6 (41x41)</p></li>
<li><p>Support both Error and Erasure Correction using universal Reed-Solomon decoder</p></li>
<li><p>Extract valuable information although from badly damaged QR Code</p></li>
<li><p>Simulate data unmasking for manual data analysis</p></li>
<li><p>Lightweight, fast, and easy to use</p></li>
<li><p>Free and open source :)</p></li>
</ul>
<div class="space"></div>
<div class="nav">
<button class="left" onclick="window.location='../index.html';">Prev : Help homepage</button>
<button class="right" onclick="window.location='../getting-started/index.html';">Next : Getting Started</button>
</div>
<div class="clear"></div>
<div class="space"></div>
</div>
</body>
</html>

53
help/js/script.js Normal file
View file

@ -0,0 +1,53 @@
var sidebarMenu =
'<ul class="help-menu">\
<a href="../introduction/index.html"><li>Introduction</li></a>\
<a href="../getting-started/index.html"><li>Getting Started</li></a>\
<ul class="help-menu hide">\
<a href="../getting-started/about-qr-code.html"><li>About QR Code</li></a>\
<a href="../getting-started/interface-overview.html"><li>Interface Overview</li></a>\
<a href="../getting-started/create-save-load-project.html"><li>Create, Save, and Load Project</li></a>\
<a href="../getting-started/drawing-and-decoding-qr-code.html"><li>Drawing and Decoding QR Code</li></a>\
</ul>\
<a href="../editor-painter/index.html"><li>Editor &amp; Painter</li></a>\
<ul class="help-menu hide">\
<a href="../editor-painter/painter-basic-usage.html"><li>Painter Basic Usage</li></a>\
<a href="../editor-painter/format-info-pattern.html"><li>Format Info Pattern</li></a>\
<a href="../editor-painter/undo-redo-using-history.html"><li>Undo/Redo using History</li></a>\
</ul>\
<a href="../extension-tools/index.html"><li>Extension Tools</li></a>\
<ul class="help-menu hide">\
<a href="../extension-tools/extract-qr-information.html"><li>Extract QR Information</li></a>\
<a href="../extension-tools/reed-solomon-decoder.html"><li>Reed-Solomon Decoder</li></a>\
<a href="../extension-tools/brute-force-format-info-pattern.html"><li>Brute-force Format Info Pattern</li></a>\
<a href="../extension-tools/data-unmasking.html"><li>Data Unmasking</li></a>\
<a href="../extension-tools/padding-bits-recovery.html"><li>Padding Bits Recovery</li></a>\
</ul>\
<a href="../examples/index.html"><li>Examples</li></a>\
<ul class="help-menu hide">\
<a href="../examples/basic.html"><li>Basic Example</li></a>\
<a href="../examples/advanced.html"><li>Advanced Example</li></a>\
</ul>\
<a href="../misc/index.html"><li>Miscellaneous</li></a>\
<ul class="help-menu hide">\
<a href="../misc/qr-code-samples.html"><li>QR Code samples</li></a>\
<a href="../misc/download.html"><li>Download for Offline Use</li></a>\
<a href="../misc/license.html"><li>Third-Party &amp; License</li></a>\
</ul>\
</ul>';
$(document).ready(function(){
var url = window.location.pathname;
var dirname = /help\/.+$/.exec(url)[0].substring(5);
console.log(dirname);
if(dirname != "index.html"){
var dirname_reg = new RegExp(dirname,"g");
sidebarMenu = sidebarMenu.replace(dirname_reg, dirname+"\" class=\"selected\"");
console.log(sidebarMenu);
$("#help-menu").html(sidebarMenu);
}
$(".help-menu a.selected").next().show();
$(".help-menu .help-menu a.selected").parent().show();
})

BIN
img/dragging-tool.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
img/eraser-tool.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
img/fill-tool.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
img/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 B

BIN
img/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
img/minus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
img/pixel-black.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
img/pixel-white.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
img/plus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
img/search.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

BIN
img/toggle-tool.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

2223
index.html Normal file

File diff suppressed because it is too large Load diff

32
js/imageparser.js Normal file
View file

@ -0,0 +1,32 @@
function loadFromImage(canvasID){
var canvas_qr = document.getElementById(canvasID);
var context = canvas_qr.getContext('2d');
qrcode.width = canvas_qr.width;
qrcode.height = canvas_qr.height;
qrcode.imagedata = context.getImageData(0, 0, qrcode.width, qrcode.height);
var image = qrcode.grayScaleToBitmap(qrcode.grayscale());
var detector = new Detector(image);
var qRCodeMatrix = detector.detect();
var qrArray = qRCodeMatrix.bits.bits;
var size = qRCodeMatrix.bits.width;
var result = [];
for(var i=0; i < qrArray.length; i++){
var bin = (qrArray[i] >>> 0).toString(2);
while(bin.length < size){
bin = "0"+bin;
}
result[i] = bin.split("").reverse();
}
for(var i=0; i < result.length; i++){
for(var j=0; j < result[i].length; j++){
result[i][j] = parseInt(result[i][j]);
}
}
return result;
}

5
js/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

289
js/jsqrcode/alignpat.js Normal file
View file

@ -0,0 +1,289 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function AlignmentPattern(posX, posY, estimatedModuleSize)
{
this.x=posX;
this.y=posY;
this.count = 1;
this.estimatedModuleSize = estimatedModuleSize;
Object.defineProperties(this, {
'EstimatedModuleSize': {
get: function () {
return this.estimatedModuleSize;
}
},
"Count": {
get: function() {
return this.count;
}
},
"X": {
get: function() {
return Math.floor(this.x);
}
},
"Y": {
get: function() {
return Math.floor(this.y);
}
}
});
this.incrementCount = function()
{
this.count++;
}
this.aboutEquals=function( moduleSize, i, j)
{
if (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize)
{
var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
return moduleSizeDiff <= 1.0 || moduleSizeDiff / this.estimatedModuleSize <= 1.0;
}
return false;
}
}
function AlignmentPatternFinder( image, startX, startY, width, height, moduleSize, resultPointCallback)
{
this.image = image;
this.possibleCenters = new Array();
this.startX = startX;
this.startY = startY;
this.width = width;
this.height = height;
this.moduleSize = moduleSize;
this.crossCheckStateCount = new Array(0,0,0);
this.resultPointCallback = resultPointCallback;
this.centerFromEnd=function(stateCount, end)
{
return (end - stateCount[2]) - stateCount[1] / 2.0;
}
this.foundPatternCross = function(stateCount)
{
var moduleSize = this.moduleSize;
var maxVariance = moduleSize / 2.0;
for (var i = 0; i < 3; i++)
{
if (Math.abs(moduleSize - stateCount[i]) >= maxVariance)
{
return false;
}
}
return true;
}
this.crossCheckVertical=function( startI, centerJ, maxCount, originalStateCountTotal)
{
var image = this.image;
var maxI = qrcode.height;
var stateCount = this.crossCheckStateCount;
stateCount[0] = 0;
stateCount[1] = 0;
stateCount[2] = 0;
// Start counting up from center
var i = startI;
while (i >= 0 && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount)
{
stateCount[1]++;
i--;
}
// If already too many modules in this state or ran off the edge:
if (i < 0 || stateCount[1] > maxCount)
{
return NaN;
}
while (i >= 0 && !image[centerJ + i*qrcode.width] && stateCount[0] <= maxCount)
{
stateCount[0]++;
i--;
}
if (stateCount[0] > maxCount)
{
return NaN;
}
// Now also count down from center
i = startI + 1;
while (i < maxI && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount)
{
stateCount[1]++;
i++;
}
if (i == maxI || stateCount[1] > maxCount)
{
return NaN;
}
while (i < maxI && !image[centerJ + i*qrcode.width] && stateCount[2] <= maxCount)
{
stateCount[2]++;
i++;
}
if (stateCount[2] > maxCount)
{
return NaN;
}
var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal)
{
return NaN;
}
return this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, i):NaN;
}
this.handlePossibleCenter=function( stateCount, i, j)
{
var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
var centerJ = this.centerFromEnd(stateCount, j);
var centerI = this.crossCheckVertical(i, Math.floor (centerJ), 2 * stateCount[1], stateCountTotal);
if (!isNaN(centerI))
{
var estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0;
var max = this.possibleCenters.length;
for (var index = 0; index < max; index++)
{
var center = this.possibleCenters[index];
// Look for about the same center and module size:
if (center.aboutEquals(estimatedModuleSize, centerI, centerJ))
{
return new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
}
}
// Hadn't found this before; save it
var point = new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
this.possibleCenters.push(point);
if (this.resultPointCallback != null)
{
this.resultPointCallback.foundPossibleResultPoint(point);
}
}
return null;
}
this.find = function()
{
var startX = this.startX;
var height = this.height;
var maxJ = startX + width;
var middleI = startY + (height >> 1);
// We are looking for black/white/black modules in 1:1:1 ratio;
// this tracks the number of black/white/black modules seen so far
var stateCount = new Array(0,0,0);
for (var iGen = 0; iGen < height; iGen++)
{
// Search from middle outwards
var i = middleI + ((iGen & 0x01) == 0?((iGen + 1) >> 1):- ((iGen + 1) >> 1));
stateCount[0] = 0;
stateCount[1] = 0;
stateCount[2] = 0;
var j = startX;
// Burn off leading white pixels before anything else; if we start in the middle of
// a white run, it doesn't make sense to count its length, since we don't know if the
// white run continued to the left of the start point
while (j < maxJ && !image[j + qrcode.width* i])
{
j++;
}
var currentState = 0;
while (j < maxJ)
{
if (image[j + i*qrcode.width])
{
// Black pixel
if (currentState == 1)
{
// Counting black pixels
stateCount[currentState]++;
}
else
{
// Counting white pixels
if (currentState == 2)
{
// A winner?
if (this.foundPatternCross(stateCount))
{
// Yes
var confirmed = this.handlePossibleCenter(stateCount, i, j);
if (confirmed != null)
{
return confirmed;
}
}
stateCount[0] = stateCount[2];
stateCount[1] = 1;
stateCount[2] = 0;
currentState = 1;
}
else
{
stateCount[++currentState]++;
}
}
}
else
{
// White pixel
if (currentState == 1)
{
// Counting black pixels
currentState++;
}
stateCount[currentState]++;
}
j++;
}
if (this.foundPatternCross(stateCount))
{
var confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
if (confirmed != null)
{
return confirmed;
}
}
}
// Hmm, nothing we saw was observed and confirmed twice. If we had
// any guess at all, return it.
if (!(this.possibleCenters.length == 0))
{
return this.possibleCenters[0];
}
throw "Couldn't find enough alignment patterns";
}
}

119
js/jsqrcode/bitmat.js Normal file
View file

@ -0,0 +1,119 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function BitMatrix( width, height)
{
if(!height)
height=width;
if (width < 1 || height < 1)
{
throw "Both dimensions must be greater than 0";
}
this.width = width;
this.height = height;
var rowSize = width >> 5;
if ((width & 0x1f) != 0) {
rowSize++;
}
this.rowSize = rowSize;
this.bits = new Array(rowSize * height);
for(var i=0;i<this.bits.length;i++)
this.bits[i]=0;
Object.defineProperties(this, {
'Width': {
get: function () {
return this.width;
}
},
'Height': {
get: function () {
return this.height;
}
},
'Dimension': {
get: function () {
if (this.width != this.height) {
throw "Can't call getDimension() on a non-square matrix";
}
return this.width;
}
}
});
this.get_Renamed=function( x, y)
{
var offset = y * this.rowSize + (x >> 5);
return ((URShift(this.bits[offset], (x & 0x1f))) & 1) != 0;
}
this.set_Renamed=function( x, y)
{
var offset = y * this.rowSize + (x >> 5);
this.bits[offset] |= 1 << (x & 0x1f);
}
this.flip=function( x, y)
{
var offset = y * this.rowSize + (x >> 5);
this.bits[offset] ^= 1 << (x & 0x1f);
}
this.clear=function()
{
var max = this.bits.length;
for (var i = 0; i < max; i++)
{
this.bits[i] = 0;
}
}
this.setRegion=function( left, top, width, height)
{
if (top < 0 || left < 0)
{
throw "Left and top must be nonnegative";
}
if (height < 1 || width < 1)
{
throw "Height and width must be at least 1";
}
var right = left + width;
var bottom = top + height;
if (bottom > this.height || right > this.width)
{
throw "The region must fit inside the matrix";
}
for (var y = top; y < bottom; y++)
{
var offset = y * this.rowSize;
for (var x = left; x < right; x++)
{
this.bits[offset + (x >> 5)] |= 1 << (x & 0x1f);
}
}
}
}

203
js/jsqrcode/bmparser.js Normal file
View file

@ -0,0 +1,203 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function BitMatrixParser(bitMatrix)
{
var dimension = bitMatrix.Dimension;
if (dimension < 21 || (dimension & 0x03) != 1)
{
throw "Error BitMatrixParser";
}
this.bitMatrix = bitMatrix;
this.parsedVersion = null;
this.parsedFormatInfo = null;
this.copyBit=function( i, j, versionBits)
{
return this.bitMatrix.get_Renamed(i, j)?(versionBits << 1) | 0x1:versionBits << 1;
}
this.readFormatInformation=function()
{
if (this.parsedFormatInfo != null)
{
return this.parsedFormatInfo;
}
// Read top-left format info bits
var formatInfoBits = 0;
for (var i = 0; i < 6; i++)
{
formatInfoBits = this.copyBit(i, 8, formatInfoBits);
}
// .. and skip a bit in the timing pattern ...
formatInfoBits = this.copyBit(7, 8, formatInfoBits);
formatInfoBits = this.copyBit(8, 8, formatInfoBits);
formatInfoBits = this.copyBit(8, 7, formatInfoBits);
// .. and skip a bit in the timing pattern ...
for (var j = 5; j >= 0; j--)
{
formatInfoBits = this.copyBit(8, j, formatInfoBits);
}
this.parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits);
if (this.parsedFormatInfo != null)
{
return this.parsedFormatInfo;
}
// Hmm, failed. Try the top-right/bottom-left pattern
var dimension = this.bitMatrix.Dimension;
formatInfoBits = 0;
var iMin = dimension - 8;
for (var i = dimension - 1; i >= iMin; i--)
{
formatInfoBits = this.copyBit(i, 8, formatInfoBits);
}
for (var j = dimension - 7; j < dimension; j++)
{
formatInfoBits = this.copyBit(8, j, formatInfoBits);
}
this.parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits);
if (this.parsedFormatInfo != null)
{
return this.parsedFormatInfo;
}
throw "Error readFormatInformation";
}
this.readVersion=function()
{
if (this.parsedVersion != null)
{
return this.parsedVersion;
}
var dimension = this.bitMatrix.Dimension;
var provisionalVersion = (dimension - 17) >> 2;
if (provisionalVersion <= 6)
{
return Version.getVersionForNumber(provisionalVersion);
}
// Read top-right version info: 3 wide by 6 tall
var versionBits = 0;
var ijMin = dimension - 11;
for (var j = 5; j >= 0; j--)
{
for (var i = dimension - 9; i >= ijMin; i--)
{
versionBits = this.copyBit(i, j, versionBits);
}
}
this.parsedVersion = Version.decodeVersionInformation(versionBits);
if (this.parsedVersion != null && this.parsedVersion.DimensionForVersion == dimension)
{
return this.parsedVersion;
}
// Hmm, failed. Try bottom left: 6 wide by 3 tall
versionBits = 0;
for (var i = 5; i >= 0; i--)
{
for (var j = dimension - 9; j >= ijMin; j--)
{
versionBits = this.copyBit(i, j, versionBits);
}
}
this.parsedVersion = Version.decodeVersionInformation(versionBits);
if (this.parsedVersion != null && this.parsedVersion.DimensionForVersion == dimension)
{
return this.parsedVersion;
}
throw "Error readVersion";
}
this.readCodewords=function()
{
var formatInfo = this.readFormatInformation();
var version = this.readVersion();
// Get the data mask for the format used in this QR Code. This will exclude
// some bits from reading as we wind through the bit matrix.
var dataMask = DataMask.forReference( formatInfo.DataMask);
var dimension = this.bitMatrix.Dimension;
dataMask.unmaskBitMatrix(this.bitMatrix, dimension);
var functionPattern = version.buildFunctionPattern();
var readingUp = true;
var result = new Array(version.TotalCodewords);
var resultOffset = 0;
var currentByte = 0;
var bitsRead = 0;
// Read columns in pairs, from right to left
for (var j = dimension - 1; j > 0; j -= 2)
{
if (j == 6)
{
// Skip whole column with vertical alignment pattern;
// saves time and makes the other code proceed more cleanly
j--;
}
// Read alternatingly from bottom to top then top to bottom
for (var count = 0; count < dimension; count++)
{
var i = readingUp?dimension - 1 - count:count;
for (var col = 0; col < 2; col++)
{
// Ignore bits covered by the function pattern
if (!functionPattern.get_Renamed(j - col, i))
{
// Read a bit
bitsRead++;
currentByte <<= 1;
if (this.bitMatrix.get_Renamed(j - col, i))
{
currentByte |= 1;
}
// If we've made a whole byte, save it off
if (bitsRead == 8)
{
result[resultOffset++] = currentByte;
bitsRead = 0;
currentByte = 0;
}
}
}
}
readingUp ^= true; // readingUp = !readingUp; // switch directions
}
if (resultOffset != version.TotalCodewords)
{
throw "Error readCodewords";
}
return result;
}
}

122
js/jsqrcode/datablock.js Normal file
View file

@ -0,0 +1,122 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function DataBlock(numDataCodewords, codewords)
{
this.numDataCodewords = numDataCodewords;
this.codewords = codewords;
Object.defineProperties(this, {
'NumDataCodewords': {
get: function () {
return this.numDataCodewords;
}
},
'Codewords': {
get: function () {
return this.codewords;
}
}
});
}
DataBlock.getDataBlocks=function(rawCodewords, version, ecLevel)
{
if (rawCodewords.length != version.TotalCodewords)
{
throw "ArgumentException";
}
// Figure out the number and size of data blocks used by this version and
// error correction level
var ecBlocks = version.getECBlocksForLevel(ecLevel);
// First count the total number of data blocks
var totalBlocks = 0;
var ecBlockArray = ecBlocks.getECBlocks();
for (var i = 0; i < ecBlockArray.length; i++)
{
totalBlocks += ecBlockArray[i].Count;
}
// Now establish DataBlocks of the appropriate size and number of data codewords
var result = new Array(totalBlocks);
var numResultBlocks = 0;
for (var j = 0; j < ecBlockArray.length; j++)
{
var ecBlock = ecBlockArray[j];
for (var i = 0; i < ecBlock.Count; i++)
{
var numDataCodewords = ecBlock.DataCodewords;
var numBlockCodewords = ecBlocks.ECCodewordsPerBlock + numDataCodewords;
result[numResultBlocks++] = new DataBlock(numDataCodewords, new Array(numBlockCodewords));
}
}
// All blocks have the same amount of data, except that the last n
// (where n may be 0) have 1 more byte. Figure out where these start.
var shorterBlocksTotalCodewords = result[0].codewords.length;
var longerBlocksStartAt = result.length - 1;
while (longerBlocksStartAt >= 0)
{
var numCodewords = result[longerBlocksStartAt].codewords.length;
if (numCodewords == shorterBlocksTotalCodewords)
{
break;
}
longerBlocksStartAt--;
}
longerBlocksStartAt++;
var shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.ECCodewordsPerBlock;
// The last elements of result may be 1 element longer;
// first fill out as many elements as all of them have
var rawCodewordsOffset = 0;
for (var i = 0; i < shorterBlocksNumDataCodewords; i++)
{
for (var j = 0; j < numResultBlocks; j++)
{
result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];
}
}
// Fill out the last data block in the longer ones
for (var j = longerBlocksStartAt; j < numResultBlocks; j++)
{
result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++];
}
// Now add in error correction blocks
var max = result[0].codewords.length;
for (var i = shorterBlocksNumDataCodewords; i < max; i++)
{
for (var j = 0; j < numResultBlocks; j++)
{
var iOffset = j < longerBlocksStartAt?i:i + 1;
result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
}
}
return result;
}

284
js/jsqrcode/databr.js Normal file
View file

@ -0,0 +1,284 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function QRCodeDataBlockReader (blocks, version, numErrorCorrectionCode) {
this.blockPointer = 0;
this.bitPointer = 7;
this.dataLength = 0;
this.blocks = blocks;
this.numErrorCorrectionCode = numErrorCorrectionCode;
if (version <= 9)
this.dataLengthMode = 0;
else if (version >= 10 && version <= 26)
this.dataLengthMode = 1;
else if (version >= 27 && version <= 40)
this.dataLengthMode = 2;
this.getNextBits = function (numBits) {
var bits = 0;
if (numBits < this.bitPointer + 1) {
// next word fits into current data block
var mask = 0;
for (var i = 0; i < numBits; i++) {
mask += (1 << i);
}
mask <<= (this.bitPointer - numBits + 1);
bits = (this.blocks[this.blockPointer] & mask) >> (this.bitPointer - numBits + 1);
this.bitPointer -= numBits;
return bits;
} else if (numBits < this.bitPointer + 1 + 8) {
// next word crosses 2 data blocks
var mask1 = 0;
for (var i = 0; i < this.bitPointer + 1; i++)
{
mask1 += (1 << i);
}
bits = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1));
this.blockPointer++;
bits += ((this.blocks[this.blockPointer]) >> (8 - (numBits - (this.bitPointer + 1))));
this.bitPointer = this.bitPointer - numBits % 8;
if (this.bitPointer < 0)
{
this.bitPointer = 8 + this.bitPointer;
}
return bits;
} else if (numBits < this.bitPointer + 1 + 16) {
// next word crosses 3 data blocks
var mask1 = 0; // mask of first block
var mask3 = 0; // mask of 3rd block
//bitPointer + 1 : number of bits of the 1st block
//8 : number of the 2nd block (note that use already 8bits because next word uses 3 data blocks)
//numBits - (bitPointer + 1 + 8) : number of bits of the 3rd block
for (var i = 0; i < this.bitPointer + 1; i++)
{
mask1 += (1 << i);
}
var bitsFirstBlock = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1));
this.blockPointer++;
var bitsSecondBlock = this.blocks[this.blockPointer] << (numBits - (this.bitPointer + 1 + 8));
this.blockPointer++;
for (var i = 0; i < numBits - (this.bitPointer + 1 + 8); i++) {
mask3 += (1 << i);
}
mask3 <<= 8 - (numBits - (this.bitPointer + 1 + 8));
var bitsThirdBlock = (this.blocks[this.blockPointer] & mask3) >> (8 - (numBits - (this.bitPointer + 1 + 8)));
bits = bitsFirstBlock + bitsSecondBlock + bitsThirdBlock;
this.bitPointer = this.bitPointer - (numBits - 8) % 8;
if (this.bitPointer < 0) {
this.bitPointer = 8 + this.bitPointer;
}
return bits;
} else {
return 0;
}
};
this.NextMode = function () {
if ((this.blockPointer > this.blocks.length - this.numErrorCorrectionCode - 2))
return 0;
else
return this.getNextBits(4);
};
this.getDataLength=function( modeIndicator) {
var index = 0;
while (true)
{
if ((modeIndicator >> index) == 1)
break;
index++;
}
return this.getNextBits(qrcode.sizeOfDataLengthInfo[this.dataLengthMode][index]);
};
this.getRomanAndFigureString = function (dataLength) {
var length = dataLength;
var intData = 0;
var strData = "";
var tableRomanAndFigure = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', '+', '-', '.', '/', ':');
do {
if (length > 1) {
intData = this.getNextBits(11);
var firstLetter = Math.floor(intData / 45);
var secondLetter = intData % 45;
strData += tableRomanAndFigure[firstLetter];
strData += tableRomanAndFigure[secondLetter];
length -= 2;
} else if (length == 1) {
intData = this.getNextBits(6);
strData += tableRomanAndFigure[intData];
length -= 1;
}
} while (length > 0);
return strData;
};
this.getFigureString=function( dataLength) {
var length = dataLength;
var intData = 0;
var strData = "";
do
{
if (length >= 3)
{
intData = this.getNextBits(10);
if (intData < 100)
strData += "0";
if (intData < 10)
strData += "0";
length -= 3;
}
else if (length == 2)
{
intData = this.getNextBits(7);
if (intData < 10)
strData += "0";
length -= 2;
}
else if (length == 1)
{
intData = this.getNextBits(4);
length -= 1;
}
strData += intData;
}
while (length > 0);
return strData;
};
this.get8bitByteArray=function( dataLength) {
var length = dataLength;
var intData = 0;
var output = new Array();
do {
intData = this.getNextBits(8);
output.push( intData);
length--;
} while (length > 0);
return output;
};
this.getKanjiString = function (dataLength) {
var length = dataLength;
var intData = 0;
var unicodeString = "";
do {
intData = getNextBits(13);
var lowerByte = intData % 0xC0;
var higherByte = intData / 0xC0;
var tempWord = (higherByte << 8) + lowerByte;
var shiftjisWord = 0;
if (tempWord + 0x8140 <= 0x9FFC) {
// between 8140 - 9FFC on Shift_JIS character set
shiftjisWord = tempWord + 0x8140;
} else {
// between E040 - EBBF on Shift_JIS character set
shiftjisWord = tempWord + 0xC140;
}
unicodeString += String.fromCharCode(shiftjisWord);
length--;
} while (length > 0);
return unicodeString;
};
Object.defineProperty(this, 'DataByte', {
get: function () {
var output = new Array();
var MODE_NUMBER = 1;
var MODE_ROMAN_AND_NUMBER = 2;
var MODE_8BIT_BYTE = 4;
var MODE_KANJI = 8;
do {
var mode = this.NextMode();
if (mode == 0) {
if (output.length > 0)
break;
else
throw "Empty data block";
}
if (mode != MODE_NUMBER &&
mode != MODE_ROMAN_AND_NUMBER &&
mode != MODE_8BIT_BYTE &&
mode != MODE_KANJI) {
mode = guessMode(mode);
throw "Invalid mode: " + mode + " in (block:" + this.blockPointer + " bit:" + this.bitPointer + ")";
}
dataLength = this.getDataLength(mode);
if (dataLength < 1)
throw "Invalid data length: " + dataLength;
switch (mode) {
case MODE_NUMBER:
var temp_str = this.getFigureString(dataLength);
var ta = new Array(temp_str.length);
for(var j=0;j<temp_str.length;j++)
ta[j]=temp_str.charCodeAt(j);
output.push(ta);
break;
case MODE_ROMAN_AND_NUMBER:
var temp_str = this.getRomanAndFigureString(dataLength);
var ta = new Array(temp_str.length);
for(var j=0;j<temp_str.length;j++)
ta[j]=temp_str.charCodeAt(j);
output.push(ta );
break;
case MODE_8BIT_BYTE:
var temp_sbyteArray3 = this.get8bitByteArray(dataLength);
output.push(temp_sbyteArray3);
break;
case MODE_KANJI:
var temp_str = this.getKanjiString(dataLength);
output.push(temp_str);
break;
}
} while (true);
return output;
}
});
}

207
js/jsqrcode/datamask.js Normal file
View file

@ -0,0 +1,207 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
DataMask = {};
DataMask.forReference = function(reference)
{
if (reference < 0 || reference > 7)
{
throw "System.ArgumentException";
}
return DataMask.DATA_MASKS[reference];
}
function DataMask000()
{
this.unmaskBitMatrix=function(bits, dimension)
{
for (var i = 0; i < dimension; i++)
{
for (var j = 0; j < dimension; j++)
{
if (this.isMasked(i, j))
{
bits.flip(j, i);
}
}
}
}
this.isMasked=function( i, j)
{
return ((i + j) & 0x01) == 0;
}
}
function DataMask001()
{
this.unmaskBitMatrix=function(bits, dimension)
{
for (var i = 0; i < dimension; i++)
{
for (var j = 0; j < dimension; j++)
{
if (this.isMasked(i, j))
{
bits.flip(j, i);
}
}
}
}
this.isMasked=function( i, j)
{
return (i & 0x01) == 0;
}
}
function DataMask010()
{
this.unmaskBitMatrix=function(bits, dimension)
{
for (var i = 0; i < dimension; i++)
{
for (var j = 0; j < dimension; j++)
{
if (this.isMasked(i, j))
{
bits.flip(j, i);
}
}
}
}
this.isMasked=function( i, j)
{
return j % 3 == 0;
}
}
function DataMask011()
{
this.unmaskBitMatrix=function(bits, dimension)
{
for (var i = 0; i < dimension; i++)
{
for (var j = 0; j < dimension; j++)
{
if (this.isMasked(i, j))
{
bits.flip(j, i);
}
}
}
}
this.isMasked=function( i, j)
{
return (i + j) % 3 == 0;
}
}
function DataMask100()
{
this.unmaskBitMatrix=function(bits, dimension)
{
for (var i = 0; i < dimension; i++)
{
for (var j = 0; j < dimension; j++)
{
if (this.isMasked(i, j))
{
bits.flip(j, i);
}
}
}
}
this.isMasked=function( i, j)
{
return (((URShift(i, 1)) + (j / 3)) & 0x01) == 0;
}
}
function DataMask101()
{
this.unmaskBitMatrix=function(bits, dimension)
{
for (var i = 0; i < dimension; i++)
{
for (var j = 0; j < dimension; j++)
{
if (this.isMasked(i, j))
{
bits.flip(j, i);
}
}
}
}
this.isMasked=function( i, j)
{
var temp = i * j;
return (temp & 0x01) + (temp % 3) == 0;
}
}
function DataMask110()
{
this.unmaskBitMatrix=function(bits, dimension)
{
for (var i = 0; i < dimension; i++)
{
for (var j = 0; j < dimension; j++)
{
if (this.isMasked(i, j))
{
bits.flip(j, i);
}
}
}
}
this.isMasked=function( i, j)
{
var temp = i * j;
return (((temp & 0x01) + (temp % 3)) & 0x01) == 0;
}
}
function DataMask111()
{
this.unmaskBitMatrix=function(bits, dimension)
{
for (var i = 0; i < dimension; i++)
{
for (var j = 0; j < dimension; j++)
{
if (this.isMasked(i, j))
{
bits.flip(j, i);
}
}
}
}
this.isMasked=function( i, j)
{
return ((((i + j) & 0x01) + ((i * j) % 3)) & 0x01) == 0;
}
}
DataMask.DATA_MASKS = new Array(new DataMask000(), new DataMask001(), new DataMask010(), new DataMask011(), new DataMask100(), new DataMask101(), new DataMask110(), new DataMask111());

95
js/jsqrcode/decoder.js Normal file
View file

@ -0,0 +1,95 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Decoder={};
Decoder.rsDecoder = new ReedSolomonDecoder(GF256.QR_CODE_FIELD);
Decoder.correctErrors=function( codewordBytes, numDataCodewords)
{
var numCodewords = codewordBytes.length;
// First read into an array of ints
var codewordsInts = new Array(numCodewords);
for (var i = 0; i < numCodewords; i++)
{
codewordsInts[i] = codewordBytes[i] & 0xFF;
}
var numECCodewords = codewordBytes.length - numDataCodewords;
try
{
Decoder.rsDecoder.decode(codewordsInts, numECCodewords);
//var corrector = new ReedSolomon(codewordsInts, numECCodewords);
//corrector.correct();
}
catch ( rse)
{
throw rse;
}
// Copy back into array of bytes -- only need to worry about the bytes that were data
// We don't care about errors in the error-correction codewords
for (var i = 0; i < numDataCodewords; i++)
{
codewordBytes[i] = codewordsInts[i];
}
}
Decoder.decode=function(bits)
{
var parser = new BitMatrixParser(bits);console.log(JSON.stringify(bits));
var version = parser.readVersion();
var ecLevel = parser.readFormatInformation().ErrorCorrectionLevel;
// Read codewords
var codewords = parser.readCodewords();
// Separate into data blocks
var dataBlocks = DataBlock.getDataBlocks(codewords, version, ecLevel);
// Count total number of data bytes
var totalBytes = 0;
for (var i = 0; i < dataBlocks.length; i++)
{
totalBytes += dataBlocks[i].NumDataCodewords;
}
var resultBytes = new Array(totalBytes);
var resultOffset = 0;
// Error-correct and copy data blocks together into a stream of bytes
for (var j = 0; j < dataBlocks.length; j++)
{
var dataBlock = dataBlocks[j];
var codewordBytes = dataBlock.Codewords;
var numDataCodewords = dataBlock.NumDataCodewords;
Decoder.correctErrors(codewordBytes, numDataCodewords);
for (var i = 0; i < numDataCodewords; i++)
{
resultBytes[resultOffset++] = codewordBytes[i];
}
}
// Decode the contents of that stream of bytes
var reader = new QRCodeDataBlockReader(resultBytes, version.VersionNumber, ecLevel.Bits);
return reader;
//return DecodedBitStreamParser.decode(resultBytes, version, ecLevel);
}

413
js/jsqrcode/detector.js Normal file
View file

@ -0,0 +1,413 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function PerspectiveTransform( a11, a21, a31, a12, a22, a32, a13, a23, a33)
{
this.a11 = a11;
this.a12 = a12;
this.a13 = a13;
this.a21 = a21;
this.a22 = a22;
this.a23 = a23;
this.a31 = a31;
this.a32 = a32;
this.a33 = a33;
this.transformPoints1=function( points)
{
var max = points.length;
var a11 = this.a11;
var a12 = this.a12;
var a13 = this.a13;
var a21 = this.a21;
var a22 = this.a22;
var a23 = this.a23;
var a31 = this.a31;
var a32 = this.a32;
var a33 = this.a33;
for (var i = 0; i < max; i += 2)
{
var x = points[i];
var y = points[i + 1];
var denominator = a13 * x + a23 * y + a33;
points[i] = (a11 * x + a21 * y + a31) / denominator;
points[i + 1] = (a12 * x + a22 * y + a32) / denominator;
}
}
this. transformPoints2=function(xValues, yValues)
{
var n = xValues.length;
for (var i = 0; i < n; i++)
{
var x = xValues[i];
var y = yValues[i];
var denominator = this.a13 * x + this.a23 * y + this.a33;
xValues[i] = (this.a11 * x + this.a21 * y + this.a31) / denominator;
yValues[i] = (this.a12 * x + this.a22 * y + this.a32) / denominator;
}
}
this.buildAdjoint=function()
{
// Adjoint is the transpose of the cofactor matrix:
return new PerspectiveTransform(this.a22 * this.a33 - this.a23 * this.a32, this.a23 * this.a31 - this.a21 * this.a33, this.a21 * this.a32 - this.a22 * this.a31, this.a13 * this.a32 - this.a12 * this.a33, this.a11 * this.a33 - this.a13 * this.a31, this.a12 * this.a31 - this.a11 * this.a32, this.a12 * this.a23 - this.a13 * this.a22, this.a13 * this.a21 - this.a11 * this.a23, this.a11 * this.a22 - this.a12 * this.a21);
}
this.times=function( other)
{
return new PerspectiveTransform(this.a11 * other.a11 + this.a21 * other.a12 + this.a31 * other.a13, this.a11 * other.a21 + this.a21 * other.a22 + this.a31 * other.a23, this.a11 * other.a31 + this.a21 * other.a32 + this.a31 * other.a33, this.a12 * other.a11 + this.a22 * other.a12 + this.a32 * other.a13, this.a12 * other.a21 + this.a22 * other.a22 + this.a32 * other.a23, this.a12 * other.a31 + this.a22 * other.a32 + this.a32 * other.a33, this.a13 * other.a11 + this.a23 * other.a12 +this.a33 * other.a13, this.a13 * other.a21 + this.a23 * other.a22 + this.a33 * other.a23, this.a13 * other.a31 + this.a23 * other.a32 + this.a33 * other.a33);
}
}
PerspectiveTransform.quadrilateralToQuadrilateral=function( x0, y0, x1, y1, x2, y2, x3, y3, x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p)
{
var qToS = this.quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3);
var sToQ = this.squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p);
return sToQ.times(qToS);
}
PerspectiveTransform.squareToQuadrilateral=function( x0, y0, x1, y1, x2, y2, x3, y3)
{
dy2 = y3 - y2;
dy3 = y0 - y1 + y2 - y3;
if (dy2 == 0.0 && dy3 == 0.0)
{
return new PerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, y2 - y1, y0, 0.0, 0.0, 1.0);
}
else
{
dx1 = x1 - x2;
dx2 = x3 - x2;
dx3 = x0 - x1 + x2 - x3;
dy1 = y1 - y2;
denominator = dx1 * dy2 - dx2 * dy1;
a13 = (dx3 * dy2 - dx2 * dy3) / denominator;
a23 = (dx1 * dy3 - dx3 * dy1) / denominator;
return new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0, a13, a23, 1.0);
}
}
PerspectiveTransform.quadrilateralToSquare=function( x0, y0, x1, y1, x2, y2, x3, y3)
{
// Here, the adjoint serves as the inverse:
return this.squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3).buildAdjoint();
}
function DetectorResult(bits, points)
{
this.bits = bits;
this.points = points;
}
function Detector(image)
{
this.image=image;
this.resultPointCallback = null;
this.sizeOfBlackWhiteBlackRun=function( fromX, fromY, toX, toY)
{
// Mild variant of Bresenham's algorithm;
// see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm
var steep = Math.abs(toY - fromY) > Math.abs(toX - fromX);
if (steep)
{
var temp = fromX;
fromX = fromY;
fromY = temp;
temp = toX;
toX = toY;
toY = temp;
}
var dx = Math.abs(toX - fromX);
var dy = Math.abs(toY - fromY);
var error = - dx >> 1;
var ystep = fromY < toY?1:- 1;
var xstep = fromX < toX?1:- 1;
var state = 0; // In black pixels, looking for white, first or second time
for (var x = fromX, y = fromY; x != toX; x += xstep)
{
var realX = steep?y:x;
var realY = steep?x:y;
if (state == 1)
{
// In white pixels, looking for black
if (this.image[realX + realY*qrcode.width])
{
state++;
}
}
else
{
if (!this.image[realX + realY*qrcode.width])
{
state++;
}
}
if (state == 3)
{
// Found black, white, black, and stumbled back onto white; done
var diffX = x - fromX;
var diffY = y - fromY;
return Math.sqrt( (diffX * diffX + diffY * diffY));
}
error += dy;
if (error > 0)
{
if (y == toY)
{
break;
}
y += ystep;
error -= dx;
}
}
var diffX2 = toX - fromX;
var diffY2 = toY - fromY;
return Math.sqrt( (diffX2 * diffX2 + diffY2 * diffY2));
}
this.sizeOfBlackWhiteBlackRunBothWays=function( fromX, fromY, toX, toY)
{
var result = this.sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY);
// Now count other way -- don't run off image though of course
var scale = 1.0;
var otherToX = fromX - (toX - fromX);
if (otherToX < 0)
{
scale = fromX / (fromX - otherToX);
otherToX = 0;
}
else if (otherToX >= qrcode.width)
{
scale = (qrcode.width - 1 - fromX) / (otherToX - fromX);
otherToX = qrcode.width - 1;
}
var otherToY = Math.floor (fromY - (toY - fromY) * scale);
scale = 1.0;
if (otherToY < 0)
{
scale = fromY / (fromY - otherToY);
otherToY = 0;
}
else if (otherToY >= qrcode.height)
{
scale = (qrcode.height - 1 - fromY) / (otherToY - fromY);
otherToY = qrcode.height - 1;
}
otherToX = Math.floor (fromX + (otherToX - fromX) * scale);
result += this.sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);
return result - 1.0; // -1 because we counted the middle pixel twice
}
this.calculateModuleSizeOneWay=function( pattern, otherPattern)
{
var moduleSizeEst1 = this.sizeOfBlackWhiteBlackRunBothWays(Math.floor( pattern.X), Math.floor( pattern.Y), Math.floor( otherPattern.X), Math.floor(otherPattern.Y));
var moduleSizeEst2 = this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(otherPattern.X), Math.floor(otherPattern.Y), Math.floor( pattern.X), Math.floor(pattern.Y));
if (isNaN(moduleSizeEst1))
{
return moduleSizeEst2 / 7.0;
}
if (isNaN(moduleSizeEst2))
{
return moduleSizeEst1 / 7.0;
}
// Average them, and divide by 7 since we've counted the width of 3 black modules,
// and 1 white and 1 black module on either side. Ergo, divide sum by 14.
return (moduleSizeEst1 + moduleSizeEst2) / 14.0;
}
this.calculateModuleSize=function( topLeft, topRight, bottomLeft)
{
// Take the average
return (this.calculateModuleSizeOneWay(topLeft, topRight) + this.calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0;
}
this.distance=function( pattern1, pattern2)
{
xDiff = pattern1.X - pattern2.X;
yDiff = pattern1.Y - pattern2.Y;
return Math.sqrt( (xDiff * xDiff + yDiff * yDiff));
}
this.computeDimension=function( topLeft, topRight, bottomLeft, moduleSize)
{
var tltrCentersDimension = Math.round(this.distance(topLeft, topRight) / moduleSize);
var tlblCentersDimension = Math.round(this.distance(topLeft, bottomLeft) / moduleSize);
var dimension = ((tltrCentersDimension + tlblCentersDimension) >> 1) + 7;
switch (dimension & 0x03)
{
// mod 4
case 0:
dimension++;
break;
// 1? do nothing
case 2:
dimension--;
break;
case 3:
throw "Error";
}
return dimension;
}
this.findAlignmentInRegion=function( overallEstModuleSize, estAlignmentX, estAlignmentY, allowanceFactor)
{
// Look for an alignment pattern (3 modules in size) around where it
// should be
var allowance = Math.floor (allowanceFactor * overallEstModuleSize);
var alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance);
var alignmentAreaRightX = Math.min(qrcode.width - 1, estAlignmentX + allowance);
if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3)
{
throw "Error";
}
var alignmentAreaTopY = Math.max(0, estAlignmentY - allowance);
var alignmentAreaBottomY = Math.min(qrcode.height - 1, estAlignmentY + allowance);
var alignmentFinder = new AlignmentPatternFinder(this.image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, this.resultPointCallback);
return alignmentFinder.find();
}
this.createTransform=function( topLeft, topRight, bottomLeft, alignmentPattern, dimension)
{
var dimMinusThree = dimension - 3.5;
var bottomRightX;
var bottomRightY;
var sourceBottomRightX;
var sourceBottomRightY;
if (alignmentPattern != null)
{
bottomRightX = alignmentPattern.X;
bottomRightY = alignmentPattern.Y;
sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0;
}
else
{
// Don't have an alignment pattern, just make up the bottom-right point
bottomRightX = (topRight.X - topLeft.X) + bottomLeft.X;
bottomRightY = (topRight.Y - topLeft.Y) + bottomLeft.Y;
sourceBottomRightX = sourceBottomRightY = dimMinusThree;
}
var transform = PerspectiveTransform.quadrilateralToQuadrilateral(3.5, 3.5, dimMinusThree, 3.5, sourceBottomRightX, sourceBottomRightY, 3.5, dimMinusThree, topLeft.X, topLeft.Y, topRight.X, topRight.Y, bottomRightX, bottomRightY, bottomLeft.X, bottomLeft.Y);
return transform;
}
this.sampleGrid=function( image, transform, dimension)
{
var sampler = GridSampler;
return sampler.sampleGrid3(image, dimension, transform);
}
this.processFinderPatternInfo = function( info)
{
var topLeft = info.TopLeft;
var topRight = info.TopRight;
var bottomLeft = info.BottomLeft;
var moduleSize = this.calculateModuleSize(topLeft, topRight, bottomLeft);
if (moduleSize < 1.0)
{
throw "Error";
}
var dimension = this.computeDimension(topLeft, topRight, bottomLeft, moduleSize);
var provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
var modulesBetweenFPCenters = provisionalVersion.DimensionForVersion - 7;
var alignmentPattern = null;
// Anything above version 1 has an alignment pattern
if (provisionalVersion.AlignmentPatternCenters.length > 0)
{
// Guess where a "bottom right" finder pattern would have been
var bottomRightX = topRight.X - topLeft.X + bottomLeft.X;
var bottomRightY = topRight.Y - topLeft.Y + bottomLeft.Y;
// Estimate that alignment pattern is closer by 3 modules
// from "bottom right" to known top left location
var correctionToTopLeft = 1.0 - 3.0 / modulesBetweenFPCenters;
var estAlignmentX = Math.floor (topLeft.X + correctionToTopLeft * (bottomRightX - topLeft.X));
var estAlignmentY = Math.floor (topLeft.Y + correctionToTopLeft * (bottomRightY - topLeft.Y));
// Kind of arbitrary -- expand search radius before giving up
for (var i = 4; i <= 16; i <<= 1)
{
//try
//{
alignmentPattern = this.findAlignmentInRegion(moduleSize, estAlignmentX, estAlignmentY, i);
break;
//}
//catch (re)
//{
// try next round
//}
}
// If we didn't find alignment pattern... well try anyway without it
}
var transform = this.createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);
var bits = this.sampleGrid(this.image, transform, dimension);
var points;
if (alignmentPattern == null)
{
points = new Array(bottomLeft, topLeft, topRight);
}
else
{
points = new Array(bottomLeft, topLeft, topRight, alignmentPattern);
}
return new DetectorResult(bits, points);
}
this.detect=function()
{
var info = new FinderPatternFinder().findFinderPattern(this.image);
return this.processFinderPatternInfo(info);
}
}

64
js/jsqrcode/errorlevel.js Normal file
View file

@ -0,0 +1,64 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function ErrorCorrectionLevel(ordinal, bits, name)
{
this.ordinal_Renamed_Field = ordinal;
this.bits = bits;
this.name = name;
Object.defineProperties(this, {
'Bits': {
get: function () {
return this.bits;
}
},
'Name': {
get: function () {
return this.name;
}
}
});
this.ordinal=function() {
return this.ordinal_Renamed_Field;
}
}
ErrorCorrectionLevel.forBits=function( bits)
{
if (bits < 0 || bits >= FOR_BITS.length) {
throw "ArgumentException";
}
return FOR_BITS[bits];
}
var L = new ErrorCorrectionLevel(0, 0x01, "L");
var M = new ErrorCorrectionLevel(1, 0x00, "M");
var Q = new ErrorCorrectionLevel(2, 0x03, "Q");
var H = new ErrorCorrectionLevel(3, 0x02, "H");
var FOR_BITS = new Array( M, L, H, Q);

653
js/jsqrcode/findpat.js Normal file
View file

@ -0,0 +1,653 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var MIN_SKIP = 3;
var MAX_MODULES = 57;
var INTEGER_MATH_SHIFT = 8;
var CENTER_QUORUM = 2;
qrcode.orderBestPatterns = function (patterns) {
function distance( pattern1, pattern2) {
xDiff = pattern1.X - pattern2.X;
yDiff = pattern1.Y - pattern2.Y;
return Math.sqrt( (xDiff * xDiff + yDiff * yDiff));
}
/// <summary> Returns the z component of the cross product between vectors BC and BA.</summary>
function crossProductZ( pointA, pointB, pointC) {
var bX = pointB.x;
var bY = pointB.y;
return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));
}
// Find distances between pattern centers
var zeroOneDistance = distance(patterns[0], patterns[1]);
var oneTwoDistance = distance(patterns[1], patterns[2]);
var zeroTwoDistance = distance(patterns[0], patterns[2]);
var pointA, pointB, pointC;
// Assume one closest to other two is B; A and C will just be guesses at first
if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {
pointB = patterns[0];
pointA = patterns[1];
pointC = patterns[2];
} else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance) {
pointB = patterns[1];
pointA = patterns[0];
pointC = patterns[2];
} else {
pointB = patterns[2];
pointA = patterns[0];
pointC = patterns[1];
}
// Use cross product to figure out whether A and C are correct or flipped.
// This asks whether BC x BA has a positive z component, which is the arrangement
// we want for A, B, C. If it's negative, then we've got it flipped around and
// should swap A and C.
if (crossProductZ(pointA, pointB, pointC) < 0.0) {
var temp = pointA;
pointA = pointC;
pointC = temp;
}
patterns[0] = pointA;
patterns[1] = pointB;
patterns[2] = pointC;
};
function FinderPattern (posX, posY, estimatedModuleSize) {
this.x=posX;
this.y=posY;
this.count = 1;
this.estimatedModuleSize = estimatedModuleSize;
Object.defineProperties(this, {
"EstimatedModuleSize": {
get: function () {
return this.estimatedModuleSize;
}
},
"Count": {
get: function () {
return this.count;
}
},
"X": {
get: function () {
return this.x;
}
},
"Y": {
get: function () {
return this.y;
}
}
});
this.incrementCount = function() {
this.count++;
};
this.aboutEquals = function (moduleSize, i, j) {
if (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize) {
var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
return moduleSizeDiff <= 1.0 || moduleSizeDiff / this.estimatedModuleSize <= 1.0;
}
return false;
}
};
function FinderPatternInfo(patternCenters) {
this.bottomLeft = patternCenters[0];
this.topLeft = patternCenters[1];
this.topRight = patternCenters[2];
Object.defineProperties(this, {
"BottomLeft": {
get: function () {
return this.bottomLeft;
}
},
"TopLeft": {
get: function () {
return this.topLeft;
}
},
"TopRight": {
get: function () {
return this.topRight;
}
}
});
}
function FinderPatternFinder()
{
this.image=null;
this.possibleCenters = [];
this.hasSkipped = false;
this.crossCheckStateCount = new Array(0,0,0,0,0);
this.resultPointCallback = null;
Object.defineProperty(this, 'CrossCheckStateCount', {
get: function () {
this.crossCheckStateCount[0] = 0;
this.crossCheckStateCount[1] = 0;
this.crossCheckStateCount[2] = 0;
this.crossCheckStateCount[3] = 0;
this.crossCheckStateCount[4] = 0;
return this.crossCheckStateCount;
}
});
this.foundPatternCross=function( stateCount)
{
var totalModuleSize = 0;
for (var i = 0; i < 5; i++)
{
var count = stateCount[i];
if (count == 0)
{
return false;
}
totalModuleSize += count;
}
if (totalModuleSize < 7)
{
return false;
}
var moduleSize = Math.floor((totalModuleSize << INTEGER_MATH_SHIFT) / 7);
var maxVariance = Math.floor(moduleSize / 2);
// Allow less than 50% variance from 1-1-3-1-1 proportions
return Math.abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) < 3 * maxVariance && Math.abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) < maxVariance;
}
this.centerFromEnd=function( stateCount, end)
{
return (end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0;
}
this.crossCheckVertical=function( startI, centerJ, maxCount, originalStateCountTotal)
{
var image = this.image;
var maxI = qrcode.height;
var stateCount = this.CrossCheckStateCount;
// Start counting up from center
var i = startI;
while (i >= 0 && image[centerJ + i*qrcode.width])
{
stateCount[2]++;
i--;
}
if (i < 0)
{
return NaN;
}
while (i >= 0 && !image[centerJ +i*qrcode.width] && stateCount[1] <= maxCount)
{
stateCount[1]++;
i--;
}
// If already too many modules in this state or ran off the edge:
if (i < 0 || stateCount[1] > maxCount)
{
return NaN;
}
while (i >= 0 && image[centerJ + i*qrcode.width] && stateCount[0] <= maxCount)
{
stateCount[0]++;
i--;
}
if (stateCount[0] > maxCount)
{
return NaN;
}
// Now also count down from center
i = startI + 1;
while (i < maxI && image[centerJ +i*qrcode.width])
{
stateCount[2]++;
i++;
}
if (i == maxI)
{
return NaN;
}
while (i < maxI && !image[centerJ + i*qrcode.width] && stateCount[3] < maxCount)
{
stateCount[3]++;
i++;
}
if (i == maxI || stateCount[3] >= maxCount)
{
return NaN;
}
while (i < maxI && image[centerJ + i*qrcode.width] && stateCount[4] < maxCount)
{
stateCount[4]++;
i++;
}
if (stateCount[4] >= maxCount)
{
return NaN;
}
// If we found a finder-pattern-like section, but its size is more than 40% different than
// the original, assume it's a false positive
var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal)
{
return NaN;
}
return this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, i):NaN;
}
this.crossCheckHorizontal=function( startJ, centerI, maxCount, originalStateCountTotal)
{
var image = this.image;
var maxJ = qrcode.width;
var stateCount = this.CrossCheckStateCount;
var j = startJ;
while (j >= 0 && image[j+ centerI*qrcode.width])
{
stateCount[2]++;
j--;
}
if (j < 0)
{
return NaN;
}
while (j >= 0 && !image[j+ centerI*qrcode.width] && stateCount[1] <= maxCount)
{
stateCount[1]++;
j--;
}
if (j < 0 || stateCount[1] > maxCount)
{
return NaN;
}
while (j >= 0 && image[j+ centerI*qrcode.width] && stateCount[0] <= maxCount)
{
stateCount[0]++;
j--;
}
if (stateCount[0] > maxCount)
{
return NaN;
}
j = startJ + 1;
while (j < maxJ && image[j+ centerI*qrcode.width])
{
stateCount[2]++;
j++;
}
if (j == maxJ)
{
return NaN;
}
while (j < maxJ && !image[j+ centerI*qrcode.width] && stateCount[3] < maxCount)
{
stateCount[3]++;
j++;
}
if (j == maxJ || stateCount[3] >= maxCount)
{
return NaN;
}
while (j < maxJ && image[j+ centerI*qrcode.width] && stateCount[4] < maxCount)
{
stateCount[4]++;
j++;
}
if (stateCount[4] >= maxCount)
{
return NaN;
}
// If we found a finder-pattern-like section, but its size is significantly different than
// the original, assume it's a false positive
var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal)
{
return NaN;
}
return this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, j):NaN;
}
this.handlePossibleCenter=function( stateCount, i, j)
{
var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
var centerJ = this.centerFromEnd(stateCount, j); //float
var centerI = this.crossCheckVertical(i, Math.floor( centerJ), stateCount[2], stateCountTotal); //float
if (!isNaN(centerI))
{
// Re-cross check
centerJ = this.crossCheckHorizontal(Math.floor( centerJ), Math.floor( centerI), stateCount[2], stateCountTotal);
if (!isNaN(centerJ))
{
var estimatedModuleSize = stateCountTotal / 7.0;
var found = false;
var max = this.possibleCenters.length;
for (var index = 0; index < max; index++)
{
var center = this.possibleCenters[index];
// Look for about the same center and module size:
if (center.aboutEquals(estimatedModuleSize, centerI, centerJ))
{
center.incrementCount();
found = true;
break;
}
}
if (!found)
{
var point = new FinderPattern(centerJ, centerI, estimatedModuleSize);
this.possibleCenters.push(point);
if (this.resultPointCallback != null)
{
this.resultPointCallback.foundPossibleResultPoint(point);
}
}
return true;
}
}
return false;
}
this.selectBestPatterns=function()
{
var startSize = this.possibleCenters.length;
if (startSize < 3)
{
// Couldn't find enough finder patterns
throw "Couldn't find enough finder patterns";
}
// Filter outlier possibilities whose module size is too different
if (startSize > 3)
{
// But we can only afford to do so if we have at least 4 possibilities to choose from
var totalModuleSize = 0.0;
var square = 0.0;
for (var i = 0; i < startSize; i++)
{
//totalModuleSize += this.possibleCenters[i].EstimatedModuleSize;
var centerValue=this.possibleCenters[i].EstimatedModuleSize;
totalModuleSize += centerValue;
square += (centerValue * centerValue);
}
var average = totalModuleSize / startSize;
this.possibleCenters.sort(function(center1,center2) {
var dA=Math.abs(center2.EstimatedModuleSize - average);
var dB=Math.abs(center1.EstimatedModuleSize - average);
if (dA < dB) {
return (-1);
} else if (dA == dB) {
return 0;
} else {
return 1;
}
});
var stdDev = Math.sqrt(square / startSize - average * average);
var limit = Math.max(0.2 * average, stdDev);
for (var i = 0; i < this.possibleCenters.length && this.possibleCenters.length > 3; i++)
{
var pattern = this.possibleCenters[i];
//if (Math.abs(pattern.EstimatedModuleSize - average) > 0.2 * average)
if (Math.abs(pattern.EstimatedModuleSize - average) > limit)
{
this.possibleCenters.remove(i);
i--;
}
}
}
if (this.possibleCenters.length > 3)
{
// Throw away all but those first size candidate points we found.
this.possibleCenters.sort(function(a, b){
if (a.count > b.count){return -1;}
if (a.count < b.count){return 1;}
return 0;
});
}
return new Array( this.possibleCenters[0], this.possibleCenters[1], this.possibleCenters[2]);
}
this.findRowSkip=function()
{
var max = this.possibleCenters.length;
if (max <= 1)
{
return 0;
}
var firstConfirmedCenter = null;
for (var i = 0; i < max; i++)
{
var center = this.possibleCenters[i];
if (center.Count >= CENTER_QUORUM)
{
if (firstConfirmedCenter == null)
{
firstConfirmedCenter = center;
}
else
{
// We have two confirmed centers
// How far down can we skip before resuming looking for the next
// pattern? In the worst case, only the difference between the
// difference in the x / y coordinates of the two centers.
// This is the case where you find top left last.
this.hasSkipped = true;
return Math.floor ((Math.abs(firstConfirmedCenter.X - center.X) - Math.abs(firstConfirmedCenter.Y - center.Y)) / 2);
}
}
}
return 0;
}
this.haveMultiplyConfirmedCenters=function()
{
var confirmedCount = 0;
var totalModuleSize = 0.0;
var max = this.possibleCenters.length;
for (var i = 0; i < max; i++)
{
var pattern = this.possibleCenters[i];
if (pattern.Count >= CENTER_QUORUM)
{
confirmedCount++;
totalModuleSize += pattern.EstimatedModuleSize;
}
}
if (confirmedCount < 3)
{
return false;
}
// OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive"
// and that we need to keep looking. We detect this by asking if the estimated module sizes
// vary too much. We arbitrarily say that when the total deviation from average exceeds
// 5% of the total module size estimates, it's too much.
var average = totalModuleSize / max;
var totalDeviation = 0.0;
for (var i = 0; i < max; i++)
{
pattern = this.possibleCenters[i];
totalDeviation += Math.abs(pattern.EstimatedModuleSize - average);
}
return totalDeviation <= 0.05 * totalModuleSize;
}
this.findFinderPattern = function(image){
var tryHarder = false;
this.image=image;
var maxI = qrcode.height;
var maxJ = qrcode.width;
var iSkip = Math.floor((3 * maxI) / (4 * MAX_MODULES));
if (iSkip < MIN_SKIP || tryHarder)
{
iSkip = MIN_SKIP;
}
var done = false;
var stateCount = new Array(5);
for (var i = iSkip - 1; i < maxI && !done; i += iSkip)
{
// Get a row of black/white values
stateCount[0] = 0;
stateCount[1] = 0;
stateCount[2] = 0;
stateCount[3] = 0;
stateCount[4] = 0;
var currentState = 0;
for (var j = 0; j < maxJ; j++)
{
if (image[j+i*qrcode.width] )
{
// Black pixel
if ((currentState & 1) == 1)
{
// Counting white pixels
currentState++;
}
stateCount[currentState]++;
}
else
{
// White pixel
if ((currentState & 1) == 0)
{
// Counting black pixels
if (currentState == 4)
{
// A winner?
if (this.foundPatternCross(stateCount))
{
// Yes
var confirmed = this.handlePossibleCenter(stateCount, i, j);
if (confirmed)
{
// Start examining every other line. Checking each line turned out to be too
// expensive and didn't improve performance.
iSkip = 2;
if (this.hasSkipped)
{
done = this.haveMultiplyConfirmedCenters();
}
else
{
var rowSkip = this.findRowSkip();
if (rowSkip > stateCount[2])
{
// Skip rows between row of lower confirmed center
// and top of presumed third confirmed center
// but back up a bit to get a full chance of detecting
// it, entire width of center of finder pattern
// Skip by rowSkip, but back off by stateCount[2] (size of last center
// of pattern we saw) to be conservative, and also back off by iSkip which
// is about to be re-added
i += rowSkip - stateCount[2] - iSkip;
j = maxJ - 1;
}
}
}
else
{
// Advance to next black pixel
do
{
j++;
}
while (j < maxJ && !image[j + i*qrcode.width]);
j--; // back up to that last white pixel
}
// Clear state to start looking again
currentState = 0;
stateCount[0] = 0;
stateCount[1] = 0;
stateCount[2] = 0;
stateCount[3] = 0;
stateCount[4] = 0;
}
else
{
// No, shift counts back by two
stateCount[0] = stateCount[2];
stateCount[1] = stateCount[3];
stateCount[2] = stateCount[4];
stateCount[3] = 1;
stateCount[4] = 0;
currentState = 3;
}
}
else
{
stateCount[++currentState]++;
}
}
else
{
// Counting white pixels
stateCount[currentState]++;
}
}
}
if (this.foundPatternCross(stateCount))
{
var confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
if (confirmed)
{
iSkip = stateCount[0];
if (this.hasSkipped)
{
// Found a third one
done = haveMultiplyConfirmedCenters();
}
}
}
}
var patternInfo = this.selectBestPatterns();
qrcode.orderBestPatterns(patternInfo);
return new FinderPatternInfo(patternInfo);
};
}

110
js/jsqrcode/formatinf.js Normal file
View file

@ -0,0 +1,110 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var FORMAT_INFO_MASK_QR = 0x5412;
var FORMAT_INFO_DECODE_LOOKUP = new Array(new Array(0x5412, 0x00), new Array(0x5125, 0x01), new Array(0x5E7C, 0x02), new Array(0x5B4B, 0x03), new Array(0x45F9, 0x04), new Array(0x40CE, 0x05), new Array(0x4F97, 0x06), new Array(0x4AA0, 0x07), new Array(0x77C4, 0x08), new Array(0x72F3, 0x09), new Array(0x7DAA, 0x0A), new Array(0x789D, 0x0B), new Array(0x662F, 0x0C), new Array(0x6318, 0x0D), new Array(0x6C41, 0x0E), new Array(0x6976, 0x0F), new Array(0x1689, 0x10), new Array(0x13BE, 0x11), new Array(0x1CE7, 0x12), new Array(0x19D0, 0x13), new Array(0x0762, 0x14), new Array(0x0255, 0x15), new Array(0x0D0C, 0x16), new Array(0x083B, 0x17), new Array(0x355F, 0x18), new Array(0x3068, 0x19), new Array(0x3F31, 0x1A), new Array(0x3A06, 0x1B), new Array(0x24B4, 0x1C), new Array(0x2183, 0x1D), new Array(0x2EDA, 0x1E), new Array(0x2BED, 0x1F));
var BITS_SET_IN_HALF_BYTE = new Array(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
function FormatInformation(formatInfo)
{
this.errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03);
this.dataMask = (formatInfo & 0x07);
Object.defineProperties(this, {
'ErrorCorrectionLevel': {
get: function () {
return this.errorCorrectionLevel;
}
},
'DataMask': {
get: function () {
return this.dataMask;
}
}
});
this.GetHashCode=function()
{
return (this.errorCorrectionLevel.ordinal() << 3) | dataMask;
}
this.Equals=function( o)
{
var other = o;
return this.errorCorrectionLevel == other.errorCorrectionLevel && this.dataMask == other.dataMask;
}
}
FormatInformation.numBitsDiffering=function( a, b)
{
a ^= b; // a now has a 1 bit exactly where its bit differs with b's
// Count bits set quickly with a series of lookups:
return BITS_SET_IN_HALF_BYTE[a & 0x0F] + BITS_SET_IN_HALF_BYTE[(URShift(a, 4) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 8) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 12) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 16) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 20) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 24) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 28) & 0x0F)];
}
FormatInformation.decodeFormatInformation=function( maskedFormatInfo)
{
var formatInfo = FormatInformation.doDecodeFormatInformation(maskedFormatInfo);
if (formatInfo != null)
{
return formatInfo;
}
// Should return null, but, some QR codes apparently
// do not mask this info. Try again by actually masking the pattern
// first
return FormatInformation.doDecodeFormatInformation(maskedFormatInfo ^ FORMAT_INFO_MASK_QR);
}
FormatInformation.doDecodeFormatInformation=function( maskedFormatInfo)
{
// Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing
var bestDifference = 0xffffffff;
var bestFormatInfo = 0;
for (var i = 0; i < FORMAT_INFO_DECODE_LOOKUP.length; i++)
{
var decodeInfo = FORMAT_INFO_DECODE_LOOKUP[i];
var targetInfo = decodeInfo[0];
if (targetInfo == maskedFormatInfo)
{
// Found an exact match
return new FormatInformation(decodeInfo[1]);
}
var bitsDifference = this.numBitsDiffering(maskedFormatInfo, targetInfo);
if (bitsDifference < bestDifference)
{
bestFormatInfo = decodeInfo[1];
bestDifference = bitsDifference;
}
}
// Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits
// differing means we found a match
if (bestDifference <= 3)
{
return new FormatInformation(bestFormatInfo);
}
return null;
}

123
js/jsqrcode/gf256.js Normal file
View file

@ -0,0 +1,123 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function GF256( primitive)
{
this.expTable = new Array(256);
this.logTable = new Array(256);
var x = 1;
for (var i = 0; i < 256; i++)
{
this.expTable[i] = x;
x <<= 1; // x = x * 2; we're assuming the generator alpha is 2
if (x >= 0x100)
{
x ^= primitive;
}
}
for (var i = 0; i < 255; i++)
{
this.logTable[this.expTable[i]] = i;
}
// logTable[0] == 0 but this should never be used
var at0=new Array(1);at0[0]=0;
this.zero = new GF256Poly(this, new Array(at0));
var at1=new Array(1);at1[0]=1;
this.one = new GF256Poly(this, new Array(at1));
Object.defineProperties(this, {
'Zero': {
get: function () {
return this.zero;
}
},
'One': {
get: function () {
return this.one;
}
}
});
this.buildMonomial=function( degree, coefficient)
{
if (degree < 0)
{
throw "System.ArgumentException";
}
if (coefficient == 0)
{
return zero;
}
var coefficients = new Array(degree + 1);
for(var i=0;i<coefficients.length;i++)coefficients[i]=0;
coefficients[0] = coefficient;
return new GF256Poly(this, coefficients);
}
this.exp=function( a)
{
return this.expTable[a];
}
this.log=function( a)
{
if (a == 0)
{
throw "System.ArgumentException";
}
return this.logTable[a];
}
this.inverse=function( a)
{
if (a == 0)
{
throw "System.ArithmeticException";
}
return this.expTable[255 - this.logTable[a]];
}
this.multiply=function( a, b)
{
if (a == 0 || b == 0)
{
return 0;
}
if (a == 1)
{
return b;
}
if (b == 1)
{
return a;
}
return this.expTable[(this.logTable[a] + this.logTable[b]) % 255];
}
}
GF256.QR_CODE_FIELD = new GF256(0x011D);
GF256.DATA_MATRIX_FIELD = new GF256(0x012D);
GF256.addOrSubtract=function( a, b)
{
return a ^ b;
}

237
js/jsqrcode/gf256poly.js Normal file
View file

@ -0,0 +1,237 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function GF256Poly(field, coefficients)
{
if (coefficients == null || coefficients.length == 0)
{
throw "System.ArgumentException";
}
this.field = field;
var coefficientsLength = coefficients.length;
if (coefficientsLength > 1 && coefficients[0] == 0)
{
// Leading term must be non-zero for anything except the constant polynomial "0"
var firstNonZero = 1;
while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0)
{
firstNonZero++;
}
if (firstNonZero == coefficientsLength)
{
this.coefficients = field.Zero.coefficients;
}
else
{
this.coefficients = new Array(coefficientsLength - firstNonZero);
for(var i=0;i<this.coefficients.length;i++)this.coefficients[i]=0;
//Array.Copy(coefficients, firstNonZero, this.coefficients, 0, this.coefficients.length);
for(var ci=0;ci<this.coefficients.length;ci++)this.coefficients[ci]=coefficients[firstNonZero+ci];
}
}
else
{
this.coefficients = coefficients;
}
Object.defineProperties(this, {
"Zero": {
get: function () {
return this.coefficients[0] == 0;
}
},
"Degree": {
get: function () {
return this.coefficients.length - 1;
}
},
"Coefficients": {
get: function () {
return this.coefficients;
}
}
});
this.getCoefficient=function( degree)
{
return this.coefficients[this.coefficients.length - 1 - degree];
}
this.evaluateAt=function( a)
{
if (a == 0)
{
// Just return the x^0 coefficient
return this.getCoefficient(0);
}
var size = this.coefficients.length;
if (a == 1)
{
// Just the sum of the coefficients
var result = 0;
for (var i = 0; i < size; i++)
{
result = GF256.addOrSubtract(result, this.coefficients[i]);
}
return result;
}
var result2 = this.coefficients[0];
for (var i = 1; i < size; i++)
{
result2 = GF256.addOrSubtract(this.field.multiply(a, result2), this.coefficients[i]);
}
return result2;
}
this.addOrSubtract=function( other)
{
if (this.field != other.field)
{
throw "GF256Polys do not have same GF256 field";
}
if (this.Zero)
{
return other;
}
if (other.Zero)
{
return this;
}
var smallerCoefficients = this.coefficients;
var largerCoefficients = other.coefficients;
if (smallerCoefficients.length > largerCoefficients.length)
{
var temp = smallerCoefficients;
smallerCoefficients = largerCoefficients;
largerCoefficients = temp;
}
var sumDiff = new Array(largerCoefficients.length);
var lengthDiff = largerCoefficients.length - smallerCoefficients.length;
// Copy high-order terms only found in higher-degree polynomial's coefficients
//Array.Copy(largerCoefficients, 0, sumDiff, 0, lengthDiff);
for(var ci=0;ci<lengthDiff;ci++)sumDiff[ci]=largerCoefficients[ci];
for (var i = lengthDiff; i < largerCoefficients.length; i++)
{
sumDiff[i] = GF256.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]);
}
return new GF256Poly(field, sumDiff);
}
this.multiply1=function( other)
{
if (this.field!=other.field)
{
throw "GF256Polys do not have same GF256 field";
}
if (this.Zero || other.Zero)
{
return this.field.Zero;
}
var aCoefficients = this.coefficients;
var aLength = aCoefficients.length;
var bCoefficients = other.coefficients;
var bLength = bCoefficients.length;
var product = new Array(aLength + bLength - 1);
for (var i = 0; i < aLength; i++)
{
var aCoeff = aCoefficients[i];
for (var j = 0; j < bLength; j++)
{
product[i + j] = GF256.addOrSubtract(product[i + j], this.field.multiply(aCoeff, bCoefficients[j]));
}
}
return new GF256Poly(this.field, product);
}
this.multiply2=function( scalar)
{
if (scalar == 0)
{
return this.field.Zero;
}
if (scalar == 1)
{
return this;
}
var size = this.coefficients.length;
var product = new Array(size);
for (var i = 0; i < size; i++)
{
product[i] = this.field.multiply(this.coefficients[i], scalar);
}
return new GF256Poly(this.field, product);
}
this.multiplyByMonomial=function( degree, coefficient)
{
if (degree < 0)
{
throw "System.ArgumentException";
}
if (coefficient == 0)
{
return this.field.Zero;
}
var size = this.coefficients.length;
var product = new Array(size + degree);
for(var i=0;i<product.length;i++)product[i]=0;
for (var i = 0; i < size; i++)
{
product[i] = this.field.multiply(this.coefficients[i], coefficient);
}
return new GF256Poly(this.field, product);
}
this.divide=function( other)
{
if (this.field!=other.field)
{
throw "GF256Polys do not have same GF256 field";
}
if (other.Zero)
{
throw "Divide by 0";
}
var quotient = this.field.Zero;
var remainder = this;
var denominatorLeadingTerm = other.getCoefficient(other.Degree);
var inverseDenominatorLeadingTerm = this.field.inverse(denominatorLeadingTerm);
while (remainder.Degree >= other.Degree && !remainder.Zero)
{
var degreeDifference = remainder.Degree - other.Degree;
var scale = this.field.multiply(remainder.getCoefficient(remainder.Degree), inverseDenominatorLeadingTerm);
var term = other.multiplyByMonomial(degreeDifference, scale);
var iterationQuotient = this.field.buildMonomial(degreeDifference, scale);
quotient = quotient.addOrSubtract(iterationQuotient);
remainder = remainder.addOrSubtract(term);
}
return new Array(quotient, remainder);
}
}

152
js/jsqrcode/grid.js Normal file
View file

@ -0,0 +1,152 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
GridSampler = {};
GridSampler.checkAndNudgePoints=function( image, points)
{
var width = qrcode.width;
var height = qrcode.height;
// Check and nudge points from start until we see some that are OK:
var nudged = true;
for (var offset = 0; offset < points.length && nudged; offset += 2)
{
var x = Math.floor (points[offset]);
var y = Math.floor( points[offset + 1]);
if (x < - 1 || x > width || y < - 1 || y > height)
{
throw "Error.checkAndNudgePoints ";
}
nudged = false;
if (x == - 1)
{
points[offset] = 0.0;
nudged = true;
}
else if (x == width)
{
points[offset] = width - 1;
nudged = true;
}
if (y == - 1)
{
points[offset + 1] = 0.0;
nudged = true;
}
else if (y == height)
{
points[offset + 1] = height - 1;
nudged = true;
}
}
// Check and nudge points from end:
nudged = true;
for (var offset = points.length - 2; offset >= 0 && nudged; offset -= 2)
{
var x = Math.floor( points[offset]);
var y = Math.floor( points[offset + 1]);
if (x < - 1 || x > width || y < - 1 || y > height)
{
throw "Error.checkAndNudgePoints ";
}
nudged = false;
if (x == - 1)
{
points[offset] = 0.0;
nudged = true;
}
else if (x == width)
{
points[offset] = width - 1;
nudged = true;
}
if (y == - 1)
{
points[offset + 1] = 0.0;
nudged = true;
}
else if (y == height)
{
points[offset + 1] = height - 1;
nudged = true;
}
}
}
GridSampler.sampleGrid3=function( image, dimension, transform)
{
var bits = new BitMatrix(dimension);
var points = new Array(dimension << 1);
for (var y = 0; y < dimension; y++)
{
var max = points.length;
var iValue = y + 0.5;
for (var x = 0; x < max; x += 2)
{
points[x] = (x >> 1) + 0.5;
points[x + 1] = iValue;
}
transform.transformPoints1(points);
// Quick check to see if points transformed to something inside the image;
// sufficient to check the endpoints
GridSampler.checkAndNudgePoints(image, points);
try
{
for (var x = 0; x < max; x += 2)
{
var xpoint = (Math.floor( points[x]) * 4) + (Math.floor( points[x + 1]) * qrcode.width * 4);
var bit = image[Math.floor( points[x])+ qrcode.width* Math.floor( points[x + 1])];
qrcode.imagedata.data[xpoint] = bit?255:0;
qrcode.imagedata.data[xpoint+1] = bit?255:0;
qrcode.imagedata.data[xpoint+2] = 0;
qrcode.imagedata.data[xpoint+3] = 255;
//bits[x >> 1][ y]=bit;
if(bit)
bits.set_Renamed(x >> 1, y);
}
}
catch ( aioobe)
{
// This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting
// transform gets "twisted" such that it maps a straight line of points to a set of points
// whose endpoints are in bounds, but others are not. There is probably some mathematical
// way to detect this about the transformation that I don't know yet.
// This results in an ugly runtime exception despite our clever checks above -- can't have
// that. We could check each point's coordinates but that feels duplicative. We settle for
// catching and wrapping ArrayIndexOutOfBoundsException.
throw "Error.checkAndNudgePoints";
}
}
return bits;
}
GridSampler.sampleGridx=function( image, dimension, p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY)
{
var transform = PerspectiveTransform.quadrilateralToQuadrilateral(p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY);
return GridSampler.sampleGrid3(image, dimension, transform);
}

322
js/jsqrcode/qrcode.js Normal file
View file

@ -0,0 +1,322 @@
/*
Copyright 2011 Lazar Laszlo (lazarsoft@gmail.com, www.lazarsoft.info)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
qrcode = {};
qrcode.imagedata = null;
qrcode.width = 0;
qrcode.height = 0;
qrcode.qrCodeSymbol = null;
qrcode.debug = false;
qrcode.maxImgSize = 1024*1024;
qrcode.sizeOfDataLengthInfo = [ [ 10, 9, 8, 8 ], [ 12, 11, 16, 10 ], [ 14, 13, 16, 12 ] ];
qrcode.callback = null;
qrcode.decode = function(src){
if(arguments.length==0)
{
var canvas_qr = document.getElementById("qr-canvas");
var context = canvas_qr.getContext('2d');
qrcode.width = canvas_qr.width;
qrcode.height = canvas_qr.height;
qrcode.imagedata = context.getImageData(0, 0, qrcode.width, qrcode.height);
qrcode.result = qrcode.process(context);
if(qrcode.callback!=null)
qrcode.callback(qrcode.result);
return qrcode.result;
}
else
{
var image = new Image();
image.crossOrigin = "Anonymous";
image.onload=function(){
//var canvas_qr = document.getElementById("qr-canvas");
var canvas_qr = document.createElement('canvas');
var context = canvas_qr.getContext('2d');
var nheight = image.height;
var nwidth = image.width;
if(image.width*image.height>qrcode.maxImgSize)
{
var ir = image.width / image.height;
nheight = Math.sqrt(qrcode.maxImgSize/ir);
nwidth=ir*nheight;
}
canvas_qr.width = nwidth;
canvas_qr.height = nheight;
context.drawImage(image, 0, 0, canvas_qr.width, canvas_qr.height );
qrcode.width = canvas_qr.width;
qrcode.height = canvas_qr.height;
try{
qrcode.imagedata = context.getImageData(0, 0, canvas_qr.width, canvas_qr.height);
}catch(e){
qrcode.result = "Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!";
if(qrcode.callback!=null)
qrcode.callback(qrcode.result);
return;
}
try
{
qrcode.result = qrcode.process(context);
}
catch(e)
{
console.log(e);
qrcode.result = "error decoding QR Code";
}
if(qrcode.callback!=null)
qrcode.callback(qrcode.result);
}
image.src = src;
}
}
qrcode.isUrl = function(s)
{
var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
return regexp.test(s);
}
qrcode.decode_url = function (s)
{
var escaped = "";
try{
escaped = escape( s );
}
catch(e)
{
console.log(e);
escaped = s;
}
var ret = "";
try{
ret = decodeURIComponent( escaped );
}
catch(e)
{
console.log(e);
ret = escaped;
}
return ret;
}
qrcode.decode_utf8 = function ( s )
{
if(qrcode.isUrl(s))
return qrcode.decode_url(s);
else
return s;
}
qrcode.process = function(ctx){
var start = new Date().getTime();
var image = qrcode.grayScaleToBitmap(qrcode.grayscale());
//var image = qrcode.binarize(128);
if(qrcode.debug)
{
for (var y = 0; y < qrcode.height; y++)
{
for (var x = 0; x < qrcode.width; x++)
{
var point = (x * 4) + (y * qrcode.width * 4);
qrcode.imagedata.data[point] = image[x+y*qrcode.width]?0:0;
qrcode.imagedata.data[point+1] = image[x+y*qrcode.width]?0:0;
qrcode.imagedata.data[point+2] = image[x+y*qrcode.width]?255:0;
}
}
ctx.putImageData(qrcode.imagedata, 0, 0);
}
//var finderPatternInfo = new FinderPatternFinder().findFinderPattern(image);
var detector = new Detector(image);
var qRCodeMatrix = detector.detect();
/*for (var y = 0; y < qRCodeMatrix.bits.Height; y++)
{
for (var x = 0; x < qRCodeMatrix.bits.Width; x++)
{
var point = (x * 4*2) + (y*2 * qrcode.width * 4);
qrcode.imagedata.data[point] = qRCodeMatrix.bits.get_Renamed(x,y)?0:0;
qrcode.imagedata.data[point+1] = qRCodeMatrix.bits.get_Renamed(x,y)?0:0;
qrcode.imagedata.data[point+2] = qRCodeMatrix.bits.get_Renamed(x,y)?255:0;
}
}*/
if(qrcode.debug)
ctx.putImageData(qrcode.imagedata, 0, 0);
console.log(qRCodeMatrix);
var reader = Decoder.decode(qRCodeMatrix.bits);
var data = reader.DataByte;
var str="";
for(var i=0;i<data.length;i++)
{
for(var j=0;j<data[i].length;j++)
str+=String.fromCharCode(data[i][j]);
}
var end = new Date().getTime();
var time = end - start;
console.log(time);
return qrcode.decode_utf8(str);
//alert("Time:" + time + " Code: "+str);
}
qrcode.getPixel = function(x,y){
if (qrcode.width < x) {
throw "point error";
}
if (qrcode.height < y) {
throw "point error";
}
point = (x * 4) + (y * qrcode.width * 4);
p = (qrcode.imagedata.data[point]*33 + qrcode.imagedata.data[point + 1]*34 + qrcode.imagedata.data[point + 2]*33)/100;
return p;
}
qrcode.binarize = function(th){
var ret = new Array(qrcode.width*qrcode.height);
for (var y = 0; y < qrcode.height; y++)
{
for (var x = 0; x < qrcode.width; x++)
{
var gray = qrcode.getPixel(x, y);
ret[x+y*qrcode.width] = gray<=th?true:false;
}
}
return ret;
}
qrcode.getMiddleBrightnessPerArea=function(image)
{
var numSqrtArea = 4;
//obtain middle brightness((min + max) / 2) per area
var areaWidth = Math.floor(qrcode.width / numSqrtArea);
var areaHeight = Math.floor(qrcode.height / numSqrtArea);
var minmax = new Array(numSqrtArea);
for (var i = 0; i < numSqrtArea; i++)
{
minmax[i] = new Array(numSqrtArea);
for (var i2 = 0; i2 < numSqrtArea; i2++)
{
minmax[i][i2] = new Array(0,0);
}
}
for (var ay = 0; ay < numSqrtArea; ay++)
{
for (var ax = 0; ax < numSqrtArea; ax++)
{
minmax[ax][ay][0] = 0xFF;
for (var dy = 0; dy < areaHeight; dy++)
{
for (var dx = 0; dx < areaWidth; dx++)
{
var target = image[areaWidth * ax + dx+(areaHeight * ay + dy)*qrcode.width];
if (target < minmax[ax][ay][0])
minmax[ax][ay][0] = target;
if (target > minmax[ax][ay][1])
minmax[ax][ay][1] = target;
}
}
//minmax[ax][ay][0] = (minmax[ax][ay][0] + minmax[ax][ay][1]) / 2;
}
}
var middle = new Array(numSqrtArea);
for (var i3 = 0; i3 < numSqrtArea; i3++)
{
middle[i3] = new Array(numSqrtArea);
}
for (var ay = 0; ay < numSqrtArea; ay++)
{
for (var ax = 0; ax < numSqrtArea; ax++)
{
middle[ax][ay] = Math.floor((minmax[ax][ay][0] + minmax[ax][ay][1]) / 2);
//Console.out.print(middle[ax][ay] + ",");
}
//Console.out.println("");
}
//Console.out.println("");
return middle;
}
qrcode.grayScaleToBitmap=function(grayScale)
{
var middle = qrcode.getMiddleBrightnessPerArea(grayScale);
var sqrtNumArea = middle.length;
var areaWidth = Math.floor(qrcode.width / sqrtNumArea);
var areaHeight = Math.floor(qrcode.height / sqrtNumArea);
var bitmap = new Array(qrcode.height*qrcode.width);
for (var ay = 0; ay < sqrtNumArea; ay++)
{
for (var ax = 0; ax < sqrtNumArea; ax++)
{
for (var dy = 0; dy < areaHeight; dy++)
{
for (var dx = 0; dx < areaWidth; dx++)
{
bitmap[areaWidth * ax + dx+ (areaHeight * ay + dy)*qrcode.width] = (grayScale[areaWidth * ax + dx+ (areaHeight * ay + dy)*qrcode.width] < middle[ax][ay])?true:false;
}
}
}
}
return bitmap;
}
qrcode.grayscale = function(){
var ret = new Array(qrcode.width*qrcode.height);
for (var y = 0; y < qrcode.height; y++)
{
for (var x = 0; x < qrcode.width; x++)
{
var gray = qrcode.getPixel(x, y);
ret[x+y*qrcode.width] = gray;
}
}
return ret;
}
function URShift( number, bits)
{
if (number >= 0)
return number >> bits;
else
return (number >> bits) + (2 << ~bits);
}
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};

178
js/jsqrcode/rsdecoder.js Normal file
View file

@ -0,0 +1,178 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function ReedSolomonDecoder(field)
{
this.field = field;
this.decode=function(received, twoS)
{
var poly = new GF256Poly(this.field, received);
var syndromeCoefficients = new Array(twoS);
for(var i=0;i<syndromeCoefficients.length;i++)syndromeCoefficients[i]=0;
var dataMatrix = false;//this.field.Equals(GF256.DATA_MATRIX_FIELD);
var noError = true;
for (var i = 0; i < twoS; i++)
{
// Thanks to sanfordsquires for this fix:
var eval = poly.evaluateAt(this.field.exp(dataMatrix?i + 1:i));
syndromeCoefficients[syndromeCoefficients.length - 1 - i] = eval;
if (eval != 0)
{
noError = false;
}
}
if (noError)
{
return ;
}
var syndrome = new GF256Poly(this.field, syndromeCoefficients);
var sigmaOmega = this.runEuclideanAlgorithm(this.field.buildMonomial(twoS, 1), syndrome, twoS);
var sigma = sigmaOmega[0];
var omega = sigmaOmega[1];
var errorLocations = this.findErrorLocations(sigma);
var errorMagnitudes = this.findErrorMagnitudes(omega, errorLocations, dataMatrix);
for (var i = 0; i < errorLocations.length; i++)
{
var position = received.length - 1 - this.field.log(errorLocations[i]);
if (position < 0)
{
throw "ReedSolomonException Bad error location";
}
received[position] = GF256.addOrSubtract(received[position], errorMagnitudes[i]);
}
}
this.runEuclideanAlgorithm=function( a, b, R)
{
// Assume a's degree is >= b's
if (a.Degree < b.Degree)
{
var temp = a;
a = b;
b = temp;
}
var rLast = a;
var r = b;
var sLast = this.field.One;
var s = this.field.Zero;
var tLast = this.field.Zero;
var t = this.field.One;
// Run Euclidean algorithm until r's degree is less than R/2
while (r.Degree >= Math.floor(R / 2))
{
var rLastLast = rLast;
var sLastLast = sLast;
var tLastLast = tLast;
rLast = r;
sLast = s;
tLast = t;
// Divide rLastLast by rLast, with quotient in q and remainder in r
if (rLast.Zero)
{
// Oops, Euclidean algorithm already terminated?
throw "r_{i-1} was zero";
}
r = rLastLast;
var q = this.field.Zero;
var denominatorLeadingTerm = rLast.getCoefficient(rLast.Degree);
var dltInverse = this.field.inverse(denominatorLeadingTerm);
while (r.Degree >= rLast.Degree && !r.Zero)
{
var degreeDiff = r.Degree - rLast.Degree;
var scale = this.field.multiply(r.getCoefficient(r.Degree), dltInverse);
q = q.addOrSubtract(this.field.buildMonomial(degreeDiff, scale));
r = r.addOrSubtract(rLast.multiplyByMonomial(degreeDiff, scale));
//r.EXE();
}
s = q.multiply1(sLast).addOrSubtract(sLastLast);
t = q.multiply1(tLast).addOrSubtract(tLastLast);
}
var sigmaTildeAtZero = t.getCoefficient(0);
if (sigmaTildeAtZero == 0)
{
throw "ReedSolomonException sigmaTilde(0) was zero";
}
var inverse = this.field.inverse(sigmaTildeAtZero);
var sigma = t.multiply2(inverse);
var omega = r.multiply2(inverse);
return new Array(sigma, omega);
}
this.findErrorLocations=function( errorLocator)
{
// This is a direct application of Chien's search
var numErrors = errorLocator.Degree;
if (numErrors == 1)
{
// shortcut
return new Array(errorLocator.getCoefficient(1));
}
var result = new Array(numErrors);
var e = 0;
for (var i = 1; i < 256 && e < numErrors; i++)
{
if (errorLocator.evaluateAt(i) == 0)
{
result[e] = this.field.inverse(i);
e++;
}
}
if (e != numErrors)
{
throw "Error locator degree does not match number of roots";
}
return result;
}
this.findErrorMagnitudes=function( errorEvaluator, errorLocations, dataMatrix)
{
// This is directly applying Forney's Formula
var s = errorLocations.length;
var result = new Array(s);
for (var i = 0; i < s; i++)
{
var xiInverse = this.field.inverse(errorLocations[i]);
var denominator = 1;
for (var j = 0; j < s; j++)
{
if (i != j)
{
denominator = this.field.multiply(denominator, GF256.addOrSubtract(1, this.field.multiply(errorLocations[j], xiInverse)));
}
}
result[i] = this.field.multiply(errorEvaluator.evaluateAt(xiInverse), this.field.inverse(denominator));
// Thanks to sanfordsquires for this fix:
if (dataMatrix)
{
result[i] = this.field.multiply(result[i], xiInverse);
}
}
return result;
}
}

149
js/jsqrcode/test.html Normal file
View file

@ -0,0 +1,149 @@
<html>
<head>
<title>QRCODE</title>
<style type="text/css">
</style>
<script type="text/javascript" src="grid.js"></script>
<script type="text/javascript" src="version.js"></script>
<script type="text/javascript" src="detector.js"></script>
<script type="text/javascript" src="formatinf.js"></script>
<script type="text/javascript" src="errorlevel.js"></script>
<script type="text/javascript" src="bitmat.js"></script>
<script type="text/javascript" src="datablock.js"></script>
<script type="text/javascript" src="bmparser.js"></script>
<script type="text/javascript" src="datamask.js"></script>
<script type="text/javascript" src="rsdecoder.js"></script>
<script type="text/javascript" src="gf256poly.js"></script>
<script type="text/javascript" src="gf256.js"></script>
<script type="text/javascript" src="decoder.js"></script>
<script type="text/javascript" src="qrcode.js"></script>
<script type="text/javascript" src="findpat.js"></script>
<script type="text/javascript" src="alignpat.js"></script>
<script type="text/javascript" src="databr.js"></script>
<script type="text/javascript">
var gCtx = null;
var gCanvas = null;
var imageData = null;
var ii=0;
var jj=0;
var c=0;
function dragenter(e) {
e.stopPropagation();
e.preventDefault();
}
function dragover(e) {
e.stopPropagation();
e.preventDefault();
}
function drop(e) {
e.stopPropagation();
e.preventDefault();
var dt = e.dataTransfer;
var files = dt.files;
handleFiles(files);
}
function handleFiles(f)
{
var o=[];
for(var i =0;i<f.length;i++)
{
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
qrcode.decode(e.target.result);
};
})(f[i]);
// Read in the image file as a data URL.
reader.readAsDataURL(f[i]); }
}
function read(a)
{
alert(a);
}
function load()
{
initCanvas(640,480);
qrcode.callback = read;
qrcode.decode("meqrthumb.png");
}
function initCanvas(ww,hh)
{
gCanvas = document.getElementById("qr-canvas");
gCanvas.addEventListener("dragenter", dragenter, false);
gCanvas.addEventListener("dragover", dragover, false);
gCanvas.addEventListener("drop", drop, false);
var w = ww;
var h = hh;
gCanvas.style.width = w + "px";
gCanvas.style.height = h + "px";
gCanvas.width = w;
gCanvas.height = h;
gCtx = gCanvas.getContext("2d");
gCtx.clearRect(0, 0, w, h);
imageData = gCtx.getImageData( 0,0,320,240);
}
function passLine(stringPixels) {
//a = (intVal >> 24) & 0xff;
var coll = stringPixels.split("-");
for(var i=0;i<320;i++) {
var intVal = parseInt(coll[i]);
r = (intVal >> 16) & 0xff;
g = (intVal >> 8) & 0xff;
b = (intVal ) & 0xff;
imageData.data[c+0]=r;
imageData.data[c+1]=g;
imageData.data[c+2]=b;
imageData.data[c+3]=255;
c+=4;
}
if(c>=320*240*4) {
c=0;
gCtx.putImageData(imageData, 0,0);
}
}
function captureToCanvas() {
flash = document.getElementById("embedflash");
flash.ccCapture();
qrcode.decode();
}
</script>
</head>
<body onload="load()">
<div class="container">
<object id="iembedflash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="320" height="240">
<param name="movie" value="camcanvas.swf" />
<param name="quality" value="high" />
<param name="allowScriptAccess" value="always" />
<embed allowScriptAccess="always" id="embedflash" src="camcanvas.swf" quality="high" width="320" height="240" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" mayscript="true" />
</object>
</div>
<button onclick="captureToCanvas()">Capture</button><br>
<canvas id="qr-canvas" width="640" height="480"></canvas>
</body>
</html>

278
js/jsqrcode/version.js Normal file
View file

@ -0,0 +1,278 @@
/*
Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info
*/
/*
*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function ECB(count, dataCodewords)
{
this.count = count;
this.dataCodewords = dataCodewords;
Object.defineProperties(this, {
'Count': {
get: function () {
return this.count;
}
},
'DataCodewords': {
get: function () {
return this.dataCodewords;
}
}
});
}
function ECBlocks( ecCodewordsPerBlock, ecBlocks1, ecBlocks2)
{
this.ecCodewordsPerBlock = ecCodewordsPerBlock;
if (ecBlocks2)
this.ecBlocks = new Array(ecBlocks1, ecBlocks2);
else
this.ecBlocks = new Array(ecBlocks1);
Object.defineProperties(this, {
"ECCodewordsPerBlock": {
get: function () {
return this.ecCodewordsPerBlock;
}
},
"TotalECCodewords": {
get: function () {
return this.ecCodewordsPerBlock * this.NumBlocks;
}
},
"NumBlocks": {
get: function () {
var total = 0;
for (var i = 0; i < this.ecBlocks.length; i++)
total += this.ecBlocks[i].length;
return total;
}
}
});
this.getECBlocks = function() {
return this.ecBlocks;
};
}
function Version( versionNumber, alignmentPatternCenters, ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4)
{
this.versionNumber = versionNumber;
this.alignmentPatternCenters = alignmentPatternCenters;
this.ecBlocks = new Array(ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4);
var total = 0;
var ecCodewords = ecBlocks1.ECCodewordsPerBlock;
var ecbArray = ecBlocks1.getECBlocks();
for (var i = 0; i < ecbArray.length; i++)
{
var ecBlock = ecbArray[i];
total += ecBlock.Count * (ecBlock.DataCodewords + ecCodewords);
}
this.totalCodewords = total;
Object.defineProperties(this, {
"VersionNumber": {
get: function () {
return this.versionNumber;
}
},
"AlignmentPatternCenters": {
get: function () {
return this.alignmentPatternCenters;
}
},
"TotalCodewords": {
get: function () {
return this.totalCodewords;
}
},
"DimensionForVersion": {
get: function () {
return 17 + 4 * this.versionNumber;
}
}
});
this.buildFunctionPattern=function()
{
var dimension = this.DimensionForVersion;
var bitMatrix = new BitMatrix(dimension);
// Top left finder pattern + separator + format
bitMatrix.setRegion(0, 0, 9, 9);
// Top right finder pattern + separator + format
bitMatrix.setRegion(dimension - 8, 0, 8, 9);
// Bottom left finder pattern + separator + format
bitMatrix.setRegion(0, dimension - 8, 9, 8);
// Alignment patterns
var max = this.alignmentPatternCenters.length;
for (var x = 0; x < max; x++)
{
var i = this.alignmentPatternCenters[x] - 2;
for (var y = 0; y < max; y++)
{
if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0))
{
// No alignment patterns near the three finder paterns
continue;
}
bitMatrix.setRegion(this.alignmentPatternCenters[y] - 2, i, 5, 5);
}
}
// Vertical timing pattern
bitMatrix.setRegion(6, 9, 1, dimension - 17);
// Horizontal timing pattern
bitMatrix.setRegion(9, 6, dimension - 17, 1);
if (this.versionNumber > 6)
{
// Version info, top right
bitMatrix.setRegion(dimension - 11, 0, 3, 6);
// Version info, bottom left
bitMatrix.setRegion(0, dimension - 11, 6, 3);
}
return bitMatrix;
}
this.getECBlocksForLevel=function( ecLevel)
{
return this.ecBlocks[ecLevel.ordinal()];
}
}
Version.VERSION_DECODE_INFO = new Array(0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, 0x2542E, 0x26A64, 0x27541, 0x28C69);
Version.VERSIONS = buildVersions();
Version.getVersionForNumber=function( versionNumber)
{
if (versionNumber < 1 || versionNumber > 40)
{
throw "ArgumentException";
}
return Version.VERSIONS[versionNumber - 1];
}
Version.getProvisionalVersionForDimension=function(dimension)
{
if (dimension % 4 != 1)
{
throw "Error getProvisionalVersionForDimension";
}
try
{
return Version.getVersionForNumber((dimension - 17) >> 2);
}
catch ( iae)
{
throw "Error getVersionForNumber";
}
}
Version.decodeVersionInformation=function( versionBits)
{
var bestDifference = 0xffffffff;
var bestVersion = 0;
for (var i = 0; i < Version.VERSION_DECODE_INFO.length; i++)
{
var targetVersion = Version.VERSION_DECODE_INFO[i];
// Do the version info bits match exactly? done.
if (targetVersion == versionBits)
{
return this.getVersionForNumber(i + 7);
}
// Otherwise see if this is the closest to a real version info bit string
// we have seen so far
var bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion);
if (bitsDifference < bestDifference)
{
bestVersion = i + 7;
bestDifference = bitsDifference;
}
}
// We can tolerate up to 3 bits of error since no two version info codewords will
// differ in less than 4 bits.
if (bestDifference <= 3)
{
return this.getVersionForNumber(bestVersion);
}
// If we didn't find a close enough match, fail
return null;
}
function buildVersions()
{
return new Array(new Version(1, new Array(), new ECBlocks(7, new ECB(1, 19)), new ECBlocks(10, new ECB(1, 16)), new ECBlocks(13, new ECB(1, 13)), new ECBlocks(17, new ECB(1, 9))),
new Version(2, new Array(6, 18), new ECBlocks(10, new ECB(1, 34)), new ECBlocks(16, new ECB(1, 28)), new ECBlocks(22, new ECB(1, 22)), new ECBlocks(28, new ECB(1, 16))),
new Version(3, new Array(6, 22), new ECBlocks(15, new ECB(1, 55)), new ECBlocks(26, new ECB(1, 44)), new ECBlocks(18, new ECB(2, 17)), new ECBlocks(22, new ECB(2, 13))),
new Version(4, new Array(6, 26), new ECBlocks(20, new ECB(1, 80)), new ECBlocks(18, new ECB(2, 32)), new ECBlocks(26, new ECB(2, 24)), new ECBlocks(16, new ECB(4, 9))),
new Version(5, new Array(6, 30), new ECBlocks(26, new ECB(1, 108)), new ECBlocks(24, new ECB(2, 43)), new ECBlocks(18, new ECB(2, 15), new ECB(2, 16)), new ECBlocks(22, new ECB(2, 11), new ECB(2, 12))),
new Version(6, new Array(6, 34), new ECBlocks(18, new ECB(2, 68)), new ECBlocks(16, new ECB(4, 27)), new ECBlocks(24, new ECB(4, 19)), new ECBlocks(28, new ECB(4, 15))),
new Version(7, new Array(6, 22, 38), new ECBlocks(20, new ECB(2, 78)), new ECBlocks(18, new ECB(4, 31)), new ECBlocks(18, new ECB(2, 14), new ECB(4, 15)), new ECBlocks(26, new ECB(4, 13), new ECB(1, 14))),
new Version(8, new Array(6, 24, 42), new ECBlocks(24, new ECB(2, 97)), new ECBlocks(22, new ECB(2, 38), new ECB(2, 39)), new ECBlocks(22, new ECB(4, 18), new ECB(2, 19)), new ECBlocks(26, new ECB(4, 14), new ECB(2, 15))),
new Version(9, new Array(6, 26, 46), new ECBlocks(30, new ECB(2, 116)), new ECBlocks(22, new ECB(3, 36), new ECB(2, 37)), new ECBlocks(20, new ECB(4, 16), new ECB(4, 17)), new ECBlocks(24, new ECB(4, 12), new ECB(4, 13))),
new Version(10, new Array(6, 28, 50), new ECBlocks(18, new ECB(2, 68), new ECB(2, 69)), new ECBlocks(26, new ECB(4, 43), new ECB(1, 44)), new ECBlocks(24, new ECB(6, 19), new ECB(2, 20)), new ECBlocks(28, new ECB(6, 15), new ECB(2, 16))),
new Version(11, new Array(6, 30, 54), new ECBlocks(20, new ECB(4, 81)), new ECBlocks(30, new ECB(1, 50), new ECB(4, 51)), new ECBlocks(28, new ECB(4, 22), new ECB(4, 23)), new ECBlocks(24, new ECB(3, 12), new ECB(8, 13))),
new Version(12, new Array(6, 32, 58), new ECBlocks(24, new ECB(2, 92), new ECB(2, 93)), new ECBlocks(22, new ECB(6, 36), new ECB(2, 37)), new ECBlocks(26, new ECB(4, 20), new ECB(6, 21)), new ECBlocks(28, new ECB(7, 14), new ECB(4, 15))),
new Version(13, new Array(6, 34, 62), new ECBlocks(26, new ECB(4, 107)), new ECBlocks(22, new ECB(8, 37), new ECB(1, 38)), new ECBlocks(24, new ECB(8, 20), new ECB(4, 21)), new ECBlocks(22, new ECB(12, 11), new ECB(4, 12))),
new Version(14, new Array(6, 26, 46, 66), new ECBlocks(30, new ECB(3, 115), new ECB(1, 116)), new ECBlocks(24, new ECB(4, 40), new ECB(5, 41)), new ECBlocks(20, new ECB(11, 16), new ECB(5, 17)), new ECBlocks(24, new ECB(11, 12), new ECB(5, 13))),
new Version(15, new Array(6, 26, 48, 70), new ECBlocks(22, new ECB(5, 87), new ECB(1, 88)), new ECBlocks(24, new ECB(5, 41), new ECB(5, 42)), new ECBlocks(30, new ECB(5, 24), new ECB(7, 25)), new ECBlocks(24, new ECB(11, 12), new ECB(7, 13))),
new Version(16, new Array(6, 26, 50, 74), new ECBlocks(24, new ECB(5, 98), new ECB(1, 99)), new ECBlocks(28, new ECB(7, 45), new ECB(3, 46)), new ECBlocks(24, new ECB(15, 19), new ECB(2, 20)), new ECBlocks(30, new ECB(3, 15), new ECB(13, 16))),
new Version(17, new Array(6, 30, 54, 78), new ECBlocks(28, new ECB(1, 107), new ECB(5, 108)), new ECBlocks(28, new ECB(10, 46), new ECB(1, 47)), new ECBlocks(28, new ECB(1, 22), new ECB(15, 23)), new ECBlocks(28, new ECB(2, 14), new ECB(17, 15))),
new Version(18, new Array(6, 30, 56, 82), new ECBlocks(30, new ECB(5, 120), new ECB(1, 121)), new ECBlocks(26, new ECB(9, 43), new ECB(4, 44)), new ECBlocks(28, new ECB(17, 22), new ECB(1, 23)), new ECBlocks(28, new ECB(2, 14), new ECB(19, 15))),
new Version(19, new Array(6, 30, 58, 86), new ECBlocks(28, new ECB(3, 113), new ECB(4, 114)), new ECBlocks(26, new ECB(3, 44), new ECB(11, 45)), new ECBlocks(26, new ECB(17, 21), new ECB(4, 22)), new ECBlocks(26, new ECB(9, 13), new ECB(16, 14))),
new Version(20, new Array(6, 34, 62, 90), new ECBlocks(28, new ECB(3, 107), new ECB(5, 108)), new ECBlocks(26, new ECB(3, 41), new ECB(13, 42)), new ECBlocks(30, new ECB(15, 24), new ECB(5, 25)), new ECBlocks(28, new ECB(15, 15), new ECB(10, 16))),
new Version(21, new Array(6, 28, 50, 72, 94), new ECBlocks(28, new ECB(4, 116), new ECB(4, 117)), new ECBlocks(26, new ECB(17, 42)), new ECBlocks(28, new ECB(17, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(19, 16), new ECB(6, 17))),
new Version(22, new Array(6, 26, 50, 74, 98), new ECBlocks(28, new ECB(2, 111), new ECB(7, 112)), new ECBlocks(28, new ECB(17, 46)), new ECBlocks(30, new ECB(7, 24), new ECB(16, 25)), new ECBlocks(24, new ECB(34, 13))),
new Version(23, new Array(6, 30, 54, 74, 102), new ECBlocks(30, new ECB(4, 121), new ECB(5, 122)), new ECBlocks(28, new ECB(4, 47), new ECB(14, 48)), new ECBlocks(30, new ECB(11, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(16, 15), new ECB(14, 16))),
new Version(24, new Array(6, 28, 54, 80, 106), new ECBlocks(30, new ECB(6, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(6, 45), new ECB(14, 46)), new ECBlocks(30, new ECB(11, 24), new ECB(16, 25)), new ECBlocks(30, new ECB(30, 16), new ECB(2, 17))),
new Version(25, new Array(6, 32, 58, 84, 110), new ECBlocks(26, new ECB(8, 106), new ECB(4, 107)), new ECBlocks(28, new ECB(8, 47), new ECB(13, 48)), new ECBlocks(30, new ECB(7, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(22, 15), new ECB(13, 16))),
new Version(26, new Array(6, 30, 58, 86, 114), new ECBlocks(28, new ECB(10, 114), new ECB(2, 115)), new ECBlocks(28, new ECB(19, 46), new ECB(4, 47)), new ECBlocks(28, new ECB(28, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(33, 16), new ECB(4, 17))),
new Version(27, new Array(6, 34, 62, 90, 118), new ECBlocks(30, new ECB(8, 122), new ECB(4, 123)), new ECBlocks(28, new ECB(22, 45), new ECB(3, 46)), new ECBlocks(30, new ECB(8, 23), new ECB(26, 24)), new ECBlocks(30, new ECB(12, 15), new ECB(28, 16))),
new Version(28, new Array(6, 26, 50, 74, 98, 122), new ECBlocks(30, new ECB(3, 117), new ECB(10, 118)), new ECBlocks(28, new ECB(3, 45), new ECB(23, 46)), new ECBlocks(30, new ECB(4, 24), new ECB(31, 25)), new ECBlocks(30, new ECB(11, 15), new ECB(31, 16))),
new Version(29, new Array(6, 30, 54, 78, 102, 126), new ECBlocks(30, new ECB(7, 116), new ECB(7, 117)), new ECBlocks(28, new ECB(21, 45), new ECB(7, 46)), new ECBlocks(30, new ECB(1, 23), new ECB(37, 24)), new ECBlocks(30, new ECB(19, 15), new ECB(26, 16))),
new Version(30, new Array(6, 26, 52, 78, 104, 130), new ECBlocks(30, new ECB(5, 115), new ECB(10, 116)), new ECBlocks(28, new ECB(19, 47), new ECB(10, 48)), new ECBlocks(30, new ECB(15, 24), new ECB(25, 25)), new ECBlocks(30, new ECB(23, 15), new ECB(25, 16))),
new Version(31, new Array(6, 30, 56, 82, 108, 134), new ECBlocks(30, new ECB(13, 115), new ECB(3, 116)), new ECBlocks(28, new ECB(2, 46), new ECB(29, 47)), new ECBlocks(30, new ECB(42, 24), new ECB(1, 25)), new ECBlocks(30, new ECB(23, 15), new ECB(28, 16))),
new Version(32, new Array(6, 34, 60, 86, 112, 138), new ECBlocks(30, new ECB(17, 115)), new ECBlocks(28, new ECB(10, 46), new ECB(23, 47)), new ECBlocks(30, new ECB(10, 24), new ECB(35, 25)), new ECBlocks(30, new ECB(19, 15), new ECB(35, 16))),
new Version(33, new Array(6, 30, 58, 86, 114, 142), new ECBlocks(30, new ECB(17, 115), new ECB(1, 116)), new ECBlocks(28, new ECB(14, 46), new ECB(21, 47)), new ECBlocks(30, new ECB(29, 24), new ECB(19, 25)), new ECBlocks(30, new ECB(11, 15), new ECB(46, 16))),
new Version(34, new Array(6, 34, 62, 90, 118, 146), new ECBlocks(30, new ECB(13, 115), new ECB(6, 116)), new ECBlocks(28, new ECB(14, 46), new ECB(23, 47)), new ECBlocks(30, new ECB(44, 24), new ECB(7, 25)), new ECBlocks(30, new ECB(59, 16), new ECB(1, 17))),
new Version(35, new Array(6, 30, 54, 78, 102, 126, 150), new ECBlocks(30, new ECB(12, 121), new ECB(7, 122)), new ECBlocks(28, new ECB(12, 47), new ECB(26, 48)), new ECBlocks(30, new ECB(39, 24), new ECB(14, 25)),new ECBlocks(30, new ECB(22, 15), new ECB(41, 16))),
new Version(36, new Array(6, 24, 50, 76, 102, 128, 154), new ECBlocks(30, new ECB(6, 121), new ECB(14, 122)), new ECBlocks(28, new ECB(6, 47), new ECB(34, 48)), new ECBlocks(30, new ECB(46, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(2, 15), new ECB(64, 16))),
new Version(37, new Array(6, 28, 54, 80, 106, 132, 158), new ECBlocks(30, new ECB(17, 122), new ECB(4, 123)), new ECBlocks(28, new ECB(29, 46), new ECB(14, 47)), new ECBlocks(30, new ECB(49, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(24, 15), new ECB(46, 16))),
new Version(38, new Array(6, 32, 58, 84, 110, 136, 162), new ECBlocks(30, new ECB(4, 122), new ECB(18, 123)), new ECBlocks(28, new ECB(13, 46), new ECB(32, 47)), new ECBlocks(30, new ECB(48, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(42, 15), new ECB(32, 16))),
new Version(39, new Array(6, 26, 54, 82, 110, 138, 166), new ECBlocks(30, new ECB(20, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(40, 47), new ECB(7, 48)), new ECBlocks(30, new ECB(43, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(10, 15), new ECB(67, 16))),
new Version(40, new Array(6, 30, 58, 86, 114, 142, 170), new ECBlocks(30, new ECB(19, 118), new ECB(6, 119)), new ECBlocks(28, new ECB(18, 47), new ECB(31, 48)), new ECBlocks(30, new ECB(34, 24), new ECB(34, 25)), new ECBlocks(30, new ECB(20, 15), new ECB(61, 16))));
}

38
js/main.js Normal file
View file

@ -0,0 +1,38 @@
var information_bits = [
//ECC L
["111011111000100",
"111001011110011",
"111110110101010",
"111100010011101",
"110011000101111",
"110001100011000",
"110110001000001",
"110100101110110"],
//ECC M
["101010000010010",
"101000100100101",
"101111001111100",
"101101101001011",
"100010111111001",
"100000011001110",
"100111110010111",
"100101010100000"],
//ECC Q
["011010101011111",
"011000001101000",
"011111100110001",
"011101000000110",
"010010010110100",
"010000110000011",
"010111011011010",
"010101111101101"],
//ECC H
["001011010001001",
"001001110111110",
"001110011100111",
"001100111010000",
"000011101100010",
"000001001010101",
"000110100001100",
"000100000111011"]
]

509
js/reedsolomon.js Normal file
View file

@ -0,0 +1,509 @@
/*****************************************************************************************
------------------Javascript Reed-Solomon Universal Encoder/Decoder--------------------
Written by : Merricx
Heavily referenced from https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders
And ported partly from https://github.com/tomerfiliba/reedsolomon
******************************************************************************************/
var gf_exp = new Uint8Array(512);
var gf_log = new Uint8Array(256);
//Source: http://stackoverflow.com/questions/2044760/default-array-values
Array.prototype.repeat = function(def, len){
while(len)
this[--len]= def;
return this;
};
/*
======================================================
GALOIS FIELD
======================================================
*/
function init_tables(prim){
prim = prim || 0x11d;
gf_exp = new Uint8Array(512);
gf_log = new Uint8Array(256);
var x = 1;
for(var i=0; i < 255;i++){
gf_exp[i] = x;
gf_log[x] = i;
x = gf_mult_noLUT(x,2,prim);
}
for(var i=255; i < 512; i++){
gf_exp[i] = gf_exp[i - 255];
}
return [gf_log, gf_exp];
}
function gf_add(x,y){
return x ^ y;
}
function gf_sub(x,y){
return x ^ y;
}
function gf_mult_noLUT(x,y,prim){
prim = prim || 0;
function cl_mult(x,y){
var z = 0;
var i = 0;
while((y>>i) > 0){
if(y & (1<<i)){
z ^= x<<i;
}
i++;
}
return z;
}
function bit_length(n){
var bits = 0;
while(n>>bits){
bits += 1;
}
return bits;
}
function cl_div(dividend,divisor){
var dl1 = bit_length(dividend);
var dl2 = bit_length(divisor);
if(dl1 < dl2){
return dividend;
}
for(var i=dl1-dl2; i > -1; i--){
if(dividend & (1 << i+dl2-1)){
dividend ^= divisor << i;
}
}
return dividend;
}
var result = cl_mult(x,y);
if(prim > 0){
result = cl_div(result, prim);
}
return result;
}
function gf_mul(x,y){
if(x == 0 || y == 0)
return 0;
return gf_exp[gf_log[x] + gf_log[y]];
}
function gf_div(x,y){
if(y == 0){
throw "Division by zero";
}
if(x == 0){
return 0;
}
return gf_exp[(gf_log[x] + 255 - gf_log[y]) % 255];
}
function gf_pow(x, power){
return gf_exp[(((gf_log[x] * power) % 255) + 255) % 255];
}
function gf_inverse(x){
return gf_exp[255 - gf_log[x]];
}
/*
======================================================
POLYNOMIAL OPERATION
======================================================
*/
function gf_poly_scale(p,x){
var r = [];
for(var i=0; i < p.length; i++){
r[i] = gf_mul(p[i], x);
}
return r;
}
function gf_poly_add(p,q){
var r = new Array(Math.max(p.length, q.length));
for(var i=0; i < p.length; i++){
r[i+r.length-p.length] = p[i];
}
for(var i=0; i < q.length; i++){
r[i+r.length-q.length] ^= q[i];
}
return r;
}
function gf_poly_mul(p,q){
var r = new Array(p.length+q.length-1);
for(var j=0; j < q.length;j++){
for(var i=0; i < p.length; i++){
r[j+i] ^= gf_mul(p[i], q[j]);
}
}
return r;
}
function gf_poly_div(dividend, divisor){
var msg_out = Array.prototype.slice.call(dividend);
for(var i=0; i < dividend.length - (divisor.length-1); i++){
coef = msg_out[i];
if(coef != 0){
for(var j=1; j < divisor.length; j++){
if(divisor[j] != 0){
msg_out[i+j] ^= gf_mul(divisor[j], coef);
}
}
}
}
var separator = divisor.length - 1;
var result = [[],[]];
for(var i=0; i < msg_out.length-separator; i++){
result[0][i] = msg_out[i];
}
for(var i=msg_out.length-separator; i < msg_out.length; i++){
result[1].push(msg_out[i]);
}
return result;
}
function gf_poly_eval(poly, x){
var y = poly[0];
for(var i=1; i < poly.length; i++){
y = gf_mul(y,x) ^ poly[i];
}
return y;
}
/*
======================================================
REED-SOLOMON ENCODING
======================================================
*/
function rs_generator_poly(nysm){
var g = [1];
for(var i=0; i < nysm; i++){
g = gf_poly_mul(g, [1, gf_pow(2, i)])
}
return g;
}
function rs_encode_msg(msg_in, nysm){
if(msg_in.length + nysm > 255)
throw "Message is too long...";
var gen = rs_generator_poly(nysm);
var msg_out = [].repeat(0, (msg_in.length+gen.length)-1)
for(var i=0; i < msg_in.length; i++){
msg_out[i] = msg_in[i];
}
for(var i=0; i < msg_in.length; i++){
var coef = msg_out[i];
if(coef != 0){
for(var j=1; j < gen.length; j++){
msg_out[i+j] ^= gf_mul(gen[j], coef);
}
}
}
for(var i=0; i < msg_in.length; i++){
msg_out[i] = msg_in[i];
}
return msg_out;
}
/*
======================================================
REED-SOLOMON DECODING
======================================================
*/
function rs_calc_syndromes(msg, nysm){
var synd = [].repeat(0, nysm);
for(var i=0; i < nysm; i++){
synd[i] = gf_poly_eval(msg, gf_pow(2,i));
}
return [0].concat(synd);
}
function rs_check(msg, nysm){
var check = rs_calc_syndromes(msg, nysm);
var no_error = true;
for(var i=0; i < check.length; i++){
if(check[i] != 0){
no_error = false;
break;
}
}
return no_error;
}
function rs_find_errata_locator(e_pos){
var e_loc = [1];
for(var i=0; i < e_pos.length; i++){
e_loc = gf_poly_mul(e_loc, gf_poly_add([1], [gf_pow(2,e_pos[i]), 0]))
}
return e_loc;
}
function rs_find_error_evaluator(synd, err_loc, nysm){
var x = [].repeat(0, nysm+1);
var remainder = gf_poly_div(gf_poly_mul(synd, err_loc), ([1].concat(x)))[1];
return remainder;
}
function rs_correct_errata(msg_in, synd, err_pos){
var coef_pos = [];
for(var i=0; i < err_pos.length; i++){
coef_pos[i] = msg_in.length - 1 - err_pos[i];
}
var err_loc = rs_find_errata_locator(coef_pos);
var err_eval = rs_find_error_evaluator(synd.reverse(), err_loc, err_loc.length-1);
var X = [];
for(var i=0; i < coef_pos.length; i++){
var l = 255 - coef_pos[i];
X.push(gf_pow(2, -l));
}
var E = [].repeat(0, msg_in.length);
for(var i=0; i < X.length; i++){
var Xi_inv = gf_inverse(X[i]);
err_loc_prime_tmp = [];
for(var j=0; j < X.length; j++){
if(j != i){
err_loc_prime_tmp.push(gf_sub(1, gf_mul(Xi_inv, X[j])));
}
}
var err_loc_prime = 1;
for(var j=0; j < err_loc_prime_tmp.length; j++){
err_loc_prime = gf_mul(err_loc_prime, err_loc_prime_tmp[j]);
}
var y = gf_poly_eval(err_eval, Xi_inv);
y = gf_mul(gf_pow(X[i], 1), y);
var magnitude = gf_div(y, err_loc_prime);
E[err_pos[i]] = magnitude;
}
msg_in = gf_poly_add(msg_in, E);
return msg_in;
}
function rs_find_error_locator(synd, nysm, erase_loc, erase_count){
erase_loc = erase_loc || undefined;
erase_count = erase_count || 0;
if(erase_loc != undefined){
err_loc = Array.prototype.slice.call(erase_loc);
old_loc = Array.prototype.slice.call(erase_loc);
} else {
err_loc = [1];
old_loc = [1];
}
synd_shift = 0
if(synd.length > nysm){
synd_shift = synd.length - nysm;
}
for(var i=0; i < nysm-erase_count;i++){
if(erase_loc != undefined){
K = erase_count+i+synd_shift;
} else {
K = i+synd_shift;
}
delta = synd[K];
for(var j=1;j < err_loc.length; j++){
delta ^= gf_mul(err_loc[err_loc.length-(j+1)], synd[K-j]);
}
old_loc = old_loc.concat([0]);
if(delta != 0){
if(old_loc.length > err_loc.length){
new_loc = gf_poly_scale(old_loc, delta);
old_loc = gf_poly_scale(err_loc, gf_inverse(delta));
err_loc = new_loc;
}
err_loc = gf_poly_add(err_loc, gf_poly_scale(old_loc, delta));
}
}
while(err_loc.length != 0 && err_loc[0] == 0){
err_loc.shift();
}
errs = err_loc.length - 1;
if((errs - erase_count) * 2 + erase_count > nysm){
throw new Error("Too many errors to correct");
}
return err_loc;
}
function rs_find_errors(err_loc, nmess){
errs = err_loc.length - 1;
err_pos = [];
for(var i=0; i < nmess; i++){
if(gf_poly_eval(err_loc, gf_pow(2, i)) == 0){
err_pos.push(nmess - 1 - i);
}
}
if(err_pos.length != errs){
throw new Error("Could not locate error!");
}
return err_pos;
}
function rs_forney_syndromes(synd, pos, nmess){
erase_pos_reversed = [];
for(var i=0; i < pos.length; i++){
erase_pos_reversed.push(nmess-1-pos[i]);
}
fsynd = Array.prototype.slice.call(synd);
fsynd.shift();
for(var i=0; i < pos.length; i++){
x = gf_pow(2, erase_pos_reversed[i]);
for(var j=0; j < fsynd.length-1; j++){
fsynd[j] = gf_mul(fsynd[j], x) ^ fsynd[j+1];
}
}
return fsynd;
}
function rs_correct_msg(msg_in, nysm, erase_pos){
erase_pos = erase_pos || undefined;
var msg_len = msg_in.length - nysm;
if(msg_in.length > 255){
return "Message is too long...";
}
msg_out = Array.prototype.slice.call(msg_in);
if(erase_pos == undefined){
erase_pos = [];
} else {
for(var i=0; i < erase_pos.length; i++){
msg_out[erase_pos[i]] = 0;
}
}
if(erase_pos.length > nysm)
return "Too many erasures to correct";
synd = rs_calc_syndromes(msg_out, nysm);
if(rs_check(msg_out, nysm)){
msg_in = msg_in.slice(0, msg_len);
return msg_in;
}
fsynd = rs_forney_syndromes(synd, erase_pos, msg_out.length);
try {
err_loc = rs_find_error_locator(fsynd, nysm, undefined ,erase_pos.length);
}
catch (error){
return error.message;
}
try {
err_pos = rs_find_errors(err_loc.reverse(), msg_out.length);
} catch (error) {
return error.message;
}
msg_out = rs_correct_errata(msg_out, synd, erase_pos.concat(err_pos));
synd = rs_calc_syndromes(msg_out, nysm);
if(!rs_check(msg_out, nysm)){
return "Could not correct message";
}
return msg_out.slice(0, msg_len);
}
/*
======================================================
MAIN FUNCTION
======================================================
*/
//Generate pre-computed tables
init_tables();
var RS = {
//Encoding
encode: function(data, nysm){
return rs_encode_msg(data, nysm);
},
//Decoding
decode: function(data, nysm, erase_pos){
return rs_correct_msg(data, nysm, erase_pos);
}
}

1030
js/sqrd.js Normal file

File diff suppressed because it is too large Load diff

160
js/table.js Normal file
View file

@ -0,0 +1,160 @@
var function_pattern_with_format_info = {
TOP_LEFT: [
[1,1,1,1,1,1,1,0,2],
[1,0,0,0,0,0,1,0,3],
[1,0,1,1,1,0,1,0,4],
[1,0,1,1,1,0,1,0,5],
[1,0,1,1,1,0,1,0,6],
[1,0,0,0,0,0,1,0,7],
[1,1,1,1,1,1,1,0,1],
[0,0,0,0,0,0,0,0,8],
[16,15,14,13,12,11,1,10,9]
],
TOP_RIGHT: [
[0,1,1,1,1,1,1,1],
[0,1,0,0,0,0,0,1],
[0,1,0,1,1,1,0,1],
[0,1,0,1,1,1,0,1],
[0,1,0,1,1,1,0,1],
[0,1,0,0,0,0,0,1],
[0,1,1,1,1,1,1,1],
[0,0,0,0,0,0,0,0],
[9,8,7,6,5,4,3,2]
],
BOTTOM_LEFT: [
[0,0,0,0,0,0,0,0,1],
[1,1,1,1,1,1,1,0,10],
[1,0,0,0,0,0,1,0,11],
[1,0,1,1,1,0,1,0,12],
[1,0,1,1,1,0,1,0,13],
[1,0,1,1,1,0,1,0,14],
[1,0,0,0,0,0,1,0,15],
[1,1,1,1,1,1,1,0,16],
]
};
var alignment_pattern_array = [
[],
[6, 18],
[6, 22],
[6, 26],
[6, 30],
[6, 34]
];
var format_information_bits = [
//ECC L
["111011111000100",
"111001011110011",
"111110110101010",
"111100010011101",
"110011000101111",
"110001100011000",
"110110001000001",
"110100101110110"],
//ECC M
["101010000010010",
"101000100100101",
"101111001111100",
"101101101001011",
"100010111111001",
"100000011001110",
"100111110010111",
"100101010100000"],
//ECC Q
["011010101011111",
"011000001101000",
"011111100110001",
"011101000000110",
"010010010110100",
"010000110000011",
"010111011011010",
"010101111101101"],
//ECC H
["001011010001001",
"001001110111110",
"001110011100111",
"001100111010000",
"000011101100010",
"000001001010101",
"000110100001100",
"000100000111011"]
];
var format_information_unmask = [
'000000000000000',
'000010100110111',
'000101001101110',
'000111101011001',
'001000111101011',
'001010011011100',
'001101110000101',
'001111010110010',
'010001111010110',
'010011011100001',
'010100110111000',
'010110010001111',
'011001000111101',
'011011100001010',
'011100001010011',
'011110101100100',
'100001010011011',
'100011110101100',
'100100011110101',
'100110111000010',
'101001101110000',
'101011001000111',
'101100100011110',
'101110000101001',
'110000101001101',
'110010001111010',
'110101100100011',
'110111000010100',
'111000010100110',
'111010110010001',
'111101011001000',
'111111111111111'
];
var data_code_num_table = [
[ 16, 19, 9, 13],
[ 28, 34, 16, 22],
[ 44, 55, 26, 34],
[ 64, 80, 36, 48],
[ 86, 108, 46, 62],
[ 108, 136, 60, 76]
];
var RS_block_num_table = [
[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 2, 2],
[2, 1, 4, 2],
[2, 1, 4, 4],
[4, 2, 4, 4]
];
var alphanumeric_table = [
"0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "A", "B",
"C", "D", "E", "F", "G", "H",
"I", "J", "K", "L", "M", "N",
"O", "P", "Q", "R", "S", "T",
"U", "V", "W", "X", "Y", "Z",
" ", "$", "%", "*", "+", "-",
".", "/", ":"
];
var error_correction_code_table = [
[10,7,17,13],
[16,10,28,22],
[26,15,22,18],
[18,20,16,26],
[24,26,22,18],
[16,18,28,24]
];
var remainder_bits_table = [0,7,7,7,7,7];

BIN
sample/problem (1).png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 873 B

BIN
sample/sample-0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
sample/sample-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
sample/sample-rs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB