using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropServices; class Program { static void Main() { Bitmap bitmap = new Bitmap(100, 100, PixelFormat.Format32bppArgb); // Create a graphics object from the bitmap using (Graphics graphics = Graphics.FromImage(bitmap)) { // Create a pen for drawing the line Pen pen = new Pen(Color.Black, 2); // Draw a line on the bitmap graphics.DrawLine(pen, new Point(0, 0), new Point(100, 100)); } // Save the bitmap to a file bitmap.Save("line.bmp", ImageFormat.Bmp); } }This code creates a 100x100 bitmap and draws a line from the top-left corner to the bottom-right corner using a pen with a black color and a thickness of 2. The resulting bitmap is saved to a file named "line.bmp". The System.Drawing.SafeNativeMethods.Gdip class is a part of the .NET Framework and is included in the System.Drawing.dll library.