'imagecolorat'和透明度 [英] 'imagecolorat' and transparency
本文介绍了'imagecolorat'和透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在图片
How it's possible to get the transparency value of a pixel on an image?
'imagecolorat'仅选取图像中指定位置的像素颜色的索引。使用该索引,我可以获得RGB值,但不能获得透明值。
'imagecolorat' picks only the index of the color of the pixel at the specified location in the image. With that index I can get the RGB values but not the transparent one.
希望您理解,并提前感谢您。
Hope you understand, and thank you in advance.
推荐答案
据我所知,透明度值由函数 imagecolorat
返回。你可以尝试:
As far as I know, the transparency value is returned by the function imagecolorat
. Could you try:
$color = imagecolorat($image, $x, $y);
$transparency = ($color >> 24) & 0x7F;
透明度是0到127之间的整数,所以我们需要屏蔽32位的前8位颜色整数。
The transparency is a integer between 0 and 127 so we need to mask the first 8 bits of the 32bit color integer.
这篇关于'imagecolorat'和透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文