bitcoin-atm
bitcoin atm for pyc inc.
git clone https://9o.is/git/bitcoin-atm.git
datamask.js
(3848B)
1 /*
2 Ported to JavaScript by Lazar Laszlo 2011
3
4 lazarsoft@gmail.com, www.lazarsoft.info
5
6 */
7
8 /*
9 *
10 * Copyright 2007 ZXing authors
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 */
24
25
26 DataMask = {};
27
28 DataMask.forReference = function(reference)
29 {
30 if (reference < 0 || reference > 7)
31 {
32 throw "System.ArgumentException";
33 }
34 return DataMask.DATA_MASKS[reference];
35 }
36
37 function DataMask000()
38 {
39 this.unmaskBitMatrix=function(bits, dimension)
40 {
41 for (var i = 0; i < dimension; i++)
42 {
43 for (var j = 0; j < dimension; j++)
44 {
45 if (this.isMasked(i, j))
46 {
47 bits.flip(j, i);
48 }
49 }
50 }
51 }
52 this.isMasked=function( i, j)
53 {
54 return ((i + j) & 0x01) == 0;
55 }
56 }
57
58 function DataMask001()
59 {
60 this.unmaskBitMatrix=function(bits, dimension)
61 {
62 for (var i = 0; i < dimension; i++)
63 {
64 for (var j = 0; j < dimension; j++)
65 {
66 if (this.isMasked(i, j))
67 {
68 bits.flip(j, i);
69 }
70 }
71 }
72 }
73 this.isMasked=function( i, j)
74 {
75 return (i & 0x01) == 0;
76 }
77 }
78
79 function DataMask010()
80 {
81 this.unmaskBitMatrix=function(bits, dimension)
82 {
83 for (var i = 0; i < dimension; i++)
84 {
85 for (var j = 0; j < dimension; j++)
86 {
87 if (this.isMasked(i, j))
88 {
89 bits.flip(j, i);
90 }
91 }
92 }
93 }
94 this.isMasked=function( i, j)
95 {
96 return j % 3 == 0;
97 }
98 }
99
100 function DataMask011()
101 {
102 this.unmaskBitMatrix=function(bits, dimension)
103 {
104 for (var i = 0; i < dimension; i++)
105 {
106 for (var j = 0; j < dimension; j++)
107 {
108 if (this.isMasked(i, j))
109 {
110 bits.flip(j, i);
111 }
112 }
113 }
114 }
115 this.isMasked=function( i, j)
116 {
117 return (i + j) % 3 == 0;
118 }
119 }
120
121 function DataMask100()
122 {
123 this.unmaskBitMatrix=function(bits, dimension)
124 {
125 for (var i = 0; i < dimension; i++)
126 {
127 for (var j = 0; j < dimension; j++)
128 {
129 if (this.isMasked(i, j))
130 {
131 bits.flip(j, i);
132 }
133 }
134 }
135 }
136 this.isMasked=function( i, j)
137 {
138 return (((URShift(i, 1)) + (j / 3)) & 0x01) == 0;
139 }
140 }
141
142 function DataMask101()
143 {
144 this.unmaskBitMatrix=function(bits, dimension)
145 {
146 for (var i = 0; i < dimension; i++)
147 {
148 for (var j = 0; j < dimension; j++)
149 {
150 if (this.isMasked(i, j))
151 {
152 bits.flip(j, i);
153 }
154 }
155 }
156 }
157 this.isMasked=function( i, j)
158 {
159 var temp = i * j;
160 return (temp & 0x01) + (temp % 3) == 0;
161 }
162 }
163
164 function DataMask110()
165 {
166 this.unmaskBitMatrix=function(bits, dimension)
167 {
168 for (var i = 0; i < dimension; i++)
169 {
170 for (var j = 0; j < dimension; j++)
171 {
172 if (this.isMasked(i, j))
173 {
174 bits.flip(j, i);
175 }
176 }
177 }
178 }
179 this.isMasked=function( i, j)
180 {
181 var temp = i * j;
182 return (((temp & 0x01) + (temp % 3)) & 0x01) == 0;
183 }
184 }
185 function DataMask111()
186 {
187 this.unmaskBitMatrix=function(bits, dimension)
188 {
189 for (var i = 0; i < dimension; i++)
190 {
191 for (var j = 0; j < dimension; j++)
192 {
193 if (this.isMasked(i, j))
194 {
195 bits.flip(j, i);
196 }
197 }
198 }
199 }
200 this.isMasked=function( i, j)
201 {
202 return ((((i + j) & 0x01) + ((i * j) % 3)) & 0x01) == 0;
203 }
204 }
205
206 DataMask.DATA_MASKS = new Array(new DataMask000(), new DataMask001(), new DataMask010(), new DataMask011(), new DataMask100(), new DataMask101(), new DataMask110(), new DataMask111());
207