【发布时间】:2011-07-09 02:29:22
【问题描述】:
windows mobile 6.5 CE 是否支持双缓冲
【问题讨论】:
标签: windows-mobile compact-framework
windows mobile 6.5 CE 是否支持双缓冲
【问题讨论】:
标签: windows-mobile compact-framework
如果您自己绘制控件,那么您可能需要考虑执行自己的双缓冲。
我最近没有大量更新 WinCE,并认为他们最终会移植你在桌面上获得的双缓冲的便利性,但也许他们没有。
基本上,前提是只绘制图像,然后在一次镜头中将该图像blit到“真实”图形对象上。
它是这样的“东西”(如果语法完美的话,这来自记忆,所以 idk):
public class DoubleBufferedControl : Control
{
protected override OnPaint(object sender, PaintEventArgs e)
{
using(Bitmap bitmap = new Bitmap(Width, Height))
{
using(Graphics graphics = Graphics.FromImage(bitmap))
{
DoPaint(sender, new PaintEventArgs(graphics));
e.Graphics.DrawImage(bitmap, 0, 0);
}
}
}
protected virtual DoPaint(object sender, PaintEventArgs e)
{
/* left empty for overrides */
}
protected override OnPaintBackground(object sender, PaintEventArgs e)
{
/* do nothing */
}
}
然后让您自己的所有控件都继承自此,并将您的绘画代码添加到 DoPaint 的覆盖中。
您可能希望将上述优化为仅创建一次位图(ctor),处理调整大小事件,然后在调整大小时重新创建它,然后添加一些处理代码,以便您可以在对象死亡时处理位图。
【讨论】:
这真的取决于你的意思和位置。几乎所有 CE 显示驱动程序都使用双缓冲来从显存绘制到显示器,以防止撕裂和伪影(我从未见过不这样做的)。
如果您询问某个框架(例如 Compact Framework、MFC、Direct Show 或其他)是否通过 API 支持它,那么我们需要知道您在说什么框架。
【讨论】: