RGB(a,b,c)中有3个数字变量,我想分别得到每个变量,然后赋值到另外三个变量e,f,g中,如何实现??

解决方案 »

  1.   

    3个宏
    GetRValue
    GetGValue
    GetBValue
      

  2.   

    由RGB的定义:
    #define RGB(r,g,b) ((COLORREF)(((BYTE)(r)||
                       ((WORD)((BYTE))(g)<<8))||
                       ((DWORD)(BYTE))(b)<<16)))
    你可以用"移位"和"与"这两个操作符实现
      

  3.   

    GetRValue
    GetGValue
    GetBValue
      

  4.   

    我得到的数字总是不对?? 
    BYTE a1=GetRValue(RGB(255,255,255));
    CString b2;
    b2.Format("%x",a1);
    为什么b2不是255,而是22??
    我要得到255要怎样做??
      

  5.   

    b2.Format("%d",a1); //用%d