I have a Color, and I have a method that should return a more “transparent” version of that color. I tried the following method:
public static Color SetTransparency(int A, Color color)
{
return Color.FromArgb(A, color.R, color.G, color.B);
}
but for some reason, no matter what the A is, the returned Color‘s transparency level just won’t change.
Any idea?
Well, it looks okay to me, except that you’re using
Color.R(etc) instead ofcolor.R– are you sure you’re actually using the returnedColorrather than assuming it will change the existing color? How are you determining that the "transparency level" won’t change?Here’s an example showing that the alpha value is genuinely correct in the returned color:
No surprises there. It would be really helpful if you’d provide a short but complete program which demonstrates the exact problem you’re having. Are you sure that whatever you’re doing with the color even supports transparency?
Note that this method effectively already exists as
Color.FromArgb(int, Color).