int times = 10;
//no. 2
System.Drawing.Bitmap bmp1 = new System.Drawing.Bitmap(file);
Stopwatch sw = new Stopwatch();
sw.Start();
for (int number = 0; number < times; number++)
for (int i = 0; i < bmp1.Width; i++)
for (int j = 0; j < bmp1.Height; j++)
{
var c1 = bmp1.GetPixel(i, j);
}
sw.Stop();
Console.WriteLine($"{nameof(Bitmap)}:{sw.ElapsedMilliseconds}");
//no. 1
OldLockBitmap oldLockBitmap = new OldLockBitmap(bmp1);
oldLockBitmap.LockBits();
sw.Restart();
for (int number = 0; number < times; number++)
for (int i = 0; i < bmp1.Width; i++)
for (int j = 0; j < bmp1.Height; j++)
{
var c1 = oldLockBitmap.GetPixel(i, j);
}
sw.Stop();
oldLockBitmap.UnlockBits();
Console.WriteLine($"{nameof(OldLockBitmap)}1:{sw.ElapsedMilliseconds}");