public static function buildCache() { QRtools::markTime('before_build_cache'); $mask = new QRmask(); for ($a = 1; $a <= Constants::QRSPEC_VERSION_MAX; $a++) { $frame = QRspec::newFrame($a); if (Constants::QR_IMAGE) { $fileName = Constants::QR_CACHE_DIR . 'frame_' . $a . '.png'; $image = QRimage::image(self::binarize($frame), $fileName, 1, 0); ImagePng($image, $filename); } $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'); }
public function encodePNG2($intext, $outfile = false, $saveandprint = false) { try { ob_start(); $tab = $this->encode($intext); $err = ob_get_contents(); ob_end_clean(); if ($err != '') { QRtools::log($outfile, $err); } $maxSize = (int) (QR_PNG_MAXIMUM_SIZE / (count($tab) + 2 * $this->margin)); return QRimage::image($tab, min(max(1, $this->size), $maxSize), $this->margin); } catch (Exception $e) { QRtools::log($outfile, $e->getMessage()); } }