
不用API
Dim fname As String
Private Sub Command1_Click()
Dim c As String, x As Integer, y As Integer
c = ""
MeCaption = "正在读取颜色中"
For x = 1 To Picture1ScaleWidth
For y = 1 To Picture1ScaleHeight
c = c & strRGB(Picture1Point(x - 1, y - 1)) & " " '读取每个像素的十六进制颜色值
Next
c = c & vbCrLf
Next
Open fname & "txt" For Output As #1 '在同一目录下保存txt格式的颜色文件
Print #1, c
Close #1
MeCaption = "读取颜色"
End Sub
Private Function strRGB(ByVal color As Long) As String '颜色值转RGB格式的字符串
Dim r As Integer, g As Integer, b As Integer
r = (color And &HFF) Mod 256
g = ((color And &HFF00) \ &H100) Mod 256
b = ((color And &HFF0000) \ &H10000) Mod 256
strRGB = "RGB(" & b & "," & g & "," & r & ")"
End Function
Private Sub Form_Load()
MeCaption = "读取颜色"
Picture1AutoSize = True
Picture1ScaleMode = 3
fname = "e:\hehejpg"
Picture1Picture = LoadPicture(fname)
End Sub
以上就是关于如何用WIN API读取图片文件,获得RGB值全部的内容,包括:如何用WIN API读取图片文件,获得RGB值、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)