protected final function processFinderPatternInfo($info)
 {
     $topLeft = $info->getTopLeft();
     $topRight = $info->getTopRight();
     $bottomLeft = $info->getBottomLeft();
     $moduleSize = (double) $this->calculateModuleSize($topLeft, $topRight, $bottomLeft);
     if ($moduleSize < 1.0) {
         throw NotFoundException::getNotFoundInstance();
     }
     $dimension = (int) $this->computeDimension($topLeft, $topRight, $bottomLeft, $moduleSize);
     $provisionalVersion = Version::getProvisionalVersionForDimension($dimension);
     $modulesBetweenFPCenters = $provisionalVersion->getDimensionForVersion() - 7;
     $alignmentPattern = null;
     // Anything above version 1 has an alignment pattern
     if (count($provisionalVersion->getAlignmentPatternCenters()) > 0) {
         // Guess where a "bottom right" finder pattern would have been
         $bottomRightX = $topRight->getX() - $topLeft->getX() + $bottomLeft->getX();
         $bottomRightY = $topRight->getY() - $topLeft->getY() + $bottomLeft->getY();
         // Estimate that alignment pattern is closer by 3 modules
         // from "bottom right" to known top left location
         $correctionToTopLeft = 1.0 - 3.0 / (double) $modulesBetweenFPCenters;
         $estAlignmentX = (int) ($topLeft->getX() + $correctionToTopLeft * ($bottomRightX - $topLeft->getX()));
         $estAlignmentY = (int) ($topLeft->getY() + $correctionToTopLeft * ($bottomRightY - $topLeft->getY()));
         // Kind of arbitrary -- expand search radius before giving up
         for ($i = 4; $i <= 16; $i <<= 1) {
             //??????????
             try {
                 $alignmentPattern = $this->findAlignmentInRegion($moduleSize, $estAlignmentX, $estAlignmentY, (double) $i);
                 break;
             } catch (NotFoundException $re) {
                 // try next round
             }
         }
         // If we didn't find alignment pattern... well try anyway without it
     }
     $transform = $this->createTransform($topLeft, $topRight, $bottomLeft, $alignmentPattern, $dimension);
     $bits = $this->sampleGrid($this->image, $transform, $dimension);
     $points = array();
     if ($alignmentPattern == null) {
         $points = array($bottomLeft, $topLeft, $topRight);
     } else {
         // die('$points = new ResultPoint[]{bottomLeft, topLeft, topRight, alignmentPattern};');
         $points = array($bottomLeft, $topLeft, $topRight, $alignmentPattern);
     }
     return new DetectorResult($bits, $points);
 }
 /**
  * <p>Reads version information from one of its two locations within the QR Code.</p>
  *
  * @return {@link Version} encapsulating the QR Code's version
  * @throws FormatException if both version information locations cannot be parsed as
  * the valid encoding of version information
  */
 function readVersion()
 {
     if ($this->parsedVersion != null) {
         return $this->parsedVersion;
     }
     $dimension = $this->bitMatrix->getHeight();
     $provisionalVersion = ($dimension - 17) / 4;
     if ($provisionalVersion <= 6) {
         return Version::getVersionForNumber($provisionalVersion);
     }
     // Read top-right version info: 3 wide by 6 tall
     $versionBits = 0;
     $ijMin = $dimension - 11;
     for ($j = 5; $j >= 0; $j--) {
         for ($i = $dimension - 9; $i >= $ijMin; $i--) {
             $versionBits = $this->copyBit($i, $j, $versionBits);
         }
     }
     $theParsedVersion = Version::decodeVersionInformation($versionBits);
     if ($theParsedVersion != null && $theParsedVersion->getDimensionForVersion() == $dimension) {
         $this->parsedVersion = $theParsedVersion;
         return $theParsedVersion;
     }
     // Hmm, failed. Try bottom left: 6 wide by 3 tall
     $versionBits = 0;
     for ($i = 5; $i >= 0; $i--) {
         for ($j = $dimension - 9; $j >= $ijMin; $j--) {
             $versionBits = $this->copyBit($i, $j, $versionBits);
         }
     }
     $theParsedVersion = Version::decodeVersionInformation($versionBits);
     if ($theParsedVersion != null && $theParsedVersion->getDimensionForVersion() == $dimension) {
         $this->parsedVersion = $theParsedVersion;
         return $theParsedVersion;
     }
     throw FormatException::getFormatInstance();
 }