Skip to content

Commit 27e82de

Browse files
committed
🚿
1 parent 3d99ee9 commit 27e82de

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

src/Common/MaskPattern.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
* Class MaskPattern
44
*
55
* @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
910
*/
1011

1112
namespace chillerlan\QRCode\Common;
@@ -20,6 +21,7 @@
2021
* ISO/IEC 18004:2000 Section 8.8.2 - Evaluation of masking results
2122
*
2223
* @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
2325
*/
2426
final class MaskPattern{
2527

@@ -128,6 +130,9 @@ public static function testRule1(array $matrix, int $height, int $width):int{
128130
return self::applyRule1($matrix, $height, $width, true) + self::applyRule1($matrix, $height, $width, false);
129131
}
130132

133+
/**
134+
*
135+
*/
131136
private static function applyRule1(array $matrix, int $height, int $width, bool $isHorizontal):int{
132137
$penalty = 0;
133138
$iLimit = $isHorizontal ? $height : $width;
@@ -215,7 +220,7 @@ public static function testRule3(array $matrix, int $height, int $width):int{
215220
&& !$row[$x + 5]
216221
&& $row[$x + 6]
217222
&& (
218-
self::isWhiteHorizontal($row, $width, $x - 4, $x)
223+
self::isWhiteHorizontal($row, $width, $x - 4, $x)
219224
|| self::isWhiteHorizontal($row, $width, $x + 7, $x + 11)
220225
)
221226
){
@@ -232,7 +237,7 @@ public static function testRule3(array $matrix, int $height, int $width):int{
232237
&& !$matrix[$y + 5][$x]
233238
&& $matrix[$y + 6][$x]
234239
&& (
235-
self::isWhiteVertical($matrix, $height, $x, $y - 4, $y)
240+
self::isWhiteVertical($matrix, $height, $x, $y - 4, $y)
236241
|| self::isWhiteVertical($matrix, $height, $x, $y + 7, $y + 11)
237242
)
238243
){
@@ -245,6 +250,9 @@ public static function testRule3(array $matrix, int $height, int $width):int{
245250
return $penalties * 40;
246251
}
247252

253+
/**
254+
*
255+
*/
248256
private static function isWhiteHorizontal(array $row, int $width, int $from, int $to):bool{
249257

250258
if($from < 0 || $width < $to){
@@ -260,6 +268,9 @@ private static function isWhiteHorizontal(array $row, int $width, int $from, int
260268
return true;
261269
}
262270

271+
/**
272+
*
273+
*/
263274
private static function isWhiteVertical(array $matrix, int $height, int $x, int $from, int $to):bool{
264275

265276
if($from < 0 || $height < $to){

src/Decoder/Binarizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private function getHistogramBlackMatrix(int $width, int $height):BitMatrix{
172172
$right = (int)(($width * 4) / 5);
173173

174174
for($x = (int)($width / 5); $x < $right; $x++){
175-
$pixel = $localLuminances[(int)$x] & 0xff;
175+
$pixel = $localLuminances[$x] & 0xff;
176176
$buckets[$pixel >> self::LUMINANCE_SHIFT]++;
177177
}
178178
}
@@ -188,7 +188,7 @@ private function getHistogramBlackMatrix(int $width, int $height):BitMatrix{
188188
$offset = $y * $width;
189189

190190
for($x = 0; $x < $width; $x++){
191-
$pixel = (int)($localLuminances[$offset + $x] & 0xff);
191+
$pixel = $localLuminances[$offset + $x] & 0xff;
192192

193193
if($pixel < $blackPoint){
194194
$matrix->set($x, $y);
@@ -286,7 +286,7 @@ private function calculateBlackPoints(array $luminances, int $subWidth, int $sub
286286
}
287287
}
288288

289-
$blackPoints[$y][$x] = (int)($average);
289+
$blackPoints[$y][$x] = $average;
290290
}
291291
}
292292

src/Detector/Detector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private function sizeOfBlackWhiteBlackRunBothWays(float $fromX, float $fromY, fl
162162
}
163163

164164
$otherToX = (int)($fromX + ($otherToX - $fromX) * $scale);
165-
$result += $this->sizeOfBlackWhiteBlackRun((int)$fromX, (int)$fromY, (int)$otherToX, (int)$otherToY);
165+
$result += $this->sizeOfBlackWhiteBlackRun((int)$fromX, (int)$fromY, $otherToX, $otherToY);
166166

167167
// Middle pixel is double-counted this way; subtract 1
168168
return $result - 1.0;

0 commit comments

Comments
 (0)