2013年2月27日水曜日

C# 6行コードでスクリーンキャプチャを取得する

  1.  Image img = new Bitmap(300, 200); 
  2. Graphics g = Graphics.FromImage(img);
  3. g.CopyFromScreen(
        new Point(Cursor.Position.X - 150, Cursor.Position.Y - 25),
        new Point(0, 0), new Size(300, 200));
  4. IntPtr dc1 = g.GetHdc();
  5. g.ReleaseHdc(dc1); 
  6. img.Save("c:\\1.jpeg");

0 件のコメント: