绘图时以显示形式发生闪烁 [英] Flicker happen in display form when drawing

查看:74
本文介绍了绘图时以显示形式发生闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用directx控件绘制1024x1024 MFC表单。我的显示器屏幕没有占用1024X1024分辨率,所以我启用了显示窗体的滚动条控件。我正在使用线程连续绘制表单(1024x1024)。在我滚动查看显示器的隐藏部分时,会发生一些闪烁。如何在显示中移动滚动条时避免闪烁。

I am drawing in a 1024x1024 MFC Form using directx control. 1024X1024 resolution not occupied in my monitor screen, so i enabled scroll bar control for the Display form. I am using thread to draw the form (1024x1024) continuously. At the time i am scrolling to view the hidden part of the display, some flicker is happen. How to avoid that flicker while moving scroll bar in the display.

推荐答案

>我正在使用线程连续绘制表单(1024x1024)。

>当我滚动查看隐藏的显示部分时,会发生一些闪烁。



我不会画画滚动期间的表单。您可以在开头使用
>I am using thread to draw the form (1024x1024) continuously.
>At the time i am scrolling to view the hidden part of the display, some flicker is happen.

I would not draw the form during scrolling. You can use
SetRedraw(FALSE)

,在滚动结束时使用

SetRedraw(TRUE)

。从MSDN看一下这个例子:



on the end of scrolling. Take a look at this example from MSDN:

// Updating a control or window with large amounts of data may cause
// flicker. In such cases it may be better to turn off drawing

//...

   //m_list is a member of type CListCtrl
   m_List.SetRedraw(FALSE);  // turn drawing off regardless of list mode

//...
// Update control
//...

   m_List.SetRedraw(TRUE);  // turn drawing back on and update the window

   // invalidate the entire control, force painting
   m_List.Invalidate();
   m_List.UpdateWindow();


您可以创建一个大小相同的内存DC和位图,而不是直接绘制到您的控件上。然后,准备好后,只需将当前可见部分bitblt到控件的DC。这有几个优点:



- 绘制到内存位图比绘制到屏幕更快

- 你不必为每个滚动步骤执行绘图代码;相反,你绘制一次整个控件,然后咬住可见的部分。你可能烤箱使用窗口滚动功能进行滚动,只是咬住在最后一个滚动步骤中可见的小条纹。



这种技术称为双缓冲,是广泛用于抑制屏幕闪烁。
Instead of painting directly to your control you could create an equally sized memory DC and bitmap and paint into that. Then, when ready, just bitblt the currently visible part to the DC of the control. That has several advantages:

- drawing to a memory bitmap is faster than drawing to the screen
- you don''t have to execute your drawing code for every scroll step; instead you draw once the entire control and just bitblt the part that is visible. Your might oven use the window scrolling functions for scrolling and just bitblt the small stripe that became visible in the last scrolls step.

This technique is called double-buffering and is used widely to suppress screen flicker.


消除闪烁的技术称为双缓冲



请参阅此CodeProject文章: MFC中的无闪烁绘图 [< a href =http://www.codeproject.com/Articles/33/Flicker-Free-Drawing-In-MFCtarget =_ blanktitle =New Window> ^ ]。



参见:

http://forums.codeguru.com/showthread.php?462696-Double-Buffering-MFC [ ^ ],

http://www.cs.sjsu.edu/faculty/beeson/courses/cs130/LectureNotes/17-DoubleBuffering /DoubleBuffer.html [ ^ ]。



-SA
The technique of elimination flicker is called "double buffering".

Please see this CodeProject article: Flicker Free Drawing In MFC[^].

See also:
http://forums.codeguru.com/showthread.php?462696-Double-Buffering-MFC[^],
http://www.cs.sjsu.edu/faculty/beeson/courses/cs130/LectureNotes/17-DoubleBuffering/DoubleBuffer.html[^].

—SA


这篇关于绘图时以显示形式发生闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆