Question

I am using a method to get a pixel of the image to check if this point is transparent or not. I am using GetPixel that returns a System.Drawing.Color with a 32bit color info.

This struct have the "A" property where I can get the alpha value of pixel, according to this MSDN topic.

Code:

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
}

How are the correct way to check if a pixel is opaque or not?

Was it helpful?

Solution

For the alpha channel the values are:

Opaque = 255
Translucent = 1-254
Transparent = 0
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top