Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Dim mark As Boolean
Dim color As Long
Dim r As Integer
Dim g As Integer
Dim b As Integer
Dim starttime As Data
Dim endtime As Data
Dim spendtime As Data
Public Function mosaic(Picture1 As PictureBox)
Dim row As Integer
Dim lin As Integer
Dim rl As Integer
Dim ll As Integer
Dim xl As Integer
Dim yl As Integer
Dim k As Integer
Dim j As Integer
Dim X As Integer
Dim Y As Integer
Dim color As Long
Dim r As Integer
Dim b As Integer
row = Int(Picture1.ScaleWidth / 10)
lin = Int(Picture1.ScaleHeight / 10)
rl = Picture1.ScaleWidth Mod 10
ll = Picture1.ScaleHeight Mod 10
For Y = 0 To (lin - 1) * 10 Step 10
For X = 0 To (row - 1) * 10 Step 10
color = GetPixel(Picture1.hdc, X + 5, Y + 5)
r = color Mod 256
b = (Int(color / 65536))
g = Int((color - (b * 65536) - r) / 256)
For k = 0 To 9
For j = 0 To 9
SetPixel Picture1.hdc, X + k, Y + j, RGB(r, g, b)
Next j
Next k
Picture1.Refresh
Next X
If rl <> 0 Then
xl = Picture1.ScaleWidth - rl
color = GetPixel(Picture1.hdc, xl + rl / 2, Y + 5)
r = color Mod 256
b = (Int(color / 65536))
g = Int((color - (b * 655356) - r) / 256)
For k = 0 To rl - 1
For j = 0 To 9
SetPixel Picture1.hdc, xl + k, Y + j, RGB(r, g, b)
Next j
Next k
Picture1.Refresh
End If
Next Y
If ll <> 0 Then
yl = Picture1.ScaleHeight - ll
For X = 0 To (row - 1) * 10 Step 10
color = GetPixel(Picture1.hdc, X + 5, yl + ll / 2)
r = color Mod 256
b = (Int(color / 65536))
g = Int((color - (b * 65536) - r) / 256)
For k = 0 To 9
For j = 0 To ll - 1
SetPixel Picture1.hdc, X + k, Y + j, RGB(r, g, b)
Next j
Next k
Picture1.Refresh
Next X
If rl <> 0 Then
color = GetPixel(Picture1.hdc, xl + rl / 2, yl + ll / 2)
r = color Mod 256
b = (Int(color / 65536))
g = Int((color - (b * 65536) - r) / 256)
For k = 0 To rl - 1
For j = 0 To ll - 1
SetPixel Picture1.hdc, X + k, Y + j, RGB(r, g, b)
Next j
Next k
Picture1.Refresh
End If
End If
endtime = Time
spendtime = endtime - starttime
End Function
Private Sub Command3_Click()
Picture1.AutoRedraw = True
mosaic Picture1
Picture1.AutoRedraw = False
End Sub
这段程序哪里出错了?