• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP QRspec类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中QRspec的典型用法代码示例。如果您正苦于以下问题:PHP QRspec类的具体用法?PHP QRspec怎么用?PHP QRspec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了QRspec类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: init

 public function init(array $spec)
 {
     $dl = QRspec::rsDataCodes1($spec);
     $el = QRspec::rsEccCodes1($spec);
     $rs = QRrs::initRs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
     $blockNo = 0;
     $dataPos = 0;
     $eccPos = 0;
     for ($i = 0; $i < QRspec::rsBlockNum1($spec); $i++) {
         $ecc = array_slice($this->ecccode, $eccPos);
         $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs);
         $this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc);
         $dataPos += $dl;
         $eccPos += $el;
         $blockNo++;
     }
     if (QRspec::rsBlockNum2($spec) == 0) {
         return 0;
     }
     $dl = QRspec::rsDataCodes2($spec);
     $el = QRspec::rsEccCodes2($spec);
     $rs = QRrs::initRs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
     if ($rs == null) {
         return -1;
     }
     for ($i = 0; $i < QRspec::rsBlockNum2($spec); $i++) {
         $ecc = array_slice($this->ecccode, $eccPos);
         $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs);
         $this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc);
         $dataPos += $dl;
         $eccPos += $el;
         $blockNo++;
     }
     return 0;
 }
开发者ID:yiuked,项目名称:tmcart,代码行数:35,代码来源:QRrawcode.php


示例2: encodeMask

 public function encodeMask(QRinput $input, $mask)
 {
     if ($input->getVersion() < 0 || $input->getVersion() > Constants::QRSPEC_VERSION_MAX) {
         throw new Exception('wrong version');
     }
     if ($input->getErrorCorrectionLevel() > Constants::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 (Constants::QR_FIND_BEST_MASK) {
             $masked = $maskObj->mask($width, $frame, $input->getErrorCorrectionLevel());
         } else {
             $masked = $maskObj->makeMask($width, $frame, intval(Constants::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;
 }
开发者ID:is00hcw,项目名称:PHPQRCode,代码行数:57,代码来源:QRcode.php


示例3: buildCache

 public static function buildCache()
 {
     QRtools::markTime('before_build_cache');
     $mask = new QRmask();
     for ($a = 1; $a <= QRSPEC_VERSION_MAX; $a++) {
         $frame = QRspec::newFrame($a);
         if (QR_IMAGE) {
             $fileName = QR_CACHE_DIR . 'frame_' . $a . '.png';
             QRimage::png(self::binarize($frame), $fileName, 1, 0);
         }
         $width = count($frame);
         $bitMask = array_fill(0, $width, array_fill(0, $width, 0));
         for ($maskNo = 0; $maskNo < 8; $maskNo++) {
             $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true);
         }
     }
     QRtools::markTime('after_build_cache');
 }
开发者ID:norain2050,项目名称:xingkang,代码行数:18,代码来源:qrtools.php


示例4: writeFormatInformation

 public function writeFormatInformation($width, &$frame, $mask, $level)
 {
     $blacks = 0;
     $format = QRspec::getFormatInfo($mask, $level);
     for ($i = 0; $i < 8; $i++) {
         if ($format & 1) {
             $blacks += 2;
             $v = 0x85;
         } else {
             $v = 0x84;
         }
         $frame[8][$width - 1 - $i] = chr($v);
         if ($i < 6) {
             $frame[$i][8] = chr($v);
         } else {
             $frame[$i + 1][8] = chr($v);
         }
         $format = $format >> 1;
     }
     for ($i = 0; $i < 7; $i++) {
         if ($format & 1) {
             $blacks += 2;
             $v = 0x85;
         } else {
             $v = 0x84;
         }
         $frame[$width - 7 + $i][8] = chr($v);
         if ($i == 0) {
             $frame[8][7] = chr($v);
         } else {
             $frame[8][6 - $i] = chr($v);
         }
         $format = $format >> 1;
     }
     return $blacks;
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:36,代码来源:QRmask.php


示例5: encodeBitStream

 public function encodeBitStream($version)
 {
     try {
         unset($this->bstream);
         $words = QRspec::maximumWords($this->mode, $version);
         if ($this->size > $words) {
             $st1 = new QRinputitem($this->mode, $words, $this->data);
             $st2 = new QRinputitem($this->mode, $this->size - $words, array_slice($this->data, $words));
             $st1->encodeBitStream($version);
             $st2->encodeBitStream($version);
             $this->bstream = new QRbitstream();
             $this->bstream->append($st1->bstream);
             $this->bstream->append($st2->bstream);
             unset($st1);
             unset($st2);
         } else {
             $ret = 0;
             switch ($this->mode) {
                 case QR_MODE_NUM:
                     $ret = $this->encodeModeNum($version);
                     break;
                 case QR_MODE_AN:
                     $ret = $this->encodeModeAn($version);
                     break;
                 case QR_MODE_8:
                     $ret = $this->encodeMode8($version);
                     break;
                 case QR_MODE_KANJI:
                     $ret = $this->encodeModeKanji($version);
                     break;
                 case QR_MODE_STRUCTURE:
                     $ret = $this->encodeModeStructure();
                     break;
                 default:
                     break;
             }
             if ($ret < 0) {
                 return -1;
             }
         }
         return $this->bstream->size();
     } catch (Exception $e) {
         return -1;
     }
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:45,代码来源:QRinputitem.php


示例6: appendPaddingBit

 public function appendPaddingBit(&$bstream)
 {
     $bits = $bstream->size();
     $maxwords = QRspec::getDataLength($this->version, $this->level);
     $maxbits = $maxwords * 8;
     if ($maxbits == $bits) {
         return 0;
     }
     if ($maxbits - $bits < 5) {
         return $bstream->appendNum($maxbits - $bits, 0);
     }
     $bits += 4;
     $words = (int) (($bits + 7) / 8);
     $padding = new QRbitstream();
     $ret = $padding->appendNum($words * 8 - $bits + 4, 0);
     if ($ret < 0) {
         return $ret;
     }
     $padlen = $maxwords - $words;
     if ($padlen > 0) {
         $padbuf = array();
         for ($i = 0; $i < $padlen; $i++) {
             $padbuf[$i] = $i & 1 ? 0x11 : 0xec;
         }
         $ret = $padding->appendBytes($padlen, $padbuf);
         if ($ret < 0) {
             return $ret;
         }
     }
     $ret = $bstream->append($padding);
     return $ret;
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:32,代码来源:QRinput.php


示例7: eat8

 public function eat8()
 {
     $la = QRspec::lengthIndicator(Constants::QR_MODE_AN, $this->input->getVersion());
     $ln = QRspec::lengthIndicator(Constants::QR_MODE_NUM, $this->input->getVersion());
     $p = 1;
     $dataStrLen = strlen($this->dataStr);
     while ($p < $dataStrLen) {
         $mode = $this->identifyMode($p);
         if ($mode == Constants::QR_MODE_KANJI) {
             break;
         }
         if ($mode == Constants::QR_MODE_NUM) {
             $q = $p;
             while (self::isdigitat($this->dataStr, $q)) {
                 $q++;
             }
             $dif = QRinput::estimateBitsMode8($p) + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln - QRinput::estimateBitsMode8($q);
             // - 4 - l8
             if ($dif < 0) {
                 break;
             } else {
                 $p = $q;
             }
         } else {
             if ($mode == Constants::QR_MODE_AN) {
                 $q = $p;
                 while (self::isalnumat($this->dataStr, $q)) {
                     $q++;
                 }
                 $dif = QRinput::estimateBitsMode8($p) + QRinput::estimateBitsModeAn($q - $p) + 4 + $la - QRinput::estimateBitsMode8($q);
                 // - 4 - l8
                 if ($dif < 0) {
                     break;
                 } else {
                     $p = $q;
                 }
             } else {
                 $p++;
             }
         }
     }
     $run = $p;
     $ret = $this->input->append(Constants::QR_MODE_8, $run, str_split($this->dataStr));
     if ($ret < 0) {
         return -1;
     }
     return $run;
 }
开发者ID:justintung,项目名称:PHPQRCode,代码行数:48,代码来源:QRsplit.php


示例8: eat8

 public function eat8()
 {
     $la = QRspec::lengthIndicator(QR_MODE_AN, $this->input->getVersion());
     $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
     $p = 1;
     //$dataStrLen = strlen($this->dataStr);
     $dataStrLen = mb_strlen($this->dataStr, 'CP1251');
     $_str = $this->dataStr;
     $_p = 0;
     while ($p < $dataStrLen) {
         $mode = $this->identifyMode($p);
         if ($mode == QR_MODE_KANJI) {
             break;
         }
         if ($mode == QR_MODE_NUM) {
             $q = $p;
             while (self::isdigitat($this->dataStr, $q)) {
                 $q++;
             }
             $dif = QRinput::estimateBitsMode8($p) + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln - QRinput::estimateBitsMode8($q);
             // - 4 - l8
             if ($dif < 0) {
                 break;
             } else {
                 $p = $q;
             }
         } else {
             if ($mode == QR_MODE_AN) {
                 $q = $p;
                 while (self::isalnumat($this->dataStr, $q)) {
                     $q++;
                 }
                 $dif = QRinput::estimateBitsMode8($p) + QRinput::estimateBitsModeAn($q - $p) + 6 + $la - QRinput::estimateBitsMode8($q);
                 // - 4 - l8
                 if ($dif < 0) {
                     break;
                 } else {
                     $p = $q;
                 }
             } else {
                 if (BX_UTF === true) {
                     $value = ord($_str[$p]);
                     if ($value > 127) {
                         if ($value >= 192 && $value <= 223) {
                             $s = 1;
                         } elseif ($value >= 224 && $value <= 239) {
                             $s = 2;
                         } elseif ($value >= 240 && $value <= 247) {
                             $s = 3;
                         }
                     } else {
                         $s = 0;
                     }
                     $p = $p + $s;
                     $_p = $_p + $s;
                 }
                 $p++;
             }
         }
     }
     $run = $p;
     $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr));
     if ($ret < 0) {
         return -1;
     }
     return $run - $_p;
 }
开发者ID:nProfessor,项目名称:Mytb,代码行数:67,代码来源:qrsplit.php


示例9: QRencode

<?php

include 'phpqrcode/qrlib.php';
//QRcode::png('some othertext 1234', 'out.png', 'H');
$qr = new QRencode();
$tab = $qr->encode('PHP QR Code :)');
QRspec::debug($tab, true);
开发者ID:hemantshekhawat,项目名称:Snippets,代码行数:7,代码来源:qrcodebuilder.php


示例10: QRcode

<?php

include '../lib/full/qrlib.php';
// now the fun begins, we use code generating features of library
$codeContents = 'Let see what the code structure looks like with a little bit bigger code';
$version = 0;
// will be autodetected
$eccLevel = QR_ECLEVEL_H;
$encodingHint = QR_MODE_8;
$caseSensitive = true;
$code = new QRcode();
$code->encodeString($codeContents, $version, $eccLevel, $encodingHint, $caseSensitive);
QRspec::debug($code->data, false);
开发者ID:alaingab,项目名称:modx,代码行数:13,代码来源:example_704_custom_output_visualisation.php



注:本文中的QRspec类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP QRtools类代码示例发布时间:2022-05-23
下一篇:
PHP QRinput类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap