MCPcopy Create free account
hub / github.com/codemistic/Web-Development / appendPaddingBit

Method appendPaddingBit

text-to-qr/lib/phpqrcode/phpqrcode.php:1648–1690  ·  view source on GitHub ↗

----------------------------------------------------------------------

(&$bstream)

Source from the content-addressed store, hash-verified

1646
1647 //----------------------------------------------------------------------
1648 public function appendPaddingBit(&$bstream)
1649 {
1650 $bits = $bstream->size();
1651 $maxwords = QRspec::getDataLength($this->version, $this->level);
1652 $maxbits = $maxwords * 8;
1653
1654 if ($maxbits == $bits) {
1655 return 0;
1656 }
1657
1658 if ($maxbits - $bits < 5) {
1659 return $bstream->appendNum($maxbits - $bits, 0);
1660 }
1661
1662 $bits += 4;
1663 $words = (int)(($bits + 7) / 8);
1664
1665 $padding = new QRbitstream();
1666 $ret = $padding->appendNum($words * 8 - $bits + 4, 0);
1667
1668 if($ret < 0)
1669 return $ret;
1670
1671 $padlen = $maxwords - $words;
1672
1673 if($padlen > 0) {
1674
1675 $padbuf = array();
1676 for($i=0; $i<$padlen; $i++) {
1677 $padbuf[$i] = ($i&1)?0x11:0xec;
1678 }
1679
1680 $ret = $padding->appendBytes($padlen, $padbuf);
1681
1682 if($ret < 0)
1683 return $ret;
1684
1685 }
1686
1687 $ret = $bstream->append($padding);
1688
1689 return $ret;
1690 }
1691
1692 //----------------------------------------------------------------------
1693 public function mergeBitStream()

Callers 1

getBitStreamMethod · 0.95

Calls 5

sizeMethod · 0.45
getDataLengthMethod · 0.45
appendNumMethod · 0.45
appendBytesMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected