ユーザーのデスクトップ全体を画像としてキャプチャしようとしています。私はこれを次のように行います:
public Bitmap CaptureScreen()
{
// Set up a bitmap of the correct size
Bitmap CapturedImage = new Bitmap((int)SystemInformation.VirtualScreen.Width,
(int)SystemInformation.VirtualScreen.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
// Create a graphics object from it
System.Drawing.Size size = new System.Drawing.Size((int)SystemInformation.VirtualScreen.Width, (int)SystemInformation.VirtualScreen.Height);
using (Graphics g = Graphics.FromImage(CapturedImage))
{
// copy the entire screen to the bitmap
g.CopyFromScreen(0, 0, 0, 0,
size, CopyPixelOperation.SourceCopy);
}
return CapturedImage;
}
PixelFormat
ただし、をからFormat32bppArgb
に変更しようとするとFormat16bppArgb1555
、OutOfMemoryException
品質が低下したことを考えると、よくわかりません。
何か案は?または、どうすればこの画像の品質を下げることができますか(非常に頻繁にネットワーク経由で送信されるため)