我有以下代碼:System.Drawing中對象的非託管資源配置
using System.Drawing;
...
Graphics _graphics = Graphics.FromImage(...)
...
public void Draw(Stream stream, Rectangle rect, Color color) {
_graphics.FillRectangle(new SolidBrush(Color), 0, 0, Width, Height);
_graphics.DrawImage(new Bitmap(stream), rect);
}
我應該圍繞着使用上的new Bitmap(...)
的drawImage? 同樣的問題上new SolidBrush(...)
是的,我想你應該。我也會爲非託管資源做到這一點。它可能允許GC早些時候處理它們。 –