Start to put a try catch around your code and show any error in a MessageBox.
public static double CALC_BRIGHTNESS(Bitmap bm)
{
Bitmap tmpBmp = null;
try
{
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString));
}
finally
{
if (tmpBmp != null)
tmpBmp.Dispose();
}
}
Also how and where is the variable
pixels
declared?