Special effects of the world - bit map reel

zhaozj2021-02-08  265

Less nonsense, first look at the effect after running: (if there is no appearance, please be patientfully waiting for a moment)

Please forgive my time. I don't talk much about the details of the programming. I only introduce the general implementation method.

In DirectX, the page is the most basic object. We use it to load the load map, there are many types, with:

Primary Surface: Represents the back buffer of the display screen of the display screen: another backup page for page, the non-Screen Surface: Used to store the image of the image, invisible

The three pages in this program are used. Firstly, two images: a warrior, a background separately loads on two off-screens. Please note that we use the source key colors on the picture of the Samurai.

Source Key Color: The page is assumed to be a transparent color color, which is transparent in the blit

If you carefully observe the picture of the warrior, you will find green on the background of the warrior image, this is the source key color I use.

Then the job is to set a timer. Every time you make the screen for a change, in this process, you need to separate the bitmap BLIT in the two off-screen pages to the background, this time, you need to calculate some Coordinate data, these logic problems, I don't say much, because these - things, I am confused, you still think about it, in short, you need to control the source and target rectangle of Blit. Because this program I use full-screen mode, use the change page operation.

Change the page: Switch the background cache to the pointer of the front desk (main page), so that the screen on the screen is updated instant (because the change is completed, very fast, the time and the refresh rate are the same quantity), Therefore, the phenomenon of flicker is not observed.

Ok, this program is roughly like this. It is in the VC 5.0 environment, directly using DirectDraw, no packaging libraries such as CDX.

There is an executable file and source code, with more detailed comments, download MovePic.zip (190K). If there is a problem, please tell me.

转载请注明原文地址:https://www.9cbs.com/read-1274.html

New Post(0)