我想获得Set p = LoadPicture("c:\1.jpg")中所有象素的R,g,b值,那位高手修改一下,谢谢:qingmlanzhou@yahoo.com.cn
Private Sub Command2_Click()
Dim p As New StdPicture
Dim Ypos As Long, Xpos As Long
'如何获得图象的尺寸
Dim Pixel As BITMAP
Dim souColor As Long, souGetcolor As String
Dim souRed As Integer, souGreen As Integer, souBlue As Integer
Dim souN As Integer
Set p = LoadPicture("c:\1.jpg")
Ypos = p.Height
Xpos = p.Width
Ypos = Me.ScaleX(Ypos, vbHimetric, vbPixels) ''图象的高度,单位像素。
Xpos = Me.ScaleY(Xpos, vbHimetric, vbPixels) '图象的宽度,单位像素
Print Ypos, Xpos
GetObject p.Handle, Len(Pixel), Pixel '获取图片的象素
For i = 0 To Ypos - 1
For j = 0 To Xpos - 1
'获得源图片各点的RGB值
souColor = GetPixel(p.Handle, j, i)
souGetcolor = Hex(souColor)
souN = 6 - Len(souGetcolor)
souGetcolor = String(souN, "0") & souGetcolor
'转化为Red,Green,Blue的值
souRed = HexDec(Right(souGetcolor, 2))
souGreen = HexDec(Mid(souGetcolor, 3, 2))
souBlue = HexDec(Left(souGetcolor, 2))
Next j
Next i
End Sub