Why graphics drawing speed is slower in C # than VB6

Hi, I wonder why normal graphics speed is much slower than VB6 in C # code, here is an example code that does the same in VB6 and C #, it takes 1.7 seconds in VB6 on my computer and 4.2 seconds in C # Can someone please tell me why and also if there is a better and faster way in C #.

thank

C # code

Bitmap MyBitmap = new Bitmap(1024, 768);
Graphics g = Graphics.FromImage(MyBitmap);
DateTime STime = DateTime.Now;
Pen MyPen = new Pen(Color.Black);
for (int i = 0; i < 100000; i++)
{
    g.DrawLine (MyPen, 0, 0, 1024, 768);
}
MessageBox.Show(DateTime.Now.Subtract(STime).TotalMilliseconds.ToString());

VB6 Code:

Me.AutoRedraw = True
t = Timer
For i = 1 To 100000
    Me.Line (0, 0)-(1024, 768), 0
Next
MsgBox (Timer - t)
+3
source share
1 answer

VB6 goes straight to GDI. C # using System.Drawing uses GDI +. GDI + is flattened and uses 32bpp. Basically, there is overhead.

+4
source

Source: https://habr.com/ru/post/1773100/


All Articles