var source = new Bitmap(2000,2000);
var sw = Stopwatch.StartNew();
for (int i = 0; i < 10000; i++)
{
//var copy = new Bitmap(source);
var copy = source.Clone() as Bitmap;
}
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds);
The code runs in under 10 ms with my System, and the Ram usage stayes the same. With this timer and Ram usage results there cannot be a copy of the Bitmapdata.
But when I do this.
var copy2 = source.Clone() as Bitmap;
for (int x = 0; x < copy2.Width; x++)
{
for (int y = 0; y < copy2.Height; y++)
{
copy2.SetPixel(x, y, Color.Red);
}
}
// copy2 is Red
// source is NOT!!
How is this possible?