CDC::GetPixel COLORREF GetPixel( int x, int y ) const;COLORREF GetPixel( POINT point ) const;Return ValueFor 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.ParametersxSpecifies the logical x-coordinate of the point to be examined.ySpecifies the logical y-coordinate of the point to be examined.pointSpecifies the logical x- and y-coordinates of the point to be examined.ResRetrieves the RGB color value of the pixel at the point specified by x and y. The point must be in the clipping region. If the point is not in the clipping region, the function has no effect and returns –1. Not all devices support the GetPixel function. For more information, see the RC_BITBLT raster capability under the GetDeviceCaps member function.The GetPixel member function has two forms. The first takes two coordinate values; the second takes either a POINT structure or a CPoint object.CDC Overview | Class Members | Hierarchy ChartSee Also CDC::GetDeviceCaps, CDC::SetPixel,::GetPixel, POINT, CPoint
COLORREF GetPixel( int x, int y ) const;COLORREF GetPixel( POINT point ) const;Return ValueFor 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.ParametersxSpecifies the logical x-coordinate of the point to be examined.ySpecifies the logical y-coordinate of the point to be examined.pointSpecifies the logical x- and y-coordinates of the point to be examined.ResRetrieves the RGB color value of the pixel at the point specified by x and y. The point must be in the clipping region. If the point is not in the clipping region, the function has no effect and returns –1. Not all devices support the GetPixel function. For more information, see the RC_BITBLT raster capability under the GetDeviceCaps member function.The GetPixel member function has two forms. The first takes two coordinate values; the second takes either a POINT structure or a CPoint object.CDC Overview | Class Members | Hierarchy ChartSee Also CDC::GetDeviceCaps, CDC::SetPixel,::GetPixel, POINT, CPoint
typedef DWORD COLORREF;
可以知道这是一个DWORD的
DWORD 32-bit unsigned integer.
DWORD是一个无符号的,你得到-1,肯定是由符号的变量
http://www.codeproject.com/bitmap/pjaimage.asp
而我的返回值老是:ffffffff
可以用GetRValue、GetBValue、GetGValue宏
取得其中的R、G、B分量
int r=GetRValue(GetPixel(hdc,x,y));