using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using Emgu.CV;
using Emgu.CV.Structure;
namespace RichCreator.Utility.Captures
{
public class ScreenCapture
{
private DesktopDuplicationCapture capture = new DesktopDuplicationCapture();
private BitBltCapture bitCapture = new BitBltCapture();
private ScreenCapture()
{}
///
/// 截屏
///
///
public Bitmap CaptureScreen()
{
Bitmap bm= capture.CaptureScreen();
if (bm == null)
{
bm = bitCapture.CaptureScreen();
}
return bm;
}
public Image CaptureScreenReturnImage()
{
Bitmap bitmap = CaptureScreen();
Image image = new Image(bitmap);
return image;
}
///
/// 截取指定区域
///
///
///
///
///
///
public Bitmap CaptureScreen(Int32 x,Int32 y,Int32 width,Int32 height)
{
using (Bitmap bm = CaptureScreen())
{
Bitmap screenRect = bm.Clone(new Rectangle(x, y, width, height), bm.PixelFormat);
return screenRect;
}
}
#region sington
private static ScreenCapture instance;
private static object lockHelper = new object();
public static ScreenCapture Instance
{
get
{
if (instance == null)
{
lock (lockHelper)
{
if (instance == null)
{
instance = new ScreenCapture();
}
}
}
return instance;
}
}
#endregion
}
}