3
3
* Class MaskPattern
4
4
*
5
5
* @created 19.01.2021
6
- * @author smiley <[email protected] >
7
- * @copyright 2021 smiley
8
- * @license MIT
6
+ * @author ZXing Authors
7
+ * @author Smiley <[email protected] >
8
+ * @copyright 2021 Smiley
9
+ * @license Apache-2.0
9
10
*/
10
11
11
12
namespace chillerlan \QRCode \Common ;
20
21
* ISO/IEC 18004:2000 Section 8.8.2 - Evaluation of masking results
21
22
*
22
23
* @see http://www.thonky.com/qr-code-tutorial/data-masking
24
+ * @see https://github.com/zxing/zxing/blob/e9e2bd280bcaeabd59d0f955798384fe6c018a6c/core/src/main/java/com/google/zxing/qrcode/encoder/MaskUtil.java
23
25
*/
24
26
final class MaskPattern{
25
27
@@ -128,6 +130,9 @@ public static function testRule1(array $matrix, int $height, int $width):int{
128
130
return self ::applyRule1 ($ matrix , $ height , $ width , true ) + self ::applyRule1 ($ matrix , $ height , $ width , false );
129
131
}
130
132
133
+ /**
134
+ *
135
+ */
131
136
private static function applyRule1 (array $ matrix , int $ height , int $ width , bool $ isHorizontal ):int {
132
137
$ penalty = 0 ;
133
138
$ iLimit = $ isHorizontal ? $ height : $ width ;
@@ -215,7 +220,7 @@ public static function testRule3(array $matrix, int $height, int $width):int{
215
220
&& !$ row [$ x + 5 ]
216
221
&& $ row [$ x + 6 ]
217
222
&& (
218
- self ::isWhiteHorizontal ($ row , $ width , $ x - 4 , $ x )
223
+ self ::isWhiteHorizontal ($ row , $ width , $ x - 4 , $ x )
219
224
|| self ::isWhiteHorizontal ($ row , $ width , $ x + 7 , $ x + 11 )
220
225
)
221
226
){
@@ -232,7 +237,7 @@ public static function testRule3(array $matrix, int $height, int $width):int{
232
237
&& !$ matrix [$ y + 5 ][$ x ]
233
238
&& $ matrix [$ y + 6 ][$ x ]
234
239
&& (
235
- self ::isWhiteVertical ($ matrix , $ height , $ x , $ y - 4 , $ y )
240
+ self ::isWhiteVertical ($ matrix , $ height , $ x , $ y - 4 , $ y )
236
241
|| self ::isWhiteVertical ($ matrix , $ height , $ x , $ y + 7 , $ y + 11 )
237
242
)
238
243
){
@@ -245,6 +250,9 @@ public static function testRule3(array $matrix, int $height, int $width):int{
245
250
return $ penalties * 40 ;
246
251
}
247
252
253
+ /**
254
+ *
255
+ */
248
256
private static function isWhiteHorizontal (array $ row , int $ width , int $ from , int $ to ):bool {
249
257
250
258
if ($ from < 0 || $ width < $ to ){
@@ -260,6 +268,9 @@ private static function isWhiteHorizontal(array $row, int $width, int $from, int
260
268
return true ;
261
269
}
262
270
271
+ /**
272
+ *
273
+ */
263
274
private static function isWhiteVertical (array $ matrix , int $ height , int $ x , int $ from , int $ to ):bool {
264
275
265
276
if ($ from < 0 || $ height < $ to ){
0 commit comments