先用CFile 文件打开这.bmp文件把文件的指针a指相他。定义一个CBITMAP类用这个类的装载函数加载指针a的这个bmp文件。这样就可以打开位图了。至于保存则可以用CFile这个类的copy和remove等函数。由于我在网吧上网手头没有源码
如果要源码可以写信我 ......
[email protected]

解决方案 »

  1.   

    关注!!
    我曾有同样的一个例似的问题,用CFileDialog预览工程图片.至今没结果.关注,希望得到启示 :)
      

  2.   

    static char BASED_CODE szFilter[] = "24位位图 (*.bmp)|*.bmp||";
    CFileDialog m_ldFile(TRUE, ".bmp", m_strSelfTexture, OFN_HIDEREADONLY |
    OFN_OVERWRITEPROMPT, szFilter);
    if(m_ldFile.DoModal() == IDOK)
    {
      m_strSelfTexture =  m_ldFile.GetPathName();
    char * chTexture=  (char*)(LPCSTR)m_strSelfTexture;
    /////////////////////////////////////////////
    CFile file; CString msg;
    if(!file.Open(chTexture, CFile::modeRead))
    {
    msg.Format("Failed to open %s.", chTexture);
    AfxMessageBox(msg);
    }
    UINT nBytes = file.GetLength();

    file.Read(&header, sizeof(BITMAPFILEHEADER));
    if( header.bfType != 'MB')
    {
    msg.Format("%s is not a bmp file.", chTexture);
    AfxMessageBox(msg);
    }
    file.Read(&infoHeader, sizeof(BITMAPINFOHEADER));
    if(infoHeader.biBitCount != 24)
    {
    msg.Format("%s is not a 24 bytes bmp file.", chTexture);
    AfxMessageBox(msg);
    }
    file.Seek(header.bfOffBits, CFile::begin);
     data = new unsigned char[infoHeader.biSizeImage]; 
    file.ReadHuge(data, infoHeader.biSizeImage);
    只是打开24位位图的!