本文整理汇总了PHP中QRinput::getErrorCorrectionLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP QRinput::getErrorCorrectionLevel方法的具体用法?PHP QRinput::getErrorCorrectionLevel怎么用?PHP QRinput::getErrorCorrectionLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRinput
的用法示例。
在下文中一共展示了QRinput::getErrorCorrectionLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: encodeMask
public function encodeMask(QRinput $input, $mask)
{
if ($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) {
throw new Exception('wrong version');
}
if ($input->getErrorCorrectionLevel() > QR_ECLEVEL_H) {
throw new Exception('wrong level');
}
$raw = new QRrawcode($input);
QRtools::markTime('after_raw');
$version = $raw->version;
$width = QRspec::getWidth($version);
$frame = QRspec::newFrame($version);
$filler = new FrameFiller($width, $frame);
if (is_null($filler)) {
return null;
}
// inteleaved data and ecc codes
for ($i = 0; $i < $raw->dataLength + $raw->eccLength; $i++) {
$code = $raw->getCode();
$bit = 0x80;
for ($j = 0; $j < 8; $j++) {
$addr = $filler->next();
$filler->setFrameAt($addr, 0x2 | ($bit & $code) != 0);
$bit = $bit >> 1;
}
}
QRtools::markTime('after_filler');
unset($raw);
// remainder bits
$j = QRspec::getRemainder($version);
for ($i = 0; $i < $j; $i++) {
$addr = $filler->next();
$filler->setFrameAt($addr, 0x2);
}
$frame = $filler->frame;
unset($filler);
// masking
$maskObj = new QRmask();
if ($mask < 0) {
if (QR_FIND_BEST_MASK) {
$masked = $maskObj->mask($width, $frame, $input->getErrorCorrectionLevel());
} else {
$masked = $maskObj->makeMask($width, $frame, (int) QR_DEFAULT_MASK % 8, $input->getErrorCorrectionLevel());
}
} else {
$masked = $maskObj->makeMask($width, $frame, $mask, $input->getErrorCorrectionLevel());
}
if ($masked == null) {
return null;
}
QRtools::markTime('after_mask');
$this->version = $version;
$this->width = $width;
$this->data = $masked;
return $this;
}
示例2: __construct
public function __construct(QRinput $input)
{
$spec = array(0, 0, 0, 0, 0);
$this->datacode = $input->getByteStream();
if (is_null($this->datacode)) {
throw new Exception('null imput string');
}
QRspec::getEccSpec($input->getVersion(), $input->getErrorCorrectionLevel(), $spec);
$this->version = $input->getVersion();
$this->b1 = QRspec::rsBlockNum1($spec);
$this->dataLength = QRspec::rsDataLength($spec);
$this->eccLength = QRspec::rsEccLength($spec);
$this->ecccode = array_fill(0, $this->eccLength, 0);
$this->blocks = QRspec::rsBlockNum($spec);
$ret = $this->init($spec);
if ($ret < 0) {
throw new Exception('block alloc error');
return null;
}
$this->count = 0;
}