Sometimes we need cool effects to dress up our programs.
The following figure shows the sliding effect of S1 from right to left.
What do you mean?
In fact, the principle is not complex, and a drawing function stretchblt is used.
Function: Copies a bitmap from the source rectangle to the target rectangle. If necessary, the image is stretched or compressed in the current mode set by the target device.
Function prototype: bool sequence (HDC hdcdest, int sequence, int nyorigindest, int sequence, int sequence, HDC hdcsrc, int nxoriginsrc, int nyoriginsrc, int nwidthsrc, int nheightsrc, DWORD dwrop );
Parameters:
Hdcdest: The handle pointing to the target device environment.
Nxorigindest: Specifies the x-axis coordinate in the upper-left corner of the target rectangle, which is expressed in logical units.
Nyorigindest: Specifies the Y axis coordinate in the upper left corner of the target rectangle, which is expressed by logical unit.
Nwidthdest: Specify the width of the target rectangle, which is expressed in logical units.
Nheightdest: Specify the height of the target rectangle, which is expressed in logical units.
Hdcsrc: refers to the handle to the Source Device environment.
Nxoriginsrc: X axis coordinates in the upper left corner of the source rectangle area. The coordinates are expressed in logical units.
Nyoriginsrc: refers to the y-axis coordinate in the upper left corner of the source rectangular area. The coordinate is expressed in logical units.
Nwidthsrc: Specifies the width of the source rectangle, which is expressed in logical units.
Nheightsrc: Specifies the height of the source rectangle, which is expressed in logical units.
Dwdrop: Specify the grating operation to be performed. The raster operation code defines how the system combines colors in the output operations, including brushes, source bitmaps, and target bitmaps. Refer to bitblt for a list of commonly used grating operation codes.
Returned value: if the function is successfully executed, the returned value is non-zero. If the function fails to be executed, the returned value is zero.
We divide a rectangle into several small rectangles. For each small rectangle, we use the stretchblt function to narrow down or enlarge the content to a specific target area. By looking at it with the naked eye, you can see 3d effects.
As long as your imagination is rich enough, you can use this function to make a variety of Fancy effects. For example, there are many revolving doors, such as magnifiers, such.