@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | // This class uses 5x5 blocks to compute local luminance, where each block is 8x8 pixels. |
36 | 36 | // So this is the smallest dimension in each axis we can accept. |
37 | 37 | private const BLOCK_SIZE_POWER = 3; |
38 | - private const BLOCK_SIZE = 8; // ...0100...00 |
|
39 | - private const BLOCK_SIZE_MASK = 7; // ...0011...11 |
|
38 | + private const BLOCK_SIZE = 8; // ...0100...00 |
|
39 | + private const BLOCK_SIZE_MASK = 7; // ...0011...11 |
|
40 | 40 | private const MINIMUM_DIMENSION = 40; |
41 | 41 | private const MIN_DYNAMIC_RANGE = 24; |
42 | 42 | |
@@ -139,13 +139,13 @@ discard block |
||
139 | 139 | if($width >= self::MINIMUM_DIMENSION && $height >= self::MINIMUM_DIMENSION){ |
140 | 140 | $subWidth = $width >> self::BLOCK_SIZE_POWER; |
141 | 141 | |
142 | - if(($width & self::BLOCK_SIZE_MASK) !== 0){ |
|
142 | + if(($width&self::BLOCK_SIZE_MASK) !== 0){ |
|
143 | 143 | $subWidth++; |
144 | 144 | } |
145 | 145 | |
146 | 146 | $subHeight = $height >> self::BLOCK_SIZE_POWER; |
147 | 147 | |
148 | - if(($height & self::BLOCK_SIZE_MASK) !== 0){ |
|
148 | + if(($height&self::BLOCK_SIZE_MASK) !== 0){ |
|
149 | 149 | $subHeight++; |
150 | 150 | } |
151 | 151 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $right = (int)(($width * 4) / 5); |
173 | 173 | |
174 | 174 | for($x = (int)($width / 5); $x < $right; $x++){ |
175 | - $pixel = $localLuminances[(int)$x] & 0xff; |
|
175 | + $pixel = $localLuminances[(int)$x]&0xff; |
|
176 | 176 | $buckets[$pixel >> self::LUMINANCE_SHIFT]++; |
177 | 177 | } |
178 | 178 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $offset = $y * $width; |
189 | 189 | |
190 | 190 | for($x = 0; $x < $width; $x++){ |
191 | - $pixel = (int)($localLuminances[$offset + $x] & 0xff); |
|
191 | + $pixel = (int)($localLuminances[$offset + $x]&0xff); |
|
192 | 192 | |
193 | 193 | if($pixel < $blackPoint){ |
194 | 194 | $matrix->set($x, $y); |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | for($yy = 0, $offset = $yoffset * $width + $xoffset; $yy < self::BLOCK_SIZE; $yy++, $offset += $width){ |
236 | 236 | |
237 | 237 | for($xx = 0; $xx < self::BLOCK_SIZE; $xx++){ |
238 | - $pixel = (int)($luminances[(int)($offset + $xx)]) & 0xff; |
|
239 | - $sum += $pixel; |
|
238 | + $pixel = (int)($luminances[(int)($offset + $xx)])&0xff; |
|
239 | + $sum += $pixel; |
|
240 | 240 | // still looking for good contrast |
241 | 241 | if($pixel < $min){ |
242 | 242 | $min = $pixel; |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | // finish the rest of the rows quickly |
253 | 253 | for($yy++, $offset += $width; $yy < self::BLOCK_SIZE; $yy++, $offset += $width){ |
254 | 254 | for($xx = 0; $xx < self::BLOCK_SIZE; $xx++){ |
255 | - $sum += (int)($luminances[(int)($offset + $xx)]) & 0xff; |
|
255 | + $sum += (int)($luminances[(int)($offset + $xx)])&0xff; |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | |
331 | 331 | for($z = -2; $z <= 2; $z++){ |
332 | 332 | $blackRow = $blackPoints[$top + $z]; |
333 | - $sum += $blackRow[$left - 2] + $blackRow[$left - 1] + $blackRow[$left] + $blackRow[$left + 1] + $blackRow[$left + 2]; |
|
333 | + $sum += $blackRow[$left - 2] + $blackRow[$left - 1] + $blackRow[$left] + $blackRow[$left + 1] + $blackRow[$left + 2]; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | $average = (int)($sum / 25); |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | for($j = 0, $o = $yoffset * $width + $xoffset; $j < self::BLOCK_SIZE; $j++, $o += $width){ |
340 | 340 | for($i = 0; $i < self::BLOCK_SIZE; $i++){ |
341 | 341 | // Comparison needs to be <= so that black == 0 pixels are black even if the threshold is 0. |
342 | - if(((int)($luminances[$o + $i]) & 0xff) <= $average){ |
|
342 | + if(((int)($luminances[$o + $i])&0xff) <= $average){ |
|
343 | 343 | $matrix->set($xoffset + $i, $yoffset + $j); |
344 | 344 | } |
345 | 345 | } |