intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Cách chụp hình một form trong .NET

Chia sẻ: Abcdef_45 Abcdef_45 | Ngày: | Loại File: PDF | Số trang:3

57
lượt xem
3
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Cách chụp hình 1 form rồi đưa ra file dạng { enum ImageFormat } . ở đây ví dụ file *.jpeg [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")] // Lấy API ra :D private static extern bool BitBlt( IntPtr hdcDest, // handle to destination DC int nXDest, // x-coord of destination upper-left corner int nYDest, // y-coord of destination upper-left corner int nWidth, // width of destination rectangle int nHeight, // height of destination rectangle IntPtr hdcSrc, // handle to source DC int nXSrc, // x-coordinate of source upper-left corner int nYSrc, // y-coordinate of source upper-left corner System.Int32 dwRop // raster operation code ); //...

Chủ đề:
Lưu

Nội dung Text: Cách chụp hình một form trong .NET

  1. Cách chụp hình một form trong .NET Cách chụp hình 1 form rồi đưa ra file dạng { enum ImageFormat } . ở đây ví dụ file *.jpeg [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")] // Lấy API ra :D private static extern bool BitBlt( IntPtr hdcDest, // handle to destination DC int nXDest, // x-coord of destination upper-left corner int nYDest, // y-coord of destination upper-left corner int nWidth, // width of destination rectangle int nHeight, // height of destination rectangle IntPtr hdcSrc, // handle to source DC int nXSrc, // x-coordinate of source upper -left corner int nYSrc, // y-coordinate of source upper -left corner System.Int32 dwRop // raster operation code ); // chép nguyên xi định nghĩa cho dễ hiểu // Lấy đối tượng IntPtr dc1 = aGraphicsObject.GetHdc();
  2. // Tạo button rồi xử lý chụp hình form private void Button_Click(object sender, System.EventArgs e) { Graphics g1 = this.CreateGraphics(); Image MyImage = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height, g1); Graphics g2 = Graphics.FromImage(MyImage); IntPtr dc1 = g1.GetHdc(); IntPtr dc2 = g2.GetHdc(); BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 0, 0, 13369376); g1.ReleaseHdc(dc1); g2.ReleaseHdc(dc2); MyImage.Save(@"c:\Captured.jpg", ImageFormat.Jpeg); Nguồn: congdongcviet.com [C#] Lấy OS Info Đoạn code khá đơn giản mà hữu hiệu
  3. using System; class GetOSVersion { static void GetOSVersion(PlatformID pID, Version ver) { OperatingSystem os = new OperatingSystem(pID,ver); PlatformID platform = os.Platform; Version version = os.Version; Console.WriteLine("Platform : {0,-15} Version : {1}", platform,version); } static void Main() { Console.WriteLine("Your OS Information : \n"); GetOSVersion(Environment.OSVersion.Platform,Environment.OSVersio n.Version); } } Nguồn: congdongcviet.com
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2