c#解决窗口背景贴图刷新,放大后图像闪烁问题
来源:互联网 发布:加拿大研究型硕士知乎 编辑:程序博客网 时间:2024/05/12 07:45
找到的别人的代码,很好用,把Panel类替换成BackGroundPanelTrend就可以了,但奇怪的是为什么图片右和下会有两道黑边,把width和height各加了200,解决问题了,好像是没画全??郁闷了
原文链接:http://www.cublog.cn/u2/67893/showart_2267690.html
重写Pannel控件
给BackGroundPanelTrend 对象的背静图片初始化一张图片
public class BackGroundPanelTrend : Panel
{
// Don't use the Paint-event like this: panel.Paint += ...
//Instead of using a Panel, create a custom control class and overridethe OnPaint-method. To reduce flickering, also override theOnPaintBackground-method.
// using System.Drawing;
//using System.Windows.Forms;
//public class RenderControl : Control
//{
// protected override void OnPaint(PaintEventArgs e)
// {
// // render-code goes here
// base.OnPaint(e);
// }
// protected override void OnPaintBackground(PaintEventArgs e)
// {
// // do nothing here: doesn't paint background => no flickering
// }
//}
//
//Then use the RenderControl in your form, like any other control.
//
protected override void OnPaintBackground(PaintEventArgs e)
{
//
// 重载基类的背景擦除函数,
// 解决窗口刷新,放大,图像闪烁
// do nothing here: doesn't paint background => no flickering
return;
}
protected override void OnPaint(PaintEventArgs e)
{
// render-code goes here
this.DoubleBuffered = true;
if (this.BackgroundImage != null)
{
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
// e.ClipRectangle
e.Graphics.DrawImage(this.BackgroundImage, new System.Drawing.Rectangle(0, 0, this.Width, this.Height),
0, 0, this.BackgroundImage.Width, this.BackgroundImage.Height,
System.Drawing.GraphicsUnit.Pixel);
}
base.OnPaint(e);
}
}
//********************************************************************************************
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel_wholeFrameTrend = new BackGroundPanelTrend();
}
BackGroundPanelTrend panel_wholeFrameTrend;
//***************************************************************************************
- c#解决窗口背景贴图刷新,放大后图像闪烁问题
- 解决窗口刷新闪烁
- 解决窗口刷新闪烁
- 解决窗口刷新闪烁
- 解决窗口刷新闪烁
- 解决窗口刷新闪烁
- 解决窗口刷新闪烁
- 解决窗口刷新闪烁
- 解决窗口刷新闪烁
- 解决窗口刷新闪烁
- 窗口刷新闪烁问题
- 【转】解决窗口刷新闪烁
- 解决窗口闪烁问题
- 窗口背景的刷新问题
- C#图像放大问题解决方法
- PC Camera开发日志(十三)------ 窗口贴图闪烁问题
- 窗口背景贴图
- C#画图解决闪烁问题
- defining int64
- 多媒体工程师职位要求
- WORD损坏打不开修复方法
- 备份集、备份片、映像副本
- FILD和FSTP转换成C语言
- c#解决窗口背景贴图刷新,放大后图像闪烁问题
- JBPM之长事务设计解析
- 通过t4模板结合XML定义文件生成MVVM中的Model Entity Class 代码
- 【Android】ListView与Button的共存问题解决
- STL内容简介(详细内容稍后再补)
- Linux ubuntu lamp安装配置
- Linux 压缩 解压命令 tar, gzip, zcat,bzip2, bzcat,compres
- 《那些年啊,那些事——一个程序员的奋斗史》——07
- Android Location and Maps