看看这一页,好好找找:
http://www.csdn.net/dev/Visual%20C++/source%20code/Bitmap/index.htm

解决方案 »

  1.   

    www.vckbase.com的vc知识库中有解决方案和例子程序
      

  2.   

    //在pDC 中显示任意颜色的位图
    BOOL  BmpRead(CDC *pDC,char *FileName,int x,int y)
    {
        int width,height;
        BITMAPINFOHEADER   bi;
        int          dwOffset; 
        int                i;
    CFile OpenFile;
        LOGPALETTE *lp;
        BYTE PaletteBuffer[1024];
        CPalette cp,*OldCp;
    BYTE *pBuf;
    BITMAPINFO  *bf;
    if(OpenFile.Open (FileName,CFile::modeRead)==NULL)return FALSE;
    OpenFile.Seek(14,CFile::begin);
        OpenFile.Read(&bi,40);        
        width=bi.biWidth;
        height=bi,biHeight;
    if(bi.biSizeImage==0)bi.biSizeImage=(long)bi.biWidth*bi.biHeight*bi.biBitCount/8;
      
        if(bi.biBitCount<=8)
    {
    lp =(LOGPALETTE *)new BYTE[sizeof(LOGPALETTE) +(int)bi.biClrUsed* sizeof(PALETTEENTRY)];
        lp->palVersion=0x300;
        lp->palNumEntries=(int)bi.biClrUsed;
        OpenFile.Read(PaletteBuffer,(int)bi.biClrUsed*4);
        OpenFile.Close();
        for (i = 0; i < (int)bi.biClrUsed; i++){
                lp->palPalEntry[i].peRed   = PaletteBuffer[4*i+2];
                lp->palPalEntry[i].peGreen = PaletteBuffer[4*i+1];
                lp->palPalEntry[i].peBlue  = PaletteBuffer[4*i+0];
                lp->palPalEntry[i].peFlags = 0;
            }
     cp.CreatePalette(lp);
     OldCp=pDC->SelectPalette(&cp,FALSE);
     pDC->RealizePalette();
     }
     else
     OpenFile.Close();
         if(bi.biBitCount<=8)
         bf=(BITMAPINFO*)new BYTE[bi.biSize + bi.biClrUsed *4];
         else 
     bf=(BITMAPINFO*)new BYTE[bi.biSize];
     
    OpenFile.Open (FileName, CFile::modeRead);
        OpenFile.Seek(14,CFile::begin);
        
    if(bi.biBitCount<=8)
        OpenFile.Read(bf,(int)bi.biClrUsed *4+bi.biSize);
    else
    OpenFile.Read(bf,bi.biSize);
        OpenFile.Close(); pBuf=new BYTE[bi.biSizeImage];    OpenFile.Open(FileName,CFile::modeRead);
       
        if(bi.biBitCount<=8)
        dwOffset=54+bi.biClrUsed*4;
    else
    dwOffset=54;
        OpenFile.Seek(dwOffset,CFile::begin);
        OpenFile.Read(pBuf,bi.biSizeImage);
        OpenFile.Close(); x=x+(width-(int)bi.biWidth)/2;
    y=y+(height-(int)bi.biHeight)/2;
          StretchDIBits(
           pDC->m_hDC,                // handle to device context
           0,              // x-coordinate of upper-left corner of dest. rectangle
           0,              // y-coordinate of upper-left corner of dest. rectangle
           width,         // width of destination rectangle
           height,        // height of destination rectangle
           0,               // x-coordinate of upper-left corner of source rectangle
           0,               // y-coordinate of upper-left corner of source rectangle
           bi.biWidth,          // width of source rectangle
           bi.biHeight,         // height of source rectangle
           pBuf,            // address of bitmap bits
           (BITMAPINFO *)bf,  // address of bitmap data
           DIB_RGB_COLORS,                   // usage flags
           SRCCOPY                    // raster operation code
          
           );
    pDC->TextOut(0,0,ts);             
    if(bi.biBitCount<=8)
    {
     pDC->SelectPalette(OldCp,FALSE);
     cp.DeleteObject();
     delete lp;
     }
     delete pBuf;
     delete bf;
     return TRUE;
    }
      

  3.   

    pDC->TextOut(0,0,ts);  该行毫无价值,应该删除
             
      

  4.   

    不然再加上在Microsoft.com的KnowLeage上有loadpic.exe