[英]Strengthen RGB colors using c#
I need to strengthen the RGB channel/colors with an number that the user can choose. 我需要使用用户可以选择的数字来增强RGB通道/颜色。 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(textBoxConstante.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));
}
}
我尚未运行您的代码,但我怀疑您在使用c#缺少隐式双重转换时遇到了问题...尝试通过以下方式重写它:
.FromArgb((int)(c.R * ((double)value /10)), [the rest wrapped the same way]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.