主题:用C#开发PPC上游戏的闪屏问题
用C#开发,用双缓冲,可还是会出现闪烁,同样的方法,开发windows程序就不会闪烁,看了文档好像是说.net CF不支持DoubleBuffered,我在form的属性里也没看到DoubleBuffered的选项,要怎么解决闪烁问题呢?请高手赐教
代码如下:
protected override void OnPaint(PaintEventArgs e)
{
Assembly asm = Assembly.GetExecutingAssembly();
m_bmpOriginal = new Bitmap(asm.GetManifestResourceStream(asm.GetName().Name
+ ".BB.bmp"));
if (m_bmpOffscreen == null) //要双缓冲的位图
{
m_bmpOffscreen = new Bitmap(ClientSize.Width, ClientSize.Height);
}
Graphics gxOff; //屏幕外的图像
gxOff = Graphics.FromImage(m_bmpOffscreen);
//gxOff.Clear(this.BackColor);
//绘制一些位图
gxOff.DrawImage(m_bmpOriginal, 0, iImgY);
//从内存位图绘制
e.Graphics.DrawImage(m_bmpOffscreen, 0, 0);
gxOff.Dispose();
base.OnPaint(e);
}
同样的方法如果建windows项目就不会闪烁,当然前提是吧DoubleBuffered设为true了
代码如下:
protected override void OnPaint(PaintEventArgs e)
{
Assembly asm = Assembly.GetExecutingAssembly();
m_bmpOriginal = new Bitmap(asm.GetManifestResourceStream(asm.GetName().Name
+ ".BB.bmp"));
if (m_bmpOffscreen == null) //要双缓冲的位图
{
m_bmpOffscreen = new Bitmap(ClientSize.Width, ClientSize.Height);
}
Graphics gxOff; //屏幕外的图像
gxOff = Graphics.FromImage(m_bmpOffscreen);
//gxOff.Clear(this.BackColor);
//绘制一些位图
gxOff.DrawImage(m_bmpOriginal, 0, iImgY);
//从内存位图绘制
e.Graphics.DrawImage(m_bmpOffscreen, 0, 0);
gxOff.Dispose();
base.OnPaint(e);
}
同样的方法如果建windows项目就不会闪烁,当然前提是吧DoubleBuffered设为true了