回复 5楼 lowxiong
Private Function FindByte(ByVal LineWidth As Long, ByVal LineCount As Long, ByVal x As Long, ByVal y As Long) As Long
FindByte = 55 + (LineCount - y - 1) * LineWidth + 3 * x
End Function
Public Function getclo(picpic As String, x As Integer, y As Integer) '图像路劲,横坐标,纵坐标
Dim BMPWidth As Long
Dim BMPHeight As Long
Dim LineWidth As Long
Dim ArrByte(0 To 3) As Byte
Dim R As Integer
Dim G As Integer
Dim B As Integer
Open picpic For Binary As #1
Get #1, 19, ArrByte
BMPWidth = ArrByte(3) * 256 ^ 3 + ArrByte(2) * 256 ^ 2 + ArrByte(1) * 256 + ArrByte(0) '图像宽
Get #1, 23, ArrByte
BMPHeight = ArrByte(3) * 256 ^ 3 + ArrByte(2) * 256 ^ 2 + ArrByte(1) * 256 + ArrByte(0) '图像高
Select Case (BMPWidth * 3) Mod 4 'BMP图要求每行字节数为4的倍数,不够则填充1-3个无用字节
Case 0
LineWidth = BMPWidth * 3
Case 1
LineWidth = BMPWidth * 3 + 3
Case 2
LineWidth = BMPWidth * 3 + 2
Case 3
LineWidth = BMPWidth * 3 + 1
End Select
Get #1, FindByte(LineWidth, BMPHeight, x, y), ArrByte '此为求 (x,y)点颜色分量
R = ArrByte(2)
G = ArrByte(1)
B = ArrByte(0)
Close #1
getclo = Hex(RGB(R, G, B))
End Function
这是网上整理来的读取硬盘图片某个点颜色的源码,因为想要做成插件调用,所以不能调用图形控件,求改色和保存修改内容的源码。