none
内存不足的问题 RRS feed

  • 问题

  •         #region 重绘
    
            protected override void OnPaint(PaintEventArgs e)
            {
                // try
                {
    
                    Bitmap memBmp = new Bitmap(pCanvas.Width, pCanvas.Height);
    
                    using (Graphics gMem = Graphics.FromImage(memBmp))
                    {
                        //  
                        pCanvas.Image = memBmp;
                        WSnap _wSnap = new WSnap(this);
                        Color canvasColor = Color.FromArgb(0xE5, 0xE5, 0xE5);
    
                        gMem.Clear(canvasColor);
    
                        Canvas.InitCanvas(gMem, _canvas, pCanvas, _zoom);
    
                        gMem.DrawImage(memBmp, pCanvas.ClientRectangle.X, pCanvas.ClientRectangle.Y);
    
                        // 高清,平滑 
                        gMem.SmoothingMode = SmoothingMode.HighQuality;
                        gMem.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        gMem.CompositingQuality = CompositingQuality.HighSpeed;
    
          
    
                        _wCmd._wGLine.Draw(gMem, _canvas, this, _wCmd, _drawContainer, this.Font, _zoom);
    
                        if (IsDrawing)
                        {
                            _wGraph.DrawOnMouse(gMem, _canvas, pCanvas, _wCmd, _drawContainer._dcMouseMovePoint, _zoom);
                        }
    
                        if (GeneralCmd._gcNewDraw == false)
                        {
                            _wGraph.DrawClickPoint(gMem, _canvas, _wCmd, _drawContainer, _zoom);
                        }
    
                        if (_lockSnap)
                        {
                            _wSnap.DrawSnap(gMem, _zoom);
                        }
    
                        using (Graphics gg = pCanvas.CreateGraphics())
                        {
                            gg.DrawImage(memBmp, pCanvas.ClientRectangle.X, pCanvas.ClientRectangle.Y);
                        }
                    }
                }
                //catch
                {
                }
            }
            #endregion

    我在重绘的地方 就写这些。。里面的实现无关紧要。 我的pCanvas是个画布控件,Bitmap我也尝试过using来释放,可是一释放就出错。。不知道怎么办。。

    我在画图的时候就会报内存不足有的时候 又不会报内存不足 不知道为什么。。

    2012年10月8日 8:29

全部回复