the trackbar move jerkily.
My code is like that:
- Code: Select all
private int ValidateGrayLevel(int graylevel)
{
if (graylevel < 0) return 0;
if (graylevel > 255) return 255;
return graylevel;
}
private void ChangeBrightness()
{
int value = this.adjustment1.Value;
Color c;
for (int i = 0; i < this.bitmapsource.Width; i++)
{
for (int j = 0; j < this.bitmapsource.Height; j++)
{
c = this.bitmapsource.GetPixel(i, j);
int r = this.ValidateGrayLevel(c.R + value);
int g = this.ValidateGrayLevel(c.G + value);
int b = this.ValidateGrayLevel(c.B + value);
this.bitmapdisplay.SetPixel(i, j, Color.FromArgb(r, g, b));
}
}
this.displayImage1.ImageDisplay = this.bitmapdisplay;
}
private void adjustment1_ValueChanged(object sender, EventArgs e)//track bar change its value
{
this.ChangeBrightness();//change brightness
}
so please tell me how to make it move smoothly