Visual Effects of "blinds" using VB

Source: Internet
Author: User

In software such as Powerpoint, a variety of graphic effects emerge one after another, among which the switching effect of "Shutter" is particularly novel and strange. It is very simple and convenient to implement such graphic effects in VB. The method is to call the Windows API function bitblt. The bitblt function is similar to the combination of getimage and putimage in C. The original intention of bitblt is "bit block transfer", which is mainly used for bitmap copying. The bitblt function is used to display graphic effects. The principle is very simple. When you create an image, draw two image boxes in the form, save the image to one image box, and set the other image box to null, then, call the bitblt function to partially copy the image part of the first image box to the second image box, so that you can implement a special graphic effect. The procedure is as follows:
Create a new form in the VB environment, draw two image boxes picsour and picdest, and two command buttons cmdshow and cmdexit. First, declare the constant name required by the bitblt function in the general process of the form, load the image in picsour while loading the form, and call the bitblt function in the cmdshow event. The 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' one of 15 bitblt algorithms, indicating Direct Copy
Load image:
Sub form-load ()
Picsour. Picture = loadpicture ("C:/Windows/leaves.bmp ″)
Picsour. scalemode = 3' in pixels
End sub
Display the switching effect of "blinds:
Sub comshow-click ()
H % = picsour. scaleheight
W % = picsour. scalewidth
Scanlines = 4
For I = 0 to (scanlines-1)
For J = I to H % step scanlines
S % = bitblt % (picdest. HDC, 0, J, w %, 1, picsour. HDC, 0, J, copy-Put)
Delay 500 'latency
Next J
Next I
End sub
Among them, delay is a common sub-process used for latency, so that you can clearly see the switching effect. The Code is as follows:
Sub delay (delaytime as integer)
For I = 1 to delaytime
Next I
End sub
Through such a simple program, you can implement the special effect of "Shutter" switching. In fact, as long as there is a suitable algorithm, the graphic effects that can be achieved by using the bitblt function are infinite. Interested readers can refer to reference books on VB.

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.