Dual-buffer decryption under VC

Source: Internet
Author: User
To understand the problem of dual buffering, first of all, we need to understand the principle of animation. Basically, animation is a continuous playback of multiple static images, the fast switching of consistent static images gives a dynamic "illusion ". You also need to refresh the image between two frames to eliminate unnecessary elements in the next frame. The simplest refresh is to "draw white" or "clear ", this is the root cause of the problem. If this refresh is visible to the audience, it will flash because the screen is blank at one time. For details, see the next ProgramDemo:
Jumpball1.exe
It can be seen that the key to eliminating "blinking" is to eliminate "blank", but "Clearing" is inevitable. Otherwise, the running character may become an octopus, that is, a shadow; the solution is "dual Buffering", that is, to open up a large unit such as memory and transfer the previously completed refresh work in the memory to the memory, the last one-time write to the video memory, thus avoiding the "blank" process visually.
An efficient bitblt function is provided in Win32 API to implement fast migration of the bitmap structure. Based on this function and the "Double Buffering" principle, this article implements continuous animation and eliminates the "blinking ":
Jumpball2.exe
Readers can compare jumpball1 ("flashing") and jumpball2 (without "flashing"), download the complete source code, and intuitively understand the implementation method of this mechanism.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.