【发布时间】:2017-12-28 13:57:22
【问题描述】:
我想在 Outlook 中保存已完成表单的图像。我正在使用 VSTO Outlook 插件。我能够捕获全屏图像,但我对表单区域本身没有运气。有人有什么想法吗?
var bmpScreenshot = new Bitmap(this.Width,
this.Height,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
var grxScreenshot = Graphics.FromImage(bmpScreenshot);
grxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y,
0,
0,
Screen.PrimaryScreen.Bounds.Size,
CopyPixelOperation.SourceCopy);
string outputFileName = @"C:\Users\63530\Desktop\image.png";
using (MemoryStream memory = new MemoryStream())
{
using (FileStream fs = new FileStream(outputFileName, FileMode.Create, FileAccess.ReadWrite))
{
bmpScreenshot.Save(memory, ImageFormat.Png);
byte[] bytes = memory.ToArray();
fs.Write(bytes, 0, bytes.Length);
}
}
【问题讨论】:
标签: c# .net screen-capture