本文整理汇总了PHP中QRimage类的典型用法代码示例。如果您正苦于以下问题:PHP QRimage类的具体用法?PHP QRimage怎么用?PHP QRimage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QRimage类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
public function generate($params = array())
{
if (isset($params['black']) && is_array($params['black']) && count($params['black']) == 3 && array_filter($params['black'], 'is_int') === $params['black']) {
QRimage::$black = $params['black'];
}
if (isset($params['white']) && is_array($params['white']) && count($params['white']) == 3 && array_filter($params['white'], 'is_int') === $params['white']) {
QRimage::$white = $params['white'];
}
$params['data'] = isset($params['data']) ? $params['data'] : 'QR Code Library';
if (isset($params['savename'])) {
$level = 'L';
if (isset($params['level']) && in_array($params['level'], array('L', 'M', 'Q', 'H'))) {
$level = $params['level'];
}
$size = 4;
if (isset($params['size'])) {
$size = min(max((int) $params['size'], 1), 10);
}
QRcode::png($params['data'], $params['savename'], $level, $size, 2);
return $params['savename'];
} else {
$level = 'L';
if (isset($params['level']) && in_array($params['level'], array('L', 'M', 'Q', 'H'))) {
$level = $params['level'];
}
$size = 4;
if (isset($params['size'])) {
$size = min(max((int) $params['size'], 1), 10);
}
QRcode::png($params['data'], NULL, $level, $size, 2);
}
}
示例2: 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');
}
示例3: encodePNG
public function encodePNG($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));
QRimage::png($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin, $saveandprint);
} catch (Exception $e) {
QRtools::log($outfile, $e->getMessage());
}
}
示例4: encodeJPG
public function encodeJPG($intext, $outfile = false, $q = 85, $rgb_color = '0,0,0', $rgb_bg_color = '255,255,255')
{
try {
ob_start();
$tab = $this->encode($intext);
$err = ob_get_contents();
ob_end_clean();
if ($err != '') {
QRtools::log($outfile, $err);
}
$maxSize = (int) (QR_JPG_MAXIMUM_SIZE / (count($tab) + 2 * $this->margin));
QRimage::jpg($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin, $q, $rgb_color, $rgb_bg_color);
} catch (Exception $e) {
QRtools::log($outfile, $e->getMessage());
}
}
示例5: list
$out[] = '';
} else {
$out[] = $matches[0][3];
}
}
return $out;
}
// validate signature
list($key, $salt) = qsot_fetch_defines(array('NONCE_KEY', 'NONCE_SALT'), $d['p']);
$test = sha1($key . @json_encode($d) . $salt);
if ($test != $sig) {
die($debug ? '<!-- hash mismatch : ' . $sig . ' / ' . $test . ' -->' : '');
}
// end abuse protection
include_once 'qrlib.php';
//QRCode::png($d, false, 'L', 3, 1);
$enc = QRencode::factory('L', 3, 1);
$outfile = false;
try {
ob_start();
$tab = $enc->encode($d['d']);
$err = ob_get_contents();
ob_end_clean();
if ($err != '') {
QRtools::log($outfile, $err);
}
$maxSize = (int) (QR_PNG_MAXIMUM_SIZE / (count($tab) + 2 * $enc->margin));
QRimage::jpg($tab, $outfile, 2.5, $enc->margin, 100);
} catch (Exception $e) {
QRtools::log($outfile, $e->getMessage());
}