我有一個圖像,我正在調整大小,drawString和FillEllipse
。
有很多點(FillEllipse)需要顯示n
位圖,所以我使用for
循環。
下面是代碼:加載位圖需要很長的時間
using (System.Drawing.Graphics Gfx = System.Drawing.Graphics.FromImage(OrginalBitmap))
{
Gfx.SmoothingMode = SmoothingMode.HighQuality;
Gfx.CompositingQuality = CompositingQuality.HighQuality;
Gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
Gfx.PixelOffsetMode = PixelOffsetMode.HighQuality;
foreach (var points in SelectedPoints)
{
Gfx.FillEllipse(
Brushes.Yellow,new Rectangle(points.X , points.Y, 8, 8));
Gfx.DrawString("M", new Font("Arial",8),
Brushes.Yellow, points.X, points.Y);
//points.X and points.X are the points that needs to be drawn on bitmap(particular location).
}
}
((IDisposable)OrginalBitmap).Dispose;
加載繪製位圖的需要,如果有在SelectedPoints多點時間很長。 性能急劇下降,加載佔用太多內存。 請讓我知道該怎麼做。
在此先感謝。
明顯的建議是嘗試改變質量,看看是否有效果。 – 2012-04-17 11:55:29
只需注意一點:由於您位於使用(...)塊內,因此您不需要'Gfx.Dispose();''Gfx'被放置在塊的外面。 – Marco 2012-04-17 11:55:33
另外,你是否有你想要製作的示例圖片,也許有更簡單的你可以做的。 – 2012-04-17 11:56:39