但bmp图片是有背景的啊
===啥意思?你所说的背景是什么?

解决方案 »

  1.   

    我是楼主,我的意思是说如果是bmp的话,不是会有背景色吗,但如果是gif或者png的话,就可以设置成没有背景色了
      

  2.   

    你查查函数,使一张位图的背景色透明BOOL TransparentBlt(
      HDC hdcDest,        // handle to destination DC
      int nXOriginDest,   // x-coord of destination upper-left corner
      int nYOriginDest,   // y-coord of destination upper-left corner
      int nWidthDest,     // width of destination rectangle
      int hHeightDest,    // height of destination rectangle
      HDC hdcSrc,         // handle to source DC
      int nXOriginSrc,    // x-coord of source upper-left corner
      int nYOriginSrc,    // y-coord of source upper-left corner
      int nWidthSrc,      // width of source rectangle
      int nHeightSrc,     // height of source rectangle
      UINT crTransparent  // color to make transparent
    );给你个例子:CDC *pDC = GetDC();
    CBitmap bmp;
    bmp.LoadBitmap(IDB_BITMAP5);
    CDC MemDC;
    MemDC.CreateCompatibleDC(pDC);
    MemDC.SelectObject(&bmp);
    BITMAP bmpInfo;
    bmp.GetBitmap(&bmpInfo);
    //使背景透明
    TransparentBlt(pDC->m_hDC, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, MemDC.m_hDC, 0, 0,
            bmpInfo.bmWidth, bmpInfo.bmHeight, RGB(255, 0, 255));
      

  3.   

    GDI+,可以多方面实现你的问题,将文字加入,背景色透明。而且,GDI+效率比较高。