急!急!急!GetPixel()函数如何使用? 为何我取出的值总是-1?????
大侠们帮帮我啊,最好做个例子,我的信箱:[email protected]

解决方案 »

  1.   

    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
      

  2.   

    GetPixel返回的不是COLORREF格式的吗?
    typedef DWORD COLORREF;
    可以知道这是一个DWORD的
    DWORD 32-bit unsigned integer. 
    DWORD是一个无符号的,你得到-1,肯定是由符号的变量
      

  3.   

    See the samples below, useful :http://www.codeproject.com/gdi/colorz.asp
    http://www.codeproject.com/bitmap/pjaimage.asp
      

  4.   

    不是白色,白色:00ffffff
    而我的返回值老是:ffffffff
      

  5.   

    GetPixel取出的是一个COLORREF值
    可以用GetRValue、GetBValue、GetGValue宏
    取得其中的R、G、B分量
    int r=GetRValue(GetPixel(hdc,x,y));
      

  6.   

    zyylikeeating(桂花!上酸菜)  is right