![]() |
#2
风吹过b2012-10-01 07:32
|
for循环代码部分求解释 当然其他的代码也解释也非常感谢

Dim intbtnselected As Integer
Dim PictureName As String
Private Sub Command1_Click()
CommonDialog1.FileName = ""
CommonDialog1.Flags = VbOFNFileMustExist
CommonDialog1.Filter = "所有文件|*.*|(*.bmp)|*.bmp|(*.jpg)|*.jpg|(*.GIF)|*.gif"
CommonDialog1.FilterIndex = 2
CommonDialog1.DialogTitle = "打开文件"
CommonDialog1.Action = 1
PictureName = CommonDialog1.FileName
If PictureName = "" Then
Exit Sub
End If
Image1.Picture = LoadPicture(PictureName)
Picture1.Width = Image1.Width
Picture1.Height = Image1.Height
Picture1.Picture = LoadPicture(PictureName)
Picture2.Width = Image1.Width
Picture2.Height = Image1.Height
End Sub
Private Sub Command2_Click()
Dim j, i As Integer
Dim X, Y As Integer
Dim n, Num As Integer
Dim bytRed, bytGreen, bytBlue, btyAverage As Long
Dim pixel As Long
i = 0
j = 0
X = Picture1.ScaleWidth
Y = Picture1.ScaleHeight
For i = 1 To Y - 1
For j = 1 To X - 1
pixel& = Picture1.Point(j, i)
bytRed = pixel& Mod 256
bytGreen = ((pixel& And &HFF00) / 256&) Mod 256&
bytBlue = (pixel& And &HFF0000) / 65536
btyAverage = Fix((bytRed + bytGreen + bytBlue) / 3)
Picture2.PSet (j, i), RGB(btyAverage, btyAverage, btyAverage)
Next
Next
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
Picture1.Picture = LoadPicture("")
Picture1.Cls
Picture2.Cls
End Sub
Dim PictureName As String
Private Sub Command1_Click()
CommonDialog1.FileName = ""
CommonDialog1.Flags = VbOFNFileMustExist
CommonDialog1.Filter = "所有文件|*.*|(*.bmp)|*.bmp|(*.jpg)|*.jpg|(*.GIF)|*.gif"
CommonDialog1.FilterIndex = 2
CommonDialog1.DialogTitle = "打开文件"
CommonDialog1.Action = 1
PictureName = CommonDialog1.FileName
If PictureName = "" Then
Exit Sub
End If
Image1.Picture = LoadPicture(PictureName)
Picture1.Width = Image1.Width
Picture1.Height = Image1.Height
Picture1.Picture = LoadPicture(PictureName)
Picture2.Width = Image1.Width
Picture2.Height = Image1.Height
End Sub
Private Sub Command2_Click()
Dim j, i As Integer
Dim X, Y As Integer
Dim n, Num As Integer
Dim bytRed, bytGreen, bytBlue, btyAverage As Long
Dim pixel As Long
i = 0
j = 0
X = Picture1.ScaleWidth
Y = Picture1.ScaleHeight
For i = 1 To Y - 1
For j = 1 To X - 1
pixel& = Picture1.Point(j, i)
bytRed = pixel& Mod 256
bytGreen = ((pixel& And &HFF00) / 256&) Mod 256&
bytBlue = (pixel& And &HFF0000) / 65536
btyAverage = Fix((bytRed + bytGreen + bytBlue) / 3)
Picture2.PSet (j, i), RGB(btyAverage, btyAverage, btyAverage)
Next
Next
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
Picture1.Picture = LoadPicture("")
Picture1.Cls
Picture2.Cls
End Sub
[ 本帖最后由 迪拜axq 于 2012-9-29 16:29 编辑 ]