Iam using this piece of code to convert image to black and white using hscrollbar :
private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
Bitmap BAndW = new Bitmap(image.Width, image.Height);
for (int i = 0; i < image.Width; i++)
{
for (int j = 0; j < image.Height; j++)
{
Color C = image.GetPixel(i, j);
int newVal = ((C.R + C.G + C.B) / 3);
// newVal = HorizontalScroll.Value;
newVal = newVal > e.NewValue ? 255 : 0;
Color newC = Color.FromArgb(newVal, newVal, newVal);
BAndW.SetPixel(i, j, newC);
}
}
pictureBox1.Image = BAndW;
}
the problem is the scrollbar took like 2s to change the color every time I scroll what should I do to decrease this time period ?