vb6 中,已知某个像素点(比如 Picture1.Point(0, 0)),如何知道该点RGB的 三个值 放到TEXT中

来源:百度知道 编辑:UC知道 时间:2024/05/26 07:58:06
我找到了

函数: GetRValue 功能: 从指定颜色中分离出红色分量
' 入口: rgbColor 指定的颜色
Function GetRValue&(ByVal rgbColor&)
GetRValue = rgbColor And &HFF
End Function

' 函数: GetRValue 功能: 从指定颜色中分离出绿色分量
' 入口: rgbColor 指定的颜色
Function GetGValue&(ByVal rgbColor&)
GetGValue = (rgbColor And &HFF00&) / &HFF&
End Function

' 函数: GetRValue 功能: 从指定颜色中分离出蓝色分量
' 入口: rgbColor 指定的颜色
Function GetBValue&(ByVal rgbColor&)
GetBValue = (rgbColor& And &HFF0000) / &HFF00&
End Function

用函数GetPixel取出的是一个COLORREF值
可以用GetRValue、GetBValue、GetGValue宏
取得其中的R、G、B分量
int r=GetRValue(GetPixel(hdc,x,y));
关于函数
参考:
COLORREF GetPixel( POINT point ) const;

Return Value

For either version of the function, an RGB color value for the color of the given point. It is –1 if the coordinates do not specify a point in the clipping region.

Parameters

x

Specifies the logical x-coordinate of the point to be examined.

y

Specifies the logical y-coordinate of the point to be examined.

point

Specifies the logical x- and y-coordinates of the point to be examined.

Remarks

Retrieves the RGB color v