本文介绍了' imagecolorat'和透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得图像上像素的透明度值?

"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'和透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 07:02