DIRCETDRAW CC ++ Guidance (4)

zhaozj2021-02-08  248

DIRCETDRAW C / C instructions

310CDT translation

DDEX4 (but in this two days, somehow is not good, it may be good for two days)

Tutorial4: The example of color key code and bitmap animation Third guidance DDEX3 demonstrates a simple behavior that puts the bitmap in front of the screen in front of the flip page. This guidance will take advantage of the technology described above, load one Background Pictures and A Series Elf (Translator Note: Generally placing a slightly changing picture) to the remote surface. Then, use the idirectdrawsurface7 :: bltfast method to copy from the surface of the screen to the background buffer, in times, create one Simple bitmap animation. DDEX4, bitmap files are all.bmp, which contains the rotating red circle of the background and 60 consecutive black background. DDEX4 contains new functions for rotating red circle wizard settings. Color key code. Then, the example is copied from the off-screen surface to the appropriate wizard to the newly added function in the background buffer. DDEX4 is shown as follows: Step1: Set Color Key STEP2: Create a simple animation (Translator Note: Color Keys That is, the color is not copied when copying from the surface of the screen, thereby forming a transparent look)

STEP1: Setting Color Keys On the basis of other examples, DDEX4's DOINIT function contains code that sets the elf color key code. Color key code is used to set a color value, this color value is used for transparency. When the system uses When the hardware block is supported, all pixels will be moved (blit) to the cache in all pixels. This creates a wizard that is not a rectangular look. The following code demonstrates how Ddex4 Set the color key.

// set the color key for this bitmap. DDSetColorKey (LPDDsone, RGB (0, 0)); Return True; When the DDSetColorKey function is called, you can set the RGB value of the color you want to set. Set the color key code. The black RGB value is (0, 0, 0) .ddsetColorKey function calls the DDColormatch function. (Two functions are in ddutil.cpp) DDColormatch function stored in the LPDDsone surface (0) 0) The color value of the pixel of the position. Then, he sets the pixels of the (0,0) position of the bitmap to the color you provide. Finally, it comes to the color value and the mask of each pixel color bit (Different or). The position of the (0,0) changes back to the original color. When these are finished, the function call returns to DDSETCOLORKEY. Returns the value of color key (DW) value. Put DDColorKey members dwColorSpaceLowValue structure, and copied to dwColorSpaceHighValue members. IDirectDrawSurface7 :: SetColorKey call then set the key color code. you may have noticed DDSetColorKey and DDColorMatch function of CLR_INVALID in. If you put CLR_INVALID as in DDEx4 The color key code is passed to the DDSetColorKey function. The upper left corner (0) pixels in the bitmap will be regarded as the color key code. DDEX4 is not large, because the position of the bitmap is gray. You If you want to see how to make (0,0) in DDEX4 as color key, you can open all.bmp files with drawing software. Then turn (0, 0) this point to black. Be sure you want to modify Save (this is not good-looking). Then, you can change the call of DDSetColorKey to the following: DDSETCOLORKEY (LPDDSONE, CLR_INVALID);

Re-compiling DDEX4, to ensure that the resource file containing the new bitmap is also recompiled. This, DDEX4 will use the (0,0) point that is now changed to black as a color key.

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

New Post(0)