C#仅在屏幕的一部分上绘制

时间:2018-11-22 08:56:02

标签: c#

我正在尝试使用c#在屏幕上绘制,但似乎只能绘制几个像素。也是我登录时

   Console.WriteLine(Screen.PrimaryScreen.Bounds.Width);
   Console.WriteLine(Screen.PrimaryScreen.Bounds.Height);

记录数:1620、1080,这是我屏幕尺寸的一半...

这是我尝试绘制的代码:

 [DllImport("User32.dll")]
 public static extern IntPtr GetDC(IntPtr hwnd);
 [DllImport("User32.dll")]
 public static extern void ReleaseDC(IntPtr hwnd, IntPtr dc);

 static void Main(string[] args) {
    Console.WriteLine(Screen.PrimaryScreen.Bounds.Width);
    Console.WriteLine(Screen.PrimaryScreen.Bounds.Height);

    IntPtr desktopPtr = GetDC(IntPtr.Zero);
    Graphics g = Graphics.FromHdc(desktopPtr);
    SolidBrush b = new SolidBrush(Color.White);
    g.FillRectangle(b, new Rectangle(0, 0, 16000, 16000));
}

希望有人可以帮助我,埃里亚斯:)

0 个答案:

没有答案