我正在使用一种获取图像像素的方法来检查该点是否透明。我正在使用 GetPixel,它返回具有 32 位颜色信息的 System.Drawing.Color。
根据这个 MSDN topic,这个结构有“A”属性,我可以在其中获取像素的 alpha 值.
代码:
using (Bitmap bmp = new Bitmap(path))
{
Color pixel = bmp.GetPixel(0, 0);
if (pixel.A == 0)
// This is a fully transparent pixel
else
// This is not a fully transparent pixel
}
检查像素是否不透明的正确方法是什么?
请您参考如下方法:
对于 alpha channel ,值为:
Opaque = 255
Translucent = 1-254
Transparent = 0
