http://www.vckbase.com/code/listcode.asp?mclsid=7&sclsid=703
我用的上面这个例子的方法 CString sFilter="Capture Files (*.bmp)|*.bmp|All Files (*.*)|*.* ||";
CFileDialog dlg(1,"", m_fileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, sFilter); if(dlg.DoModal()==IDCANCEL)
return; CString ext = dlg.GetFileExt(); if ( (ext != "bmp") && (ext != "jpg") )
return; if (ext == "jpg") 
{
CString nameBmp = dlg.GetPathName();
nameBmp.Replace(".jpg",".bmp");
WriteBmp(nameBmp); BmpToJpg(nameBmp,dlg.GetPathName());
}void CCaptureView::BmpToJpg(CString nameBmp, CString nameJpg)
{
UpdateData(TRUE);
HINSTANCE hInst;
CHANGE *pFunc;
hInst = ::LoadLibrary("jpgdll.dll");
pFunc = (CHANGE*)::GetProcAddress(hInst,"BmpToJpg");
pFunc(nameBmp.GetBuffer(100),nameJpg.GetBuffer(100));
nameBmp.ReleaseBuffer();
nameJpg.ReleaseBuffer();
::FreeLibrary(hInst); CFile file;
file.Open(nameBmp,CFile::modeCreate|CFile::modeWrite);
file.Remove(nameBmp);
file.Close();
}到pFunc(nameBmp.GetBuffer(100),nameJpg.GetBuffer(100));这里总出错?怎么回事?

解决方案 »

  1.   

    这里
    pFunc(nameBmp.GetBuffer(100),nameJpg.GetBuffer(100));
    为什么是
    GetBuffer(100)
    而不是
    GetBuffer(0)
    呢?
      

  2.   

    GetBuffer(100)
    他的列子里是GetBuffer(50)
    我为了防止文件Pathname过长,把buffer加大了不过我不管用50,100还是 0,都有错误啊还有谁看过这个列子啊,为什么例子里的没问题,我错在哪里了?
      

  3.   

    拷贝了,肯定没有错
    就算没拷贝也该是
    hInst = ::LoadLibrary("jpgdll.dll");
    出错把为什么是pFunc(nameBmp.GetBuffer(100),nameJpg.GetBuffer(100));
    出错呢
      

  4.   

    用gdiplus吧,用什么第三方库啊,msdn里面有现成的例子。
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/usingGDIPlus/usingimageencodersanddecoders/convertingabmpimagetoapngimage.asp?frame=true
    你就把里面的image/png换成image/jpeg就成
      

  5.   

    你就把里面的image/png换成image/jpeg就成有那么厉害?我试试看了
      

  6.   

    http://www.csdn.net/develop/read_article.asp?id=22948