Exemplo n.º 1
0
 public static function buildCache()
 {
     weixin_qrcode_QRtools::markTime('before_build_cache');
     $mask = new weixin_qrcode_QRmask();
     for ($a = 1; $a <= QRSPEC_VERSION_MAX; $a++) {
         $frame = weixin_qrcode_QRspec::newFrame($a);
         if (QR_IMAGE) {
             $fileName = QR_CACHE_DIR . 'frame_' . $a . '.png';
             weixin_qrcode_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);
         }
     }
     weixin_qrcode_QRtools::markTime('after_build_cache');
 }
Exemplo n.º 2
0
 public function encodePNG($intext, $outfile = false, $saveandprint = false)
 {
     try {
         ob_start();
         $tab = $this->encode($intext);
         $err = ob_get_contents();
         ob_end_clean();
         if ($err != '') {
             weixin_qrcode_QRtools::log($outfile, $err);
         }
         $maxSize = (int) (QR_PNG_MAXIMUM_SIZE / (count($tab) + 2 * $this->margin));
         weixin_qrcode_QRimage::png($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin, $saveandprint);
     } catch (Exception $e) {
         weixin_qrcode_QRtools::log($outfile, $e->getMessage());
     }
 }