Esempio n. 1
0
 /**
  * Appends ECI information to a bit array.
  *
  * @param  CharacterSetEci $eci
  * @param  BitArray        $bits
  * @return void
  */
 protected static function appendEci(CharacterSetEci $eci, BitArray $bits)
 {
     $mode = new Mode(Mode::ECI);
     $bits->appendBits($mode->get(), 4);
     $bits->appendBits($eci->get(), 8);
 }
Esempio n. 2
0
 public function testBuildMatrix()
 {
     $bytes = array(32, 65, 205, 69, 41, 220, 46, 128, 236, 42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219, 61);
     $bits = new BitArray();
     foreach ($bytes as $byte) {
         $bits->appendBits($byte, 8);
     }
     $matrix = new ByteMatrix(21, 21);
     MatrixUtil::buildMatrix($bits, new ErrorCorrectionLevel(ErrorCorrectionLevel::H), Version::getVersionForNumber(1), 3, $matrix);
     $expected = " 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 1 1\n" . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" . " 1 0 1 1 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 0 1\n" . " 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1\n" . " 1 0 1 1 1 0 1 0 1 1 0 0 1 0 1 0 1 1 1 0 1\n" . " 1 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 0 0 1\n" . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" . " 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0\n" . " 0 0 1 1 0 0 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0\n" . " 1 0 1 0 1 0 0 0 0 0 1 1 1 0 0 1 0 1 1 1 0\n" . " 1 1 1 1 0 1 1 0 1 0 1 1 1 0 0 1 1 1 0 1 0\n" . " 1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 1 0 1 0\n" . " 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1\n" . " 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 1 1\n" . " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 0 1 0 1 1 0\n" . " 1 0 0 0 0 0 1 0 0 0 0 1 0 1 1 1 0 0 0 0 0\n" . " 1 0 1 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1\n" . " 1 0 1 1 1 0 1 0 1 1 0 1 0 0 0 0 0 1 1 1 0\n" . " 1 0 1 1 1 0 1 0 1 1 1 1 0 0 0 0 1 1 1 0 0\n" . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0\n" . " 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0\n";
     $this->assertEquals($expected, $matrix->__toString());
 }
Esempio n. 3
0
 /**
  * Generates version information bits and appends them to a bit array.
  *
  * @param  Version  $version
  * @param  BitArray $bits
  * @return void
  * @throws Exception\RuntimeException
  */
 protected static function makeVersionInfoBits(Version $version, BitArray $bits)
 {
     $bits->appendBits($version->getVersionNumber(), 6);
     $bchCode = self::calculateBchCode($version->getVersionNumber(), self::$versionInfoPoly);
     $bits->appendBits($bchCode, 12);
     if ($bits->getSize() !== 18) {
         throw new Exception\RuntimeException('Bit array resulted in invalid size: ' . $bits->getSize());
     }
 }