本人現在想製作一個可以今圖畫作淡出淡入的程式,基本上在讀取、儲存資料方面已沒有問題,但在以"for...next"來改變bmp內的資料時,就需要很長很長時間,究竟有沒有更好的方法呢??以下是我的程式碼:
Private Type BITMAPFILEHEADER
bfType As Integer
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits As Long
End Type
Private Type BITMAPINFOHEADER '40 bytes
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Dim LoadBMPHeader As BITMAPFILEHEADER
Dim LoadBMPInfoHeader As BITMAPINFOHEADER
Private Type RGBCOUNT
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
End Type
Dim BMIColor(307200) As RGBCOUNT
Private Sub Command1_Click()
Open "d:\av17a.bmp" For Binary As #1
Get #1, , LoadBMPHeader
Get #1, , LoadBMPInfoHeader
Get #1, , BMIColor
Close #1
For A = 0 To 307200
If BMIColor(A).rgbBlue < Hex(VScroll1.Value) Then
BMIColor(A).rgbBlue = 0
Else
BMIColor(A).rgbBlue = BMIColor(A).rgbBlue - Hex(VScroll1.Value)
End If
If BMIColor(A).rgbGreen < Hex(VScroll1.Value) Then
BMIColor(A).rgbGreen = 0
Else
BMIColor(A).rgbGreen = BMIColor(A).rgbGreen - Hex(VScroll1.Value)
End If
If BMIColor(A).rgbRed < Hex(VScroll1.Value) Then
BMIColor(A).rgbRed = 0
Else
BMIColor(A).rgbRed = BMIColor(A).rgbRed - Hex(VScroll1.Value)
End If
Next A
Open "d:\123.bmp" For Binary As #2
Put #2, , LoadBMPHeader
Put #2, , LoadBMPInfoHeader
Put #2, , BMIColor
Close #2
Picture1 = LoadPicture("D:\123.bmp")
End Sub
Private Sub Command2_Click()
Text1.Text = &HA
End Sub
Private Sub Form_Load()
On Error Resume Next
Kill "d:\123.bmp"
End Sub
Private Sub VScroll1_Change()
Label1.Caption = VScroll1.Value
End Sub
Private Sub VScroll2_Change()
Label3.Caption = VScroll2.Value
End Sub
Private Sub VScroll3_Change()
Label4.Caption = VScroll3.Value
End Sub