I wrote a PBNI wrapper around it, but it only exposed one method (one that is used to convert a bmp to a jpg):
#include "PBFreeImage.h" #include "FreeImage.h" BOOL APIENTRY DllMain ( HANDLE hModule, DWORD ul_reason_for_all, LPVOID lpReserved ) { switch(ul_reason_for_all) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } PBXEXPORT LPCTSTR PBXCALL PBX_GetDescription() { static const TCHAR classDesc[] = { _T("class n_cpp_pbni_pbfreeimage from nonvisualobject\n") \ _T(" function int of_ConvertBmp2Jpg(string file_in, string file_out)\n") \ _T("end class\n") }; return (LPCTSTR)classDesc; } PBXEXPORT PBXRESULT PBXCALL PBX_CreateNonVisualObject ( IPB_Session * session, pbobject obj, LPCTSTR className, IPBX_NonVisualObject ** nvobj ) { if (_tcscmp(className, _T("n_cpp_pbni_pbfreeimage")) == 0) *nvobj = new PBFreeImage(session); return PBX_OK; } PBFreeImage::PBFreeImage() { } PBFreeImage::PBFreeImage( IPB_Session * pSession ) :m_pSession( pSession ) { } PBFreeImage::~PBFreeImage() { } PBXRESULT PBFreeImage::Invoke ( IPB_Session * session, pbobject obj, pbmethodID mid, PBCallInfo * ci ) { PBXRESULT pbxr = PBX_OK; switch ( mid ) { case mid_ConvertBmp2Jpg: pbxr = this->ConvertBmp2Jpg( session, ci ); break; default: pbxr = PBX_E_INVOKE_METHOD_AMBIGUOUS; } return pbxr; } void PBFreeImage::Destroy() { delete this; } PBXRESULT PBFreeImage::ConvertBmp2Jpg( IPB_Session *session,PBCallInfo * ci ) { PBXRESULT pbxr = PBX_OK; LPSTR FileName; LPSTR FileNameOut; IPB_Value* FileNameArg ; IPB_Value* FileNameArgOut ; FileNameArg = session->AcquireValue ( ci->pArgs->GetAt(0) ) ; pbstring pbFileName = FileNameArg->GetString() ; FileNameArgOut = session->AcquireValue ( ci->pArgs->GetAt(1) ) ; pbstring pbFileNameout = FileNameArgOut->GetString() ; FileName = (LPSTR)session->GetString ( pbFileName ) ; FileNameOut = (LPSTR)session->GetString ( pbFileNameout ) ; FIBITMAP *dib =FreeImage_Load(FIF_BMP, _T(FileName) , 0); unsigned int width = FreeImage_GetWidth(dib); unsigned int height = FreeImage_GetHeight(dib); if (( width > 200 ) || ( height > 45 )) { //double widthratio = width / 200 ; //double heightratio = height / 45 ; //if ( widthratio > heightratio ) { // width = width / widthratio ; // height = height / widthratio ; //} //else { // width = width / heightratio ; // height = height / heightratio ; //} width = 200 ; height = 200 ; FreeImage_Rescale ( dib, width, height, FILTER_BOX ); } FreeImage_Save(FIF_JPEG, dib, _T(FileNameOut), 0); ci->returnValue->SetLong(1); return pbxr; }