VC中如何将内存中的bmp数据转化成jpg数据?并保存? 请问: 如何将内存中的bmp数据转化成jpg数据,并保存到文件? 通过什么方法控制jpg的质量? 本人急用!最后能给出段代码!哪位大侠做过,有没有这方面的资料?感激不尽! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 opencv里有函数cvSaveImage( , ); hndx3000 你可以留下你油箱吗? 我把代码给你发我油箱[email protected] openCV的cvsaveimage()是自动转换的(可以去看它的源码),应该对你没什么用处。 int GetEncoderClsid(const WCHAR* format, CLSID* pClsid){ UINT num = 0; // number of image encoders UINT size = 0; // size of the image encoder array in bytes ImageCodecInfo* pImageCodecInfo = NULL; GetImageEncodersSize(&num, &size); if(size == 0) return -1; // Failure pImageCodecInfo = (ImageCodecInfo*)(malloc(size)); if(pImageCodecInfo == NULL) return -1; // Failure GetImageEncoders(num, size, pImageCodecInfo); for(UINT j = 0; j < num; ++j) { if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 ) { *pClsid = pImageCodecInfo[j].Clsid; free(pImageCodecInfo); return j; // Success } } free(pImageCodecInfo); return -1; // Failure}GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); Image* img = Image::FromFile( _T("c:\\1.bmp")); CLSID pngClsid; GetEncoderClsid(L"image/png", &pngClsid); img->Save( _T("c:\\1.jpg") , &pngClsid , NULL); 楼上,我需要的是把内存中的bmp转换为jpg你说的是从文件中转换吧??????????? to Lz我已经把改好的工程发给你了,注意查收 zhao还是出错了,你帮我再看看,我已经发到你邮箱,注意查收下 to anty251遇到编译错误时,不要紧张,仔细看看错误信息,根据错误信息的提示,是可以解决的,如下:d:\工具\new folder\new folder\cgstorebmp\jmorecfg.h(215): warning C4005: “FAR” : 宏重定义CGStoreBmp fatal error LNK1181: 无法打开输入文件“\工具\new folder\lib\CGVideo.lib”d:\工具\new folder\new folder\cgstorebmp\cgstorebmp.cpp(52): warning C4996: “CWinApp::Enable3dControls”被声明为否决的对于第一条:其实是因为在jmorecfg.h里又重新定义了FAR这个宏,这个宏在VS的其它头文件里已经定义过了,不过我们可以对它忽略不计,因为编译器对这个错误也是忽略的对于第二条:是因为CGVideo.lib的位置变了,所以编译器链接时找不到它了,你该知道怎么做了吧?第三条:我不用解释了吧? 我都改了上面这三条错误,再编译又出现了下面的错误:GStoreBmp warning LNK4098: 默认库“LIBCMT”与其他库的使用冲突;使用 /NODEFAULTLIB:libraryCGStoreBmp warning LNK4075: 忽略“/EDITANDCONTINUE”(由于“/INCREMENTAL:NO”规范)d:\工具\new folder\new folder\cgstorebmp\cgstorebmp.cpp(52): warning C4996: “CWinApp::Enable3dControls”被声明为否决的CGStoreBmp fatal error LNK1120: 1 个无法解析的外部命令CGStoreBmp error LNK2019: 无法解析的外部符号 __ftol2_sse ,该符号在函数 "void __cdecl forward_DCT_float(struct jpeg_compress_struct *,struct jpeg_component_info *,unsigned char * *,short (*)[64],unsigned int,unsigned int,unsigned int)" (?forward_DCT_float@@YAXPAUjpeg_compress_struct@@PAUjpeg_component_info@@PAPAEPAY0EA@FIII@Z) 中被引用这些我看不出来帮忙看下咯感谢你拉 Status Save( IStream *stream, const CLSID *clsidEncoder, const EncoderParameters *encoderParams); 用内存方式将bmp转换成jpg的代码,我现在也正在做这个,可不可发给我一份啊,,谢谢 关于MFC的结构 两个进程之间使用pipe传递数据,传递的数据能hook到吗? 罕见问题:请问QQ和MSN上的人物tree的项是怎么实现的?使用的什么控件? 如何制作类似与VC界面的Class,Resource,FileView之间切换的程序 求助:如何将工具栏中的按钮变成单选一按钮? OnTimer()怎么使用?怎么使系统时间实时变化? 怎么样用程序来设置,按钮的标题? 那位大哥能给个apihook的代码呀,一定加分! 窗口 POP3中如何通知服务器不要再发送数据? 作战理论入门[日]陆上自卫队修(带链接) vc++ 如何显示 维文
我油箱[email protected]
{
UINT num = 0; // number of image encoders
UINT size = 0; // size of the image encoder array in bytes ImageCodecInfo* pImageCodecInfo = NULL; GetImageEncodersSize(&num, &size);
if(size == 0)
return -1; // Failure pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1; // Failure GetImageEncoders(num, size, pImageCodecInfo); for(UINT j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
*pClsid = pImageCodecInfo[j].Clsid;
free(pImageCodecInfo);
return j; // Success
}
} free(pImageCodecInfo);
return -1; // Failure
}
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
Image* img = Image::FromFile( _T("c:\\1.bmp"));
CLSID pngClsid;
GetEncoderClsid(L"image/png", &pngClsid);
img->Save( _T("c:\\1.jpg") , &pngClsid , NULL);
你说的是从文件中转换吧?
??????????
我已经把改好的工程发给你了,注意查收
还是出错了,你帮我再看看,我已经发到你邮箱,注意查收下
d:\工具\new folder\new folder\cgstorebmp\jmorecfg.h(215): warning C4005: “FAR” : 宏重定义
CGStoreBmp fatal error LNK1181: 无法打开输入文件“\工具\new folder\lib\CGVideo.lib”
d:\工具\new folder\new folder\cgstorebmp\cgstorebmp.cpp(52): warning C4996: “CWinApp::Enable3dControls”被声明为否决的对于第一条:其实是因为在jmorecfg.h里又重新定义了FAR这个宏,这个宏在VS的其它头文件里已经定义过了,不过我们可以对它忽略不计,因为编译器对这个错误也是忽略的
对于第二条:是因为CGVideo.lib的位置变了,所以编译器链接时找不到它了,你该知道怎么做了吧?
第三条:我不用解释了吧?
CGStoreBmp warning LNK4075: 忽略“/EDITANDCONTINUE”(由于“/INCREMENTAL:NO”规范)
d:\工具\new folder\new folder\cgstorebmp\cgstorebmp.cpp(52): warning C4996: “CWinApp::Enable3dControls”被声明为否决的
CGStoreBmp fatal error LNK1120: 1 个无法解析的外部命令
CGStoreBmp error LNK2019: 无法解析的外部符号 __ftol2_sse ,该符号在函数 "void __cdecl forward_DCT_float(struct jpeg_compress_struct *,struct jpeg_component_info *,unsigned char * *,short (*)[64],unsigned int,unsigned int,unsigned int)" (?forward_DCT_float@@YAXPAUjpeg_compress_struct@@PAUjpeg_component_info@@PAPAEPAY0EA@FIII@Z) 中被引用这些我看不出来
帮忙看下咯
感谢你拉
const CLSID *clsidEncoder,
const EncoderParameters *encoderParams
);