如何解决ImageColorAt不从ImageCreateTrueColor返回alpha
尝试进行一些图像处理时,我发现imagecreatetruecolor()
似乎只有24位。我进行了imagecopyresampled()
保留图像中的Alpha所需的动作。
$bottles = imagecreatefrompng("bottles.png");
$output = imagecreatetruecolor(32,32);
imagecolortransparent($output,imagecolorallocatealpha($output,127));
imagealphablending($output,true);
imagesavealpha($output,false);
imagecopyresampled($output,$bottles,$type*32,32,32);
然后我想在需要了解每个像素的alpha通道的地方做一些特殊的操作,但是当我执行以下操作时:
for($y = 0; $y < 32; $y++)
{
for($x = 0; $x < 32; $x++)
{
$c = imagecolorat($output,$x,$y);
$rgb = imagecolorsforindex($output,$c);
echo $c."\n";
print_r($rgb);
$c
对于图片中没有颜色的所有部分(或在该透明度下仍为白色的所有部分)返回16777215
,并返回{{1} }显示为零。但是,如果我将$rgb["alpha"]
更改为$output
,则$bottles
返回$c
。看起来更像是32位数字,实际上2130706432
显示了各种数字。
因此,如果$rgb["alpha"]
不返回imagecolorat()
的Alpha,我如何找出其Alpha值?我在imagecreatetruecolor()
之前更改了imagealphablending()
和imagesavealpha()
组合(真+真,真+假,假+真,假+假),但它仍返回24位数字
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。