----------------------------------------------------------------------
($width, $frame)
| 216 | |
| 217 | //---------------------------------------------------------------------- |
| 218 | public function evaluateSymbol($width, $frame) |
| 219 | { |
| 220 | $head = 0; |
| 221 | $demerit = 0; |
| 222 | |
| 223 | for($y=0; $y<$width; $y++) { |
| 224 | $head = 0; |
| 225 | $this->runLength[0] = 1; |
| 226 | |
| 227 | $frameY = $frame[$y]; |
| 228 | |
| 229 | if ($y>0) |
| 230 | $frameYM = $frame[$y-1]; |
| 231 | |
| 232 | for($x=0; $x<$width; $x++) { |
| 233 | if(($x > 0) && ($y > 0)) { |
| 234 | $b22 = ord($frameY[$x]) & ord($frameY[$x-1]) & ord($frameYM[$x]) & ord($frameYM[$x-1]); |
| 235 | $w22 = ord($frameY[$x]) | ord($frameY[$x-1]) | ord($frameYM[$x]) | ord($frameYM[$x-1]); |
| 236 | |
| 237 | if(($b22 | ($w22 ^ 1))&1) { |
| 238 | $demerit += N2; |
| 239 | } |
| 240 | } |
| 241 | if(($x == 0) && (ord($frameY[$x]) & 1)) { |
| 242 | $this->runLength[0] = -1; |
| 243 | $head = 1; |
| 244 | $this->runLength[$head] = 1; |
| 245 | } else if($x > 0) { |
| 246 | if((ord($frameY[$x]) ^ ord($frameY[$x-1])) & 1) { |
| 247 | $head++; |
| 248 | $this->runLength[$head] = 1; |
| 249 | } else { |
| 250 | $this->runLength[$head]++; |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | $demerit += $this->calcN1N3($head+1); |
| 256 | } |
| 257 | |
| 258 | for($x=0; $x<$width; $x++) { |
| 259 | $head = 0; |
| 260 | $this->runLength[0] = 1; |
| 261 | |
| 262 | for($y=0; $y<$width; $y++) { |
| 263 | if($y == 0 && (ord($frame[$y][$x]) & 1)) { |
| 264 | $this->runLength[0] = -1; |
| 265 | $head = 1; |
| 266 | $this->runLength[$head] = 1; |
| 267 | } else if($y > 0) { |
| 268 | if((ord($frame[$y][$x]) ^ ord($frame[$y-1][$x])) & 1) { |
| 269 | $head++; |
| 270 | $this->runLength[$head] = 1; |
| 271 | } else { |
| 272 | $this->runLength[$head]++; |
| 273 | } |
| 274 | } |
| 275 | } |