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));这里总出错?怎么回事?
我用的上面这个例子的方法 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));这里总出错?怎么回事?
解决方案 »
- MFC宏定义define,#define GIF int * \ GIF s , h; \ s ,h各是何类型?
- CTreeCtrl 的InsertItem,其中有一个是有UINT nState, UINT nStateMask参数,它们应该填什么?
- 如何实现鼠标拖动图片
- DataGrid在什么情况下不能正常使用?
- 求vox编码模块
- 发放视频会议源码,支持16路视频
- 放分:为什么的地方不能自动提示呢?
- 小妹欲哭无泪。。。
- 恢复Hook KiFastCallEnty后 蓝屏?
- 谁有《Windows核心编程》的源代码?
- 我的控件里有个WM_GETDLGCODE消息!在VB6下没法截获!在线等!高分!!高人快来!解决马上给分!
- 基于mfc的对话框程序里我怎么加入模板支持呀
pFunc(nameBmp.GetBuffer(100),nameJpg.GetBuffer(100));
为什么是
GetBuffer(100)
而不是
GetBuffer(0)
呢?
他的列子里是GetBuffer(50)
我为了防止文件Pathname过长,把buffer加大了不过我不管用50,100还是 0,都有错误啊还有谁看过这个列子啊,为什么例子里的没问题,我错在哪里了?
就算没拷贝也该是
hInst = ::LoadLibrary("jpgdll.dll");
出错把为什么是pFunc(nameBmp.GetBuffer(100),nameJpg.GetBuffer(100));
出错呢
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/usingGDIPlus/usingimageencodersanddecoders/convertingabmpimagetoapngimage.asp?frame=true
你就把里面的image/png换成image/jpeg就成