Realize the graphics effects of "blinds" with VB

zhaozj2021-02-11  210

In software such as PowerPoint, a variety of graphics special effects are endless, with "blinds" switching effects is especially novel. It is very simple and convenient to implement such a graphic effect in VB. Its method is to call the API function Bitblt of Windows. The BitBLT function is similar to the combination of GetImage, PUTIMAGE, two functions in the C language. Bitblt is originally "Bit Block Transfer", which main use is copy of bitmap. Use the Bitblt function to display graphical effects, the principle is very simple, and then draw two picture boxes in the form, put the picture into a picture box, and set another picture box empty, then call the Bitblt function will be the first The graphics in the picture box are partially copied into the second picture box, so that you can achieve thousands of strange graphics effects. The steps are as follows: Creating a new form in the VB environment, drawing two picture box Picsour and PicDest, two command buttons cmdshow and cmdexit. First, declare the Bitblt function in the form of the form, which is loaded into the PICSOUR in the Load Form, and call the Bitblt function in the button CMDSHOW. Procedure is as follows: API function declaration: Declare Function BitBlt Lib "GDI" (ByVal hDestDC As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal nWidth AS Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, BYVAL YSRC AS INTEGER, BYVAL DWROP As Long AS Integer Const Copy-Put = & HCC0020'bitblt's 15 algorithms of the 15 algorithms, Direct copy loaded picture: Sub form-load () picsour.picture = loadingPicture ("C: / Windows / Leaves.bmp ") Picsour.scaleMode = 3 'with pixels END SUB Displays" blinds "switching effect: SUB Comshow-Click () h% = picsour.scaleHETIGHTW% = picsour.scalewidthscanlines = 4for i = 0 To (ScanLines-1) for j = i to h% step scanlines = Bitblt% (PicDest.hdc, 0, J, W%, 1, Picsour.hdc, 0, J, Copy-Put) delay 500 'delay Next Jnext IEND SUB where Delay is a generic sub-process for delaying to facilitate clearing the switching effect. The code is as follows: SUB DELAY (DELAYTIME AS INTEGER) for i = 1 To DelayTimenext IEND SUB can implement "blinds" switching effects, in fact, as long as there is a suitable algorithm, the graphic effects that can be implemented using the Bitblt function is Endless. Interested readers can check with reference to VB.

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

New Post(0)