我試圖捕獲用戶的整個桌面作爲圖像。我這樣做以下列方式:降低位圖質量產生OutOfMemoryException
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;
}
但是,如果我嘗試從Format32bppArgb
的PixelFormat
更改爲Format16bppArgb1555
,它產生的OutOfMemoryException
,我真的不明白,考慮到我已經降低了質量。
任何想法?或者我如何能降低這種圖像的質量(如將處於相當頻繁地通過網絡發送)
* *是否發生OOM?我會想象它是在轉換過程中,而不是最終結果。 – 2012-07-06 19:21:02
它發生在線 '使用(圖形g = Graphics.FromImage(CapturedImage))' – 2012-07-06 19:26:35