Bitmap的调色板和头信息相信你可以得到,剩下的就是图像信息,可用GetDIBits获得

解决方案 »

  1.   

    CBitmap* inbitmap;//源 CBitmap* m_pBitmap;   
    m_pBitmap=new CBitmap;
    BITMAP bt;
    inbitmap->GetBitmap(&bt);
         m_pBitmap->CreateBitmapIndirect(&bt);      LPVOID lpBits=NULL ;
    lpBits=new unsigned char[bt.bmWidthBytes*bt.bmHeight];
    if(lpBits==NULL) return ;
    DWORD dwCount=bt.bmWidthBytes*bt.bmHeight; inbitmap->GetBitmapBits(dwCount,lpBits);
    m_pBitmap->SetBitmapBits(dwCount,lpBits);
          
    if(lpBits) 
                    {
    delete lpBits;
                     lpBits=NULL;
    }我的代码 有时可以 有时有问题,why?
      

  2.   

    你动态分配的内存只是“长乘以高”各单位,可是在24bit的位图中,因该是3*Height*Width.
      

  3.   

    动态分配的内存只是“长乘以高”各单位,可是在24bit的位图中,因该是3*Height*Width.
      

  4.   

    HBITMAP HBM=(HBITMAP)inbitmap->Detach();
    m_pBitmap=new CBitmap;
    m_pBitmap->Attach(HBM);above code is ok. but  why using "detach()"?
      

  5.   

    CBitmap是包装一个HBITMAP而已,Detach断开他与这个HBITMAP的连接。ATTACH连接一个新的HBITMAP,,