大屏幕字幕滚动 好吧,我的是在lblText_paint 方法中重绘的,用 e.Graphics.DrawString(showText.Caption, getFont(), SbFont,rectFont,GetFormat());//将对应的文字写到矩形上 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 void lblText_Paint(object sender, PaintEventArgs e) { Rectangle rectFont = new Rectangle(); SolidBrush SbFont = null; e.Graphics.PageUnit = GraphicsUnit.Pixel; e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; SbFont = new SolidBrush(ColorTranslator.FromWin32(showText.FontColor)); Point pt = new Point(0, 0); switch (showText.Direction) {//滚动方向0:向右滚动,1:向左滚动,2:向下滚动,3:向上滚动。 case 0: if (x >= this.Width) x = -((int)oneSize.Width + 1); else x += showText.Speed; pt.X = x; break; case 1: if (x <= -((int)oneSize.Width + 1)) x = this.Width; else x -= showText.Speed; pt.X = x; break; case 2: if (y >= this.Height) y = -((int)oneSize.Height + 1); else y += showText.Speed; pt.Y = y; break; case 3: if (y <= -((int)oneSize.Height + 1)) y = this.Height; else y -= showText.Speed; pt.Y = y; break; default: break; } e.Graphics.TranslateTransform(pt.X, pt.Y); if (showText.TextDirection == 1) { rectFont = new Rectangle(0, 0, (int)oneSize.Width + 1, (int)oneSize.Height); } else { rectFont = new Rectangle(0, lblText.Height / 9, (int)oneSize.Width + 1, (int)oneSize.Height); } e.Graphics.DrawString(showText.Caption, getFont(), SbFont,rectFont,GetFormat());//将对应的文字写到矩形上 e.Graphics.Flush(); }重绘的代码,现在就是有卡顿的感觉,滚动的不流畅,我用timer进行刷新。 不行,cpu占用率太大,别的窗口移动的时间就会很卡,已经试过了! 做成图片,然后移动图片位置。这样可以省去每次重绘占用CPU。 //把timer换成Thread,可以提高点帧数,看看满足需求不 Thread th;//Initth = new Thread(new ThreadStart(XXXX));th.Start();//XXXXvoid XXXX(){ while (!lblText.Created); while (true) { if (!lblText.Created) break; lblText.Invalidate(); Thread.Sleep(10); }}//Paint上面代码SbFont后面要释放 SbFont.Dispose(); 我只能说,GDI+不适合干这个,GDI+是为了图形绘制而不是为了显示。换WPF把,有显卡加速的帮助,什么动画都好做的。 gdi+太慢了,换wpf 我觉得这事和gdi+没关系,而是winform的print方式和消息循环不适合做动画,并不是GDI+算的不够快。wpf是调用directX,也就是显卡做显示。填充显存显卡就输出了,输出的帧数只和计算速度发生关系。 如果是个小的独立的项目,建议改用WPF,在动画处理上很有优势。 你如果要用form写的话就生成图片,然后用两个pictureBox显示,不断地改变location,移出范围就交替换位。不断循环。 是在项目里的一个模块,不能换wpf,要不也不会这么纠结的 找个载体,移动location试试。 大屏幕,,为什么要用cs做 .? 你看人家LED的东西 很多都是html滚动..那个html代码qu什么什么的 就可以 还研发CS,浪费时间. 用线程调用,进行重绘,还能稍微好点,还是需要再琢磨下。cpu占用还是有些高。 如何取string的地址 高手求救关于简易计算器(c#) 如何序列化一個sqlCommand? 如何实现财务软件中的帐套备份? csdn管理员 为什么.net技术 --〉asp.net 出现Service Unavailable? 超级难的放射问题! 有无做过《漂染厂进销存系统》的朋友。 DEV gridcontrol的问题 请各位大哥帮忙:如何捕捉本机向外发出的所有消息? Visual Studio β2中文企业版(4CD)哪里能买到 C#日文XP下,连接access导入数据报错,具体如下图,求解决 iframe高度自适应问题
{
Rectangle rectFont = new Rectangle();
SolidBrush SbFont = null;
e.Graphics.PageUnit = GraphicsUnit.Pixel;
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
SbFont = new SolidBrush(ColorTranslator.FromWin32(showText.FontColor));
Point pt = new Point(0, 0);
switch (showText.Direction)
{//滚动方向0:向右滚动,1:向左滚动,2:向下滚动,3:向上滚动。
case 0:
if (x >= this.Width)
x = -((int)oneSize.Width + 1);
else
x += showText.Speed;
pt.X = x;
break;
case 1:
if (x <= -((int)oneSize.Width + 1))
x = this.Width;
else
x -= showText.Speed;
pt.X = x;
break;
case 2:
if (y >= this.Height)
y = -((int)oneSize.Height + 1);
else
y += showText.Speed;
pt.Y = y;
break;
case 3:
if (y <= -((int)oneSize.Height + 1))
y = this.Height;
else
y -= showText.Speed;
pt.Y = y;
break; default: break;
}
e.Graphics.TranslateTransform(pt.X, pt.Y);
if (showText.TextDirection == 1)
{
rectFont = new Rectangle(0, 0, (int)oneSize.Width + 1, (int)oneSize.Height);
}
else
{
rectFont = new Rectangle(0, lblText.Height / 9, (int)oneSize.Width + 1, (int)oneSize.Height);
}
e.Graphics.DrawString(showText.Caption, getFont(), SbFont,rectFont,GetFormat());//将对应的文字写到矩形上
e.Graphics.Flush();
}
重绘的代码,现在就是有卡顿的感觉,滚动的不流畅,我用timer进行刷新。
//Init
th = new Thread(new ThreadStart(XXXX));
th.Start();//XXXX
void XXXX()
{
while (!lblText.Created);
while (true)
{
if (!lblText.Created) break;
lblText.Invalidate();
Thread.Sleep(10);
}
}//Paint上面代码SbFont后面要释放
SbFont.Dispose();