大家来指点指点啊,PictureBox 图片动画显示

kona813 2004-10-24 06:28:26
求个高效的的PictureBox的图片的动画显示代码
在写个多媒体的小程序,请各位高手指点指点,帮忙了
小弟先谢谢了!
...全文
376 19 打赏 收藏 举报
写回复
19 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
kona813 2004-11-09
  • 打赏
  • 举报
回复
感谢大家了,学了不少,还有没有谁有好的特效啊?
过几天结帖了
director1982 2004-11-08
  • 打赏
  • 举报
回复
我靠,果然是高手,顶
kona813 2004-11-07
  • 打赏
  • 举报
回复
大哥,终于有人回了,等到花儿都谢了,感激感激
大家有好东西拿出来分享分享
小弟不胜感激
rednod 2004-11-06
  • 打赏
  • 举报
回复
先收藏了
lxcc 2004-11-05
  • 打赏
  • 举报
回复
'以下内容用记事本保存为Move.frm,双击打开后F5运行
VERSION 5.00
Begin VB.Form Form1
Caption = "图片特技"
ClientHeight = 4890
ClientLeft = 2970
ClientTop = 630
ClientWidth = 8445
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 4890
ScaleWidth = 8445
Begin VB.Timer Timer6
Interval = 1
Left = 6000
Top = 120
End
Begin VB.Timer Timer5
Interval = 1
Left = 5040
Top = 120
End
Begin VB.Timer Timer4
Interval = 1
Left = 4080
Top = 120
End
Begin VB.Timer Timer3
Interval = 1
Left = 3000
Top = 120
End
Begin VB.Timer Timer1
Interval = 1
Left = 1080
Top = 120
End
Begin VB.Timer Timer0
Interval = 1
Left = 240
Top = 120
End
Begin VB.Timer Timer2
Interval = 1
Left = 2040
Top = 120
End
Begin VB.PictureBox P2
AutoSize = -1 'True
Height = 3255
Left = 0
ScaleHeight = 3195
ScaleWidth = 7875
TabIndex = 1
Top = 600
Width = 7935
End
Begin VB.PictureBox P1
BackColor = &H80000000&
Height = 495
Left = 720
ScaleHeight = 435
ScaleWidth = 1635
TabIndex = 0
Top = 3960
Width = 1695
End
Begin VB.Menu 特技
Caption = " 推出 "
Index = 0
End
Begin VB.Menu 特技
Caption = " 拉近 "
Index = 1
End
Begin VB.Menu 特技
Caption = " 推拉 "
Index = 2
End
Begin VB.Menu 特技
Caption = " 百页窗 "
Index = 3
End
Begin VB.Menu 特技
Caption = " 马赛克 "
Index = 4
End
Begin VB.Menu 特技
Caption = " 拉幕 "
Index = 5
End
Begin VB.Menu 特技
Caption = " 滚动 "
Index = 6
End
Begin VB.Menu 停止
Caption = " 停止 "
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim W As Integer, H As Integer
Dim X As Integer, Y As Integer
Dim Back As Boolean
Private Sub Form_Load() '设置固定属性
P1.AutoSize = True
P1.Left = 0
P1.Top = 0
P2.AutoSize = True
P2.Visible = False
Reset
End Sub
Private Sub Reset() '重置有关变量及属性
Back = False
W = P2.Width
H = P2.Height
Form1.Width = W
Form1.Height = H + 700 '加菜单的高度
P1.Width = W
P1.Height = H
Stopped
End Sub
Private Sub Stopped() '停止所有定时器
Timer0.Enabled = False
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Timer5.Enabled = False
Timer6.Enabled = False
End Sub
Private Sub 特技_Click(Index As Integer) '选择菜单
Static n As Integer
n = n + 1
If n > 4 Then n = 1 '四幅图片不断变换
P2.Picture = LoadPicture(App.Path & "\" & n & ".jpg")
Reset
P1.Cls
Select Case Index
Case 0 '推出
X = W / 2: Y = H / 2
Timer0.Enabled = True
Case 1 '拉近
X = 0: Y = 0
Timer1.Enabled = True
Case 2 '推拉
X = W / 2: Y = H / 2
Timer2.Enabled = True
Case 3 '百叶窗
X = 0: Y = 0
Timer3.Enabled = True
Case 4 '马赛克
Timer4.Enabled = True
Case 5 '拉幕
X = 0: Y = 0
Timer5.Enabled = True
Case 6 '滚动
X = 0
Timer6.Enabled = True
End Select
End Sub

Private Sub Timer0_Timer() '推出
X = X - W / 100: Y = Y - H / 100
If X <= 0 Or Y <= 0 Then Stopped
P1.PaintPicture P2.Picture, 0, 0, W, H, X, Y, W - 2 * X, H - 2 * Y
End Sub

Private Sub Timer1_Timer() '拉近
P1.PaintPicture P2.Picture, 0, 0, W, H, X, Y, W - 2 * X, H - 2 * Y
X = X + W / 100: Y = Y + H / 100 '初值为0
If X >= W / 2 Or Y >= H / 2 Then Stopped
End Sub

Private Sub Timer2_Timer() '推拉
If Back Then
X = X + W / 100: Y = Y + H / 100
If X >= W / 2 Or Y >= H / 2 Then Back = Not Back
Else
X = X - W / 100: Y = Y - H / 100
If X <= 0 Or Y <= 0 Then Back = Not Back: X = 0: Y = 0
End If
P1.PaintPicture P2.Picture, 0, 0, W, H, X, Y, W - 2 * X, H - 2 * Y
End Sub

Private Sub Timer3_Timer() '百叶窗
Dim i As Integer, j As Integer, m As Integer, n As Integer
m = W / 20: n = H / 20
X = X + W / 500: Y = Y + H / 500 '初值为0
If X >= m And Y >= n Then Stopped
For i = 0 To 20
For j = 0 To 20
P1.PaintPicture P2.Picture, i * m, j * n, , , i * m, j * n, X, Y
Next j, i
End Sub

Private Sub Timer4_Timer() '马赛克
Dim i As Integer, m As Integer, n As Integer, xx As Integer, yy As Integer
Static c As Integer
c = c + 1
If c > 100 Then P1.PaintPicture P2.Picture, 0, 0: c = 0
m = W / 100: n = H / 100
For i = 1 To 50 + c * 10
xx = Rnd * (W - m - 50)
yy = Rnd * (H - n - 50)
P1.PaintPicture P2.Picture, xx, yy, , , xx, yy, m, n
Next i
End Sub

Private Sub Timer5_Timer() '拉幕
X = X + W / 100: Y = Y + H / 100 '初值为0
P1.PaintPicture P2.Picture, W / 2 - X, 0, , , W / 2 - X, 0, 2 * X, H
If X > 0.51 * W Then Timer5.Enabled = False
End Sub

Private Sub Timer6_Timer() '滚动
X = X + W / 200 '初值为0
If X >= W Then Stopped
P1.PaintPicture P2.Picture, W - X, 0, , , 0, 0, X, H
End Sub
kona813 2004-10-30
  • 打赏
  • 举报
回复
是想找一个最优的特效显示方法
是特效的就行,正在写个多媒体程序,其中想用特效显示图片,不过我试过几种,不够高效,结果运行时会卡机,图片较大用的是picturebox
希望大家手上如果有好的代码拿出来分享分享
熊孩子开学喽 2004-10-29
  • 打赏
  • 举报
回复
不同的效果有不同的实现方法,不知道楼主想要的是什么样子。
图像直接拷贝可以使用BitBlt或Picture控件的PaintPicture方法
图像的放大缩小可以用StretchBlt或Picture控件的PaintPicture方法;
淡入淡出可以使用AlphaBlend
透明贴图可以使用TransparentBlt
旋转,必须自己写一个函数,不过网上资料不少,基本都是可以直接拷贝下来用的。
kona813 2004-10-27
  • 打赏
  • 举报
回复
还有没有其他好的效果啊,大家拿出来发表发表!!
zgvslch 2004-10-27
  • 打赏
  • 举报
回复
淡入淡出
http://www.vbaspnew.com/ziyuan/y/tx/play22.ZIP
zgvslch 2004-10-27
  • 打赏
  • 举报
回复
雨滴显示效果这里有源代码.
http://www.vbaspnew.com/ziyuan/y/tx/vbimgeff.ZIP
kona813 2004-10-27
  • 打赏
  • 举报
回复
各位手上如果有好的代码或者效果方法,就谈谈吧
xinliangyu 2004-10-26
  • 打赏
  • 举报
回复
琢磨stretchblt的使用,会对你的问题有大帮助。该API函数对高效图形处理是不可或缺的
BlueBeer 2004-10-25
  • 打赏
  • 举报
回复
//一般图片的魔术效果显示

???
用timer轮流换图片
kona813 2004-10-25
  • 打赏
  • 举报
回复
不只是timer控制图片,也可以是其他效果,象淡入淡出,雨滴显示
就想求一个美观的图片显示效果,各位有好的就说说吧
QuickXP 2004-10-24
  • 打赏
  • 举报
回复
Private Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, ByVal _
lpstrReturnString As String, ByVal uReturnLength _
As Long, ByVal hwndCallback As Long) As Long

Dim returnstring As String*127
FileName As String

FileName = "????.avi"
erg = mciSendString "open " & Chr$(34) & FileName & _
Chr$(34) & " alias video", returnstring, _
127, 0
mciSendString "window video handle " & Picture1.HWND, _
returnstring, 127, 0
mciSendString "play video wait", returnstring, _
127, 0
mciSendString "close video", returnstring, 127, 0
kona813 2004-10-24
  • 打赏
  • 举报
回复
有没有多媒体的高手,教几招,不胜感激
jam021 2004-10-24
  • 打赏
  • 举报
回复
关注,帮你顶!
kona813 2004-10-24
  • 打赏
  • 举报
回复
一般图片的魔术效果显示
BlueBeer 2004-10-24
  • 打赏
  • 举报
回复
//求个高效的的PictureBox的图片的动画显示代码

想用PictureBox播放GIF(或SWF)?
相关推荐
发帖
多媒体

808

社区成员

VB 多媒体
社区管理员
  • 多媒体
加入社区
帖子事件
创建了帖子
2004-10-24 06:28
社区公告
暂无公告