php使用qrcode库生成二维码后,向二维码中心位置添加小图标,小图标色彩变暗

如题:
php使用qrcode库生成二维码后,向二维码中心位置添加小图标,小图标色彩变暗

实际使用的小图标为:

请问这是什么原因?

以下是生成二维码之后,向二维码中心位置添加小图标的代码:
$qr = imagecreatefromstring($this->qr_binary); $logo = imagecreatefromstring($this->logo_binary); $qr_width = imagesx($qr);//二维码图片宽度 $qr_height = imagesy($qr);//二维码图片高度 $logo_width = imagesx($logo);//logo图片宽度 $logo_height= imagesy($logo);//logo图片高度 $logo_qr_width = $qr_width / 5; $scale = $logo_width/$logo_qr_width; $logo_qr_height = $logo_height/$scale; $from_width = ($qr_width - $logo_qr_width) / 2; //重新组合图片并调整大小 imagecopyresampled($qr, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height); imagepng($qr, $file_path);

请高人指点!!!

第1个回答  2015-12-10
最可能的原因就是 logo图片是带alpha通道的图片 也就是透明 可以用
imagealphablending 设置一下色彩混合模式
追问

设置色彩混合模式之后没有任何改变
$qr = imagecreatefromstring($this->qr_binary);
$logo = imagecreatefromstring($this->logo_binary);
imagealphablending($logo, true);

追答

第二个参数用flase

追问

还是不行啊

第2个回答  2017-07-06
if (imageistruecolor($logo_url))
{
imagetruecolortopalette($logo_url, false, 65535);//添加这行代码来解决颜色失真问题

}本回答被网友采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网