时间:2021-07-01 10:21:17 帮助过:20人阅读
$ln = $this->lengthIndicator($this->QR_MODE_NM, $this->version);
$dif = $this->estimateBitsModeNum($run) + 4 + $ln
+ $this->estimateBitsMode8(1) // + 4 + l8
- $this->estimateBitsMode8($run + 1); // - 4 - l8
if ($dif > 0) {
return $this->eat8();
}
function estimateBitsModeNum($size) {
$w = (int)$size / 3;
$bits = $w * 10;
switch($size - $w * 3) {
case 1: {
$bits += 4;
break;
}
case 2: {
$bits += 7;
break;
}
default: {
break;
}
}
return $bits;
}
function estimateBitsMode8($size) {
return $size * 8;
}
function lengthIndicator($mode, $version) {
if ($mode == $this->QR_MODE_ST) {
return 0;
}
if ($version <= 9) {
$l = 0;
} elseif ($version <= 26) {
$l = 1;
} else {
$l = 2;
}
return $this->lengthTableBits[$mode][$l];
}
$lengthTableBits = array(
array(10, 12, 14),
array( 9, 11, 13),
array( 8, 16, 16),
array( 8, 10, 12)
);