开发者

Strengthen RGB colors using c#

开发者 https://www.devze.com 2023-04-11 08:53 出处:网络
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.

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]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号