Projelerinizde kullanabileceğiniz klavyedeki PrintScreen tuşunun görevini yapan class örneği...
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System;
public static class Screenshot
{
public static void TakeScreenShot(string FileName)
{
if (string.IsNullOrEmpty(FileName))
throw new ArgumentNullException("FileName");
using (Bitmap TempBitmap = Screenshot.TakeScreenShot())
{
TempBitmap.Save(FileName);
}
}
public static Bitmap TakeScreenShot()
{
Rectangle TotalScreenRect = Rectangle.Empty;
foreach (Screen CurrentScreen in Screen.AllScreens)
{
TotalScreenRect = Rectangle.Union(TotalScreenRect, CurrentScreen.Bounds);
}
Bitmap TempBitmap = new Bitmap(TotalScreenRect.Width, TotalScreenRect.Height, PixelFormat.Format32bppArgb);
using (Graphics TempGraphics = Graphics.FromImage(TempBitmap))
{
TempGraphics.CopyFromScreen(TotalScreenRect.X, TotalScreenRect.Y, 0, 0, TotalScreenRect.Size, CopyPixelOperation.SourceCopy);
}
return TempBitmap;
}
}
Hiç yorum yok:
Yorum Gönder