Strengthen RGB colors using c#
I need to strengthen the RGB channel/colors with an number that the user can choose. I've got the following code , but i'm not sure that it's correct. Can somebody tell me what i can change or can do better.
int value = int.Parse(t开发者_开发百科extBoxConstante.Text);
for (int y = 0; y < myPic.Height; y++)
{
for (int x = 0; x < myPic.Width; x++)
{
Color c = myPic.GetPixel(x, y);
myPic.SetPixel(x, y, Color.FromArgb(c.R * value /10, c.G * value/10, c.B * value/10));
}
}
I've not run your code, but I suspect you're having problems with c# lack of implicit double casting... Try rewriting it this way:
.FromArgb((int)(c.R * ((double)value /10)), [the rest wrapped the same way]
精彩评论