几天都没有人给个解答,都是答非所问。
http://topic.csdn.net/u/20071208/11/0491fc3f-5b96-4fdd-97c3-5705c828ebd9.html
http://topic.csdn.net/u/20071208/11/0491fc3f-5b96-4fdd-97c3-5705c828ebd9.html改变界面的颜色,像QQ、MSN那样有个颜色改变,设置某个颜色,整个界面都以此颜色为基调。 
我认为其实就是改变图片的色调,但是不知道如何下手。

解决方案 »

  1.   

    我觉得可以使用RGB和HSL的转换算法,然后改变H的值整个色调就是在那个圆上转(想PS或AI的调色一样)
    转换算法参考:
    void RGBtoHSV( float r, float g, float b, float *h, float *s, float *v )
    {
    float min, max, delta;
    min = MIN( r, g, b );
    max = MAX( r, g, b );
    *v = max; // v
    delta = max - min;
    if( max != 0 )
    *s = delta / max; // s
    else {
    // r = g = b = 0 // s = 0, v is undefined
    *s = 0;
    *h = -1;
    return;
    }
    if( r == max )
    *h = ( g - b ) / delta; // between yellow & magenta
    else if( g == max )
    *h = 2 + ( b - r ) / delta; // between cyan & yellow
    else
    *h = 4 + ( r - g ) / delta; // between magenta & cyan
    *h *= 60; // degrees
    if( *h < 0 )
    *h += 360;
    }
    void HSVtoRGB( float *r, float *g, float *b, float h, float s, float v )
    {
    int i;
    float f, p, q, t;
    if( s == 0 ) {
    // achromatic (grey)
    *r = *g = *b = v;
    return;
    }
    h /= 60; // sector 0 to 5
    i = floor( h );
    f = h - i; // factorial part of h
    p = v * ( 1 - s );
    q = v * ( 1 - s * f );
    t = v * ( 1 - s * ( 1 - f ) );
    switch( i ) {
    case 0:
    *r = v;
    *g = t;
    *b = p;
    break;
    case 1:
    *r = q;
    *g = v;
    *b = p;
    break;
    case 2:
    *r = p;
    *g = v;
    *b = t;
    break;
    case 3:
    *r = p;
    *g = q;
    *b = v;
    break;
    case 4:
    *r = t;
    *g = p;
    *b = v;
    break;
    default: // case 5:
    *r = v;
    *g = p;
    *b = q;
    break;
    }
    }
      

  2.   

    1楼说的办法即使实现了,程序运行效率也会影响很大的。
    最快速有效的还是贴图片。
    准备好不同基调下的洁面所需要的多组图片,不同基调下选择不同的图片显示。
    QQ,金山系列软件,winmap等软件都是怎么做的
      

  3.   

    回复laviewpbt :
    既然简单的吓人,可否透露一下
      

  4.   

    HSL颜色空间 
    HSL(hue,saturation,lightness)颜色空间,这个颜色空间都是用户台式机图形程序的颜色表示,用六角形锥体表示自己的颜色模型。
    hue就是色调!将你的颜色空间转换到HSL改变hue分量就好了!!
      

  5.   

    我能想出来的还有一种方法就是所有资源全部使用32位,同时alpha值都改成50%或者70%就是半透明状态
    然后提供一个底色,将全部资源通过AlphaBlend覆盖在底色上,只要改变底色就能很容易的改变色调了。
    可以想MSN那样选择一种基色作为底色。
      

  6.   

    應該是用了AlphaBlend還有種方式,是用 png 做了個模板,有 Alpha 通道的。再用 GDI+ 在上面做顏色疊加。--------
    我猜的
      

  7.   

    回复楼上两位:
    AlphaBlend 我不是很了解,我觉得这个方法实质应该还是改变每个像素的像素值,不知道效率如何?可否有例子?
    MSN就不清楚是怎么搞的,不过QQ似乎不是用的这个方法
      

  8.   

    AlphaBlend实现起来方便一些
    而且预设颜色可以定义。AlphaBlend
    The AlphaBlend function displays bitmaps that have transparent or semitransparent pixels.BOOL AlphaBlend(
      HDC hdcDest,                 // handle to destination DC
      int nXOriginDest,            // x-coord of upper-left corner
      int nYOriginDest,            // y-coord of upper-left corner
      int nWidthDest,              // destination width
      int nHeightDest,             // destination height
      HDC hdcSrc,                  // handle to source DC
      int nXOriginSrc,             // x-coord of upper-left corner
      int nYOriginSrc,             // y-coord of upper-left corner
      int nWidthSrc,               // source width
      int nHeightSrc,              // source height
      BLENDFUNCTION blendFunction  // alpha-blending function
    );
    Parameter
    hdcDest  Handle to the destination device context. 
    nXOriginDest  Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle. 
    nYOriginDest  Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle. 
    nWidthDest  Specifies the width, in logical units, of the destination rectangle. 
    nHeightDest Specifies the height, in logical units, of the destination rectangle. 
    hdcSrc  Handle to the source device context. 
    nXOriginSrc  Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle. 
    nYOriginSrc  Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle. 
    nWidthSrc  Specifies the width, in logical units, of the source rectangle. 
    nHeightSrc  Specifies the height, in logical units, of the source rectangle. 
    blendFunction  Specifies the alpha-blending function for source and destination bitmaps, a global alpha value to be applied to the entire source bitmap, and format information for the source bitmap. The source and destination blend functions are currently limited to AC_SRC_OVER. See the BLENDFUNCTION and EMRALPHABLEND structures. Return Values
    If the function succeeds, the return value is TRUE.
    If the function fails, the return value is FALSE. 假设你的Bitmap资源是IDB_RESOURCE,用32bit并且将透明度调到60%或者70%。下面这些代码就能实现将这个半透明的Bmp绘制在已用的窗口上
    可以将所有需要改变色调的东西先绘制好,在执行下面的,或这个这个bmp是什么颜色你的窗体就是什么颜色,最后在绘制最上一层的东西就OK了。LPCTSTR lpszResourceName = MAKEINTRESOURCE (IDB_RESOURCE);
    ASSERT(lpszResourceName != NULL);
    HINSTANCE hinstRes = AfxFindResourceHandle (lpszResourceName, RT_BITMAP);
    HBITMAP hbmp = (HBITMAP) ::LoadImage (
    hinstRes,
    lpszResourceName,
    IMAGE_BITMAP,
    0, 0,
    LR_CREATEDIBSECTION);
    int i = 0;
    DIBSECTION ds;
    if (::GetObject (hbmp, sizeof (DIBSECTION), &ds) == 0)
    return;
    RGBQUAD* pBits = (RGBQUAD*) ds.dsBm.bmBits;//----------------------------------------------------------------
    // Premultiply the R,G and B values with the Alpha channel values:
    //----------------------------------------------------------------
    for (i = 0; i < ds.dsBm.bmWidth * ds.dsBm.bmHeight; i++)
    {
    RGBQUAD* pBit = pBits + i;
    pBit->rgbRed = (BYTE) (pBit->rgbRed * pBit->rgbReserved / 255);
    pBit->rgbGreen = (BYTE) (pBit->rgbGreen * pBit->rgbReserved / 255);
    pBit->rgbBlue = (BYTE) (pBit->rgbBlue * pBit->rgbReserved / 255);
    }
    HDC dcMem;
    dcMem = CreateCompatibleDC(NULL);BLENDFUNCTION bf;
    bf.BlendOp = AC_SRC_OVER;
    bf.BlendFlags = 0;
    bf.SourceConstantAlpha = 0xFF;  // 0x00 (transparent) through 0xFF (opaque)
    bf.AlphaFormat = AC_SRC_ALPHA;  // Use bitmap alpha
    HBITMAP hBmpOriginal = (HBITMAP) SelectObject (dcMem, hbmp);AlphaBlend(pDC->m_hDC, rectMarker.left,rectMarker.top, 16, 16, dcMem, 0,0,16,16,bf); 
      

  9.   

    應該是用了AlphaBlend 還有種方式,是用 png 做了個模板,有 Alpha 通道的。 再用 GDI+ 在上面做顏色疊加。 -------- 
    我猜的就是我說的方法