获取png图像的像素的alpha值? [英] Get a pixel's alpha value of a png image?
本文介绍了获取png图像的像素的alpha值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码:
$img = imagecreatefrompng("image.png");
$col = imagecolorat($img, $x, $y);
$alpha = (($col >> 24) & 0x7F);
但 alpha 值始终为 127,即使 ($x,$y)
处的像素在原始图像中是透明的.
but the alpha value is always 127, even if the pixel at ($x,$y)
is transparent in the original image.
推荐答案
是的,你可能对 html canvas alpha 范围感到困惑
ya you right , you may have confused with html canvas alpha ranges
在 php 端工作时,您的 alpha 将始终为 0 到 127 # 0 表示不透明,127 表示透明
when working on php side your alpha will be always 0 to 127 # 0 mean non transparent and 127 mean transparent
在使用前端 HTML 画布时,您的 alpha 范围将是 0 到 255 # 0 表示透明 &255表示不透明
when working with front end HTML canvas your alpha range will be 0 to 255 # 0 mean Transparent & 255 mean non transparent
这篇关于获取png图像的像素的alpha值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文