|
|
2009/5/31 下午 10:29:58
不好意思~請問一下~ 最近在做圖片動畫顯示~是GIF透明背景圖檔~ 因PictureBox控件無法顯示透明背景圖(背景會有顏色無法呈現去背狀態...還是說可以用~只是我不會用 )
所以我使用image控件...但是做出來的動畫~圖片在更換時~會有閃爍的感覺.. 請問有辦法解決嗎 ??
以下是我的程式碼~~謝謝~~
Dim x As Integer
Private Sub Form_Load() Timer1.Interval = 300 Timer1.Enabled = True End Sub
Private Sub Timer1_Timer() x = x + 1 If x Mod 4 = 3 Then Image1.Picture = LoadPicture("1.gif") If x Mod 4 = 2 Then Image1.Picture = LoadPicture("2.gif") If x Mod 4 = 1 Then Image1.Picture = LoadPicture("3.gif") If x Mod 4 = 0 Then Image1.Picture = LoadPicture("4.gif") End Sub
我知道使用PictureBox可以使用以下方法解決...但是我的圖片背景會變黑色的..有辦法去背嗎?謝謝~~ BufferPic = LoadPicture("1.gif") picture1.PaintPicture BufferPic.Picture, 0, 0 Form1.Picture = picture1.Image
|
|
|
|
2009/6/1 上午 09:55:11
>我知道使用PictureBox可以使用以下方法解決...但是我的圖片背景會變黑色的..有辦法去背嗎?謝謝~~ >BufferPic = LoadPicture("1.gif") >picture1.PaintPicture BufferPic.Picture, 0, 0 >Form1.Picture = picture1.Image
picture1.PaintPicture BufferPic.Picture, BufferPic.Left, BufferPic.Top, BufferPic.Width, BufferPic.Height
應該是這樣用吧!或者您把四個圖先放到四個Image,設為隱藏,Image1.Picture = 您要的Image.Picture,是否可行呢...
|
|
|
|
2009/6/1 下午 03:44:25
沒有考慮圖檔載入的時間 早期的GAME(APPLE II 有點早..) 是以2個圖切換的方式處理
定2個control 一前A(可視)一後B(不可視) 顯示A時載入B 時間到隱藏A顯示B載入A 循環
用在VB效果?試一下吧
|
|
|
|
2009/6/1 下午 05:35:42
要在表單 做透空動畫 不建議使用.gif來做,因為vb6未完全支援所有特性~ 單圖透空可以用 TransparentBlt ,可以不用另建 遮罩圖!
|
|
|
|
2009/6/1 下午 07:25:51
qazujm(joe) & spainpollo(班班西)你們好~~ 如果使用你們的方法...如果我圖很多的話...那不就要很多image控件才行了@@
168(阿戊)你好~ 謝謝你~你的方法我會試試~~
|
|
|
|
2009/6/1 下午 08:02:19
>如果使用你們的方法...如果我圖很多的話...那不就要很多image控件才行了@@
更新SP6,設定使用元件,Microsoft Windows Common Control 6.0(SP6),ImageList,試試囉...
|
|
|
|
2009/6/2 上午 09:28:27
>qazujm(joe) & spainpollo(班班西)你們好~~ >如果使用你們的方法...如果我圖很多的話...那不就要很多image控件才行了@@
2個交叉使用
> >168(阿戊)你好~ >謝謝你~你的方法我會試試~~ >
|
|
|
|
2009/6/2 下午 05:39:21
>qazujm(joe) & spainpollo(班班西)你們好~~ >如果使用你們的方法...如果我圖很多的話...那不就要很多image控件才行了@@
'也可以完全不用image 或 imagelist ~ Dim a As New Collection, k As Integer Private Sub Form_Load() For i = 0 To 1 a.Add LoadPicture(i & ".gif"), "a" & i '將圖片讀入集合 Next i Timer1.Interval = 1000 Timer1.Enabled = True End Sub
Private Sub Timer1_Timer() k = (k + 1) Mod 2 Form1.Picture = a.Item("a" & k) End Sub
|
|
|
|
2009/6/3 下午 04:02:51
程式大約像這樣 Dim bSW As Boolean Dim lSeq as Long
Private Sub Form_Load() bSW=true lSeq=100001 imgTop.Picture=LoadPicture("00001.gif")
Timer1.Interval = 300 Timer1.Enabled = True End Sub
Private Sub Timer1_Timer() lSeq=lSeq+1 If bSW Then imgTop.Visible = True imgBottom.Picture = LoadPicture("c:\temp\" & Right(Str(lSeq), 5) & ".jpg") bSW = False DoEvents Else imgTop.Visible = False imgTop.Picture = LoadPicture("c:\temp\" & Right(Str(lSeq), 5) & ".jpg") bSW = True DoEvents End If End Sub ***************** 另外比較重要的 如果我沒記錯的話 電視每秒要30frame(視覺暫留1/16秒) 所以Timer1.Interval 要33以下 但不幸的是Timer 1/18秒檢查一次.... 所以只能每秒18frame Timer1.Interval=56 試試
|
|
|
|
2009/6/3 下午 04:14:15
不能編輯XD =========== 好像應該去尾.. >Timer1.Interval=56 Timer1.Interval=55
如果載入太慢(大於1/18) 就要另外處理了!!
|
|
|
|
2009/6/3 下午 04:26:01
....前面不是有提供預讀的方法了...一一"
|
|
|
|
2009/6/3 下午 05:25:08
>....前面不是有提供預讀的方法了...一一'
這是發文者的問題 不知他的圖片總量跟大小 一次載入有一次載入考慮的問題 順序載入有順序載入考慮的問題 (非同步載入?)
只是他指的閃爍或許只是顯示頻率的問題 留給發文者思考吧!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
板主 :
小樓
Top 10 評價排行 |
 |
Visual Basic 6.0/VBA |
|
|
|
|
|
|
|
|
|
|
|
|
|
| Visual Basic 6.0/VBA |
 |
|
| |
專家等級 |
評價 |
|
| |
一代宗師 |
10000 |
|
| |
曠世奇才 |
5000 |
|
| |
頂尖高手 |
3000 |
|
| |
卓越專家 |
1500 |
|
| |
優秀好手 |
750 |
|
|
|
|
|
|
|
|
|
|
|
|
Microsoft Internet Explorer
6.0. Screen 1024x768 pixel. High Color (16 bit).
2000-2013 程式設計俱樂部 http://www.programmer-club.com.tw/ |
|
|