いくつかの図形を描き、頂点でキャッチして頂点を移動するアプリケーションがあります。 List
に図形の頂点を格納し、PictureBox.Image
に割り当てられたビットマップにオブジェクトの全リストを再描画します(頂点がキャッチされ、マウスが移動するとき)。 5つ以上の図形を追加すると、動く頂点は遅れます。ここにコードの一部があります:ピクチャボックスでのビットマップ描画の遅れ
private void DrawFullList()
{
if (pictureBox2.Image != null)
{
pictureBox2.Image.Dispose();
g.Dispose();
}
graphic = new Bitmap(pictureBox2.Width, pictureBox2.Height);
g = Graphics.FromImage(graphic);
pictureBox2.Image = graphic;
for (int i = 0; i < PointsList.Count; i++)
Draw(BrushList[i], PointsList[i]);
}
private void Draw(Brush brush, Point[] points)
{
Pen PathPen = new Pen(brush);
PathPen.Width = 3;
if (points.Length == 2)
g.DrawLine(PathPen, points[0], points[1]);
else
g.FillPolygon(brush,points);
pictureBox2.Image = graphic;
}
とにかくそれをimporveするには?私はgraphic.Clear(Color.Transparent)
にしようとしていましたが、ビットマップのサイズを変更する方法はありませんでした(この機能は、ウィンドウのサイズを変更するときに使用されます)。
ヒント?
[C#WinForms - SLOW GDI +ではないC#GDIライブラリを知っている方](http://stackoverflow.com/questions/6391911/c-sharp-winforms-anyone-know-of-ac-sharp- gdi-library-not-slow-gdi) –