当前位置:编程学习 > C#/ASP.NET >>

Winform 绘制大图的问题

我的Winform中需要将一个很大的位图画在界面上,并且进行移动,选框等操作.采用了Graphics.DrawImage()将图在Paint中进行绘制在界面中.但是对图的任何操作都比较卡.

使用了双缓冲也不行.

但是我发现一个很奇怪的问题就是在图像画到界面上后再调用一次图像对象的Clone方法:

(this.imgEditBox.Image as Bitmap).Clone(new Rectangle(0,0,1,1),PixelFormat.Format24bppRgb);//这个方法只是复制了一个色素,而且也没有使用复制的位图

调用Clone方法后整个图像任何操作都无比的流畅.但是如果再弹出一个窗口在绘图区域上后又不流畅了.再界面上作个按钮.只要不流畅了调用一下Clone后就又流畅了.百思不得其解,望高人指点.
我作的是一个个学自动检测系统:Paint事件中的部分代码如下:
 Graphics gs = e.Graphics;
            Rectangle destRect = new Rectangle(0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height);
            Rectangle srcRect = new Rectangle();
            srcRect.Width = (int)Math.Round(this.Width / this.rate);
            srcRect.Height = (int)Math.Round(this.Height / this.rate);
            srcRect.X = (int)Math.Round((this.ClientRectangle.Width - srcRect.Width) / 2.0f - this.imageRect.X);
            srcRect.Y = (int)Math.Round((this.ClientRectangle.Height - srcRect.Height) / 2.0f - this.imageRect.Y);
            gs.DrawImage(image, destRect, srcRect, GraphicsUnit.Pixel); --------------------编程问答-------------------- 试试 BltBit 函数 --------------------编程问答-------------------- 图太大了....
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,