110,539
社区成员
发帖
与我相关
我的任务
分享
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll", EntryPoint = "BitBlt")]
[return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool BitBlt([System.Runtime.InteropServices.InAttribute()] System.IntPtr hdc, int x, int y, int cx, int cy, [System.Runtime.InteropServices.InAttribute()] System.IntPtr hdcSrc, int x1, int y1, uint rop);
private void button3_Click(object sender, EventArgs e)
{
this.BackgroundImage = GetScreenBmp(new Rectangle(0, 0, Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height));
}
public Bitmap GetScreenBmp(Rectangle rect)
{
Bitmap screenBmp = new Bitmap(rect.Width, rect.Height);
using (Graphics g = Graphics.FromImage(screenBmp))
{
g.CopyFromScreen(rect.X, rect.Y, 0, 0, rect.Size);
Cursor.Current.Draw(g, new Rectangle(Cursor.Position.X, Cursor.Position.Y, 33, 33));
}
return screenBmp;
}
不就是这样用吗,
为什么要使用CopyPixelOperation.SourceCopy参数,怎么用的