截当前窗体的根据你的FORM改一下坐标
///
/// 获取整个屏幕的图片
///
///
public static Image GetScreenImage()
{
Image image = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(image);
g.CopyFromScreen(new Point(0, 0), new Point(0, 0), Screen.PrimaryScreen.Bounds.Size);
return image;
}
///
/// 保存Jpg格式
///
/// 图像对象
/// 保存路径
/// 图像质量,1-100的范围,一般设置到60-80,太高图片容量会比较大
public static void SaveJpg(Image image, string path, long value)
{
ImageCodecInfo icInfo = null;
ImageCodecInfo[] infos = ImageCodecInfo.GetImageEncoders();
foreach (ImageCodecInfo info in infos)
{
if (info.MimeType == "image/jpeg")
{
icInfo = info;
break;
}
}
EncoderParameters ep = new EncoderParameters(2);
ep.Param[0] = new EncoderParameter(Encoder.Quality, value);//质量,定义图片的清晰度
ep.Param[1] = new EncoderParameter(Encoder.Compression, (long)EncoderValue.CompressionLZW);//压缩,似乎无效果
image.Save(path, icInfo, ep);
image.Dispose();
}