其实还是比较简单的。找到phpqrcode/phpqrcode.php,大概997行开始:
private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4)
{
$h = count($frame);
$w = strlen($frame[0]);
$imgW = $w + 2*$outerFrame;
$imgH = $h + 2*$outerFrame;
$base_image =ImageCreate($imgW, $imgH);
$col[0] = ImageColorAllocate($base_image,255,255,255);
$col[1] = ImageColorAllocate($base_image,0,0,0);
//imagefill($base_image, 0, 0, $col[0]);//这一行注释掉,并在下面增加如下三行
$bg = imagecolorallocatealpha($base_image , 0 , 0 , 0 , 127);
imagealphablending($base_image, false);
imagefill($base_image, 0, 0, $bg);
for($y=0; $y<$h; $y++) {
for($x=0; $x<$w; $x++) {
if ($frame[$y][$x] == '1') {
ImageSetPixel($base_image,$x+$outerFrame,$y+$outerFrame,$col[1]);
}
}
}
发表回复