首页 > 编程语言 >Random 项目总结 -07 截取当前程序图片

Random 项目总结 -07 截取当前程序图片

时间:2024-04-20 22:26:20浏览次数:23  
标签:HandleRef 07 g1 int 截取 Random DateTime new g2

[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern int BitBlt(HandleRef hDC, int x, int y, int nWidth, int nHeight, HandleRef hSrcDC, int xSrc, int ySrc, int dwRop);

private void screenshut(int intx,int inty,int intwidth,int inthigh,int intleft,int intright)
{

DateTime ndate = new DateTime();
ndate = DateTime.Now;
string filename = ndate.ToFileTime().ToString();
filepath = @"c:\myresult\" + filename + ".bmp";

Rectangle rect = new Rectangle();

rect = this.Bounds;
Graphics g1 = this.CreateGraphics();
Bitmap mybmp = new Bitmap(intwidth, inthigh, g1);

Graphics g2 = Graphics.FromImage(mybmp);
IntPtr dc1 = g1.GetHdc();
HandleRef hdcsrc = new HandleRef(null, dc1);
IntPtr dc2 = g2.GetHdc();
HandleRef hdcsave = new HandleRef(null, dc2);

const int scrcop = 0xcc0020;
BitBlt(hdcsave, intx, inty, intwidth, inthigh, hdcsrc, intleft, intright, scrcop);
g1.ReleaseHdc(dc1);
g2.ReleaseHdc(dc2);

mybmp.Save(filepath, ImageFormat.Bmp);

}

标签:HandleRef,07,g1,int,截取,Random,DateTime,new,g2
From: https://www.cnblogs.com/lionmxs/p/18148287

相关文章