Dynamic changes of subtitles or pictures can often be seen in movies or TV. When producing multimedia presentation documents such as multimedia teaching software or advertising, dynamic changes of pictures and texts are often needed. As a powerful development tool for Windows software, VB6.0 has broad application prospects in multimedia programming. This article discusses the use of VB6.0 timers combined with Windows API functions to achieve special effects such as dynamic scaling and fading of pictures or text.
1. Programming method to realize dynamic scaling and fade-out effects of graphics and text
1. Program interface
Name the form Form1 and set its Windowstate property to 2. Set the following controls and properties in the form Form1: a label control Label1, whose backcolor is equal to the backcolor of form1; bondstyle is 0, and Autosize is True. An image control image1, its Stratch and Visible are both True; Bordstyle is 0. Two picture box controls Picture1 and Picture2, the Visible property Picture1 is False and Picture2 is True; the AutoRedraw property Picture1 is True and Picture is False; the ScaleModel property is both Pixels; the Bondstyle property is both 0. Three timer controls Timer1, Timer2 and Tirner3; command button control array cmd(0),...,Cmd(4), whose caption attributes are: "Text Zoom", "Picture Zoom", "Text" Hide," "Picture Hide," and "Exit."
2. Dynamic scaling of text
By changing the Size property of the text regularly through the timer control of VB6.0, the effect of the text being dynamically enlarged or reduced can be achieved. In the program, the text size of the caption attribute of label Label1 is controlled through the tuner process of timer1. The cmd_click event triggered by cmd(0) triggers the timer1_time process, which controls the way the text changes through a logical variable 1(0) (array element). When 1(0)=true, the font is dynamically enlarged, and when 1(0)=false Make fonts smaller dynamically.
3. Dynamic scaling of graphics
Set the stretch property of the image control image1 to true, so that the size of the picture in the control changes as the size of the imagel control changes. By regularly changing the size of the imagel control through the tuner process of timer2, the effect of dynamic scaling of the image is achieved. The cmd_click event triggered by cmd(1) will trigger the timer2_time process, which controls the way the image changes through the logical variable 1(1). When 1(1)=true, it controls the dynamic enlargement of the image. When 1(1)=false, it controls the dynamic reduction of the image. .
4. Text fade-in and fade-out effect
Take several words from the string as the caption value of label Label1. If the number of words intercepted from the string increases (until it is equal to the total number of words in the string), the text fade effect will be achieved; and if the number of intercepted words decreases (from the number of words in the string) The total number of characters in the string is reduced to 0), and the text fade effect is achieved. This effect is achieved by regularly changing the number of intercepted words through the time: process of timer3. Triggered by cmd(2). The md_click event triggers the timer3_time process, and controls the way the text changes through the logical variable 1(2). When 1(2)=true, the text fades in, and when 1(2)=false, the text fades out.
5. The fade-in and fade-out effect of graphics
This is achieved by using the Windows API function BitBlt to copy pictures. The usage of BitBlt function is:
The meaning of each parameter is: hDestDC and hSrcDC represent the target device description table handle and the source device description table handle respectively. That is to copy the picture from hSrcDC to hDestDC. The hDC property of the Picturellox control is the device context handle we want to use. x, Y represent the position of the upper left corner of the target, nWidth, nHeight represent the width and height of the target. That is, where in the target device context table should the image be copied, and how wide and high should it be copied. xsrc and ySrc represent the upper left corner position in the source image, that is, where to start copying. The DwRop parameter represents a drawing method, and the direct copy method is commonly used. In this case, SRCCOPY is used.
2. Program code to realize dynamic scaling of images and texts and fade-in and fade-out special effects
The above program has been debugged under VB6.0 and Windows98/2000 environments.
->