1、在头文件StdAfx.h 内增加下述语句:
#ifndef ULONG_PTR
#define unsigned __int32 ULONG_PTR;
#endif #include <afxtempl.h>
#include "gdiplus.h"
#pragma comment(lib, "gdiplus.lib")
using namespace Gdiplus;
2、在APP.H 增加对函数的定义:
ULONG_PTR m_gdiplusToken;
3.在APP的InitInstance() 增加如下的初始化语句:
GdiplusStartupInput gdiplusStartupInput;
if(Gdiplus::Ok ! = GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL))
{
::MessageBox(NULL, _T("Initialize GDI+ library failed"),
_T("Error"), MB_OK|MB_ICONERROR);
return FALSE;
}
4。在CMyApp::~CMyApp()
{
GdiplusShutdown(m_gdiplusToken);
}
/////bmp转jpg
CImage pbtm;
pbtm.Load("c:\\aa.bmp");
pbtm.Save("c:\\aa.jpg",ImageFormatJPEG);