tạo ra 1 class Capture.cs
Mã:
public class Capturer
{
[DllImport("coredll.dll")]
public static extern int BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, uint dwRop);
[DllImport("coredll.dll")]
private static extern IntPtr GetDC(IntPtr hwnd);
const int SRCCOPY = 0x00CC0020;
public static Bitmap Snapshot(Rectangle rectangle, IntPtr wnd)
{
try
{
IntPtr deviceContext = wnd;
Bitmap capture = new Bitmap(rectangle.Width, rectangle.Height);
Graphics deviceGraphics = Graphics.FromHdc(deviceContext);
Graphics captureGraphics = Graphics.FromImage(capture);
BitBlt(captureGraphics.GetHdc(), 0, 0, rectangle.Width, rectangle.Height, deviceGraphics.GetHdc(), rectangle.Left, rectangle.Top, SRCCOPY);
captureGraphics.Dispose();
return capture;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
return null;
}
}
}
form sử dụng
Mã:
Craphics g1 = this.CreateGraphics();
Images img = new Bitmap(Capturer.Snapshot(new Rectangle(0, 0, this.Width, this.Height), g1.GetHdc()));
Pallet nhựa Long An đã trở thành một trong những lựa chọn phổ biến cho nhu cầu vận chuyển và lưu trữ hàng hóa trong nhiều ngành công nghiệp. Với đặc tính nhẹ nhàng, chắc chắn và dễ vận chuyển, các...
Thanh lý pallet nhựa Long An giá rẻ