Winform 绘制大图的问题
时间:2011-12-10
来源:互联网
我的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);
使用了双缓冲也不行.
但是我发现一个很奇怪的问题就是在图像画到界面上后再调用一次图像对象的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);
作者: abcdgechunping 发布时间: 2011-12-10
试试 BltBit 函数
作者: hyttplay 发布时间: 2011-12-10
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28