I am trying to apply brightness/contrast on a image using track bar, since applying on image taking long time. When track bar is scrolled, it's not smooth, it's getting lagged on my form. Here is my code,is this right method for separating out worker thread from UI (there is no improvement in user experience though)?
private void bright_tbr_ValueChanged(object sender, EventArgs e)
{
brightness = bright_tbr.Value;
contrast = contrast_tbr.Value;
toolTip1.SetToolTip(bright_tbr, brightness.ToString());
Thread thread = new Thread(new ThreadStart(applyBandC));
thread.IsBackground = true;
thread.Start();
}
private void applyBandC()
{
this.Invoke((MethodInvoker)delegate()
{
lock (this)
{
create_pixmap(brightness, contrast, 0, 0, 255, 255);
Bitmap bmp1 = new Bitmap(bmp);
BitmapData data1 = bmp1.LockBits(new Rectangle(0, 0, bmp1.Width, bmp1.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
MapLUT(bmp1.Height, bmp1.Width, data1.Scan0);
bmp1.UnlockBits(data1);
pictureBox2.Image = bmp1;
}
}
);
}