From dea9c030340e50324eba97c72a27c151bed12e1c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 26 Jan 2018 17:38:31 +0300 Subject: AdvaImg: - freeimage extracted to the separate library; - FI_INTERFACE removed, all references to it are replaced with direct calls of FreeImage_* functions; - unified project for AdvaImg --- protocols/JabberG/jabber.vcxproj | 3 +++ protocols/JabberG/src/jabber.cpp | 7 ------- protocols/JabberG/src/jabber_userinfo.cpp | 2 +- protocols/JabberG/src/jabber_vcard.cpp | 2 +- protocols/JabberG/src/stdafx.h | 2 -- protocols/SkypeWeb/SkypeWeb.vcxproj | 5 +++++ protocols/SkypeWeb/src/main.cpp | 2 -- protocols/SkypeWeb/src/skype_avatars.cpp | 4 +--- protocols/SkypeWeb/src/stdafx.h | 1 - protocols/Steam/Steam.vcxproj | 7 ++++++- protocols/Steam/src/stdafx.h | 1 - protocols/Steam/src/steam_dialogs.cpp | 35 ++++++++++--------------------- protocols/VKontakte/src/main.cpp | 3 +-- protocols/VKontakte/src/misc.cpp | 12 +++++------ protocols/VKontakte/src/stdafx.h | 1 - protocols/VKontakte/vk.vcxproj | 3 +++ 16 files changed, 38 insertions(+), 52 deletions(-) (limited to 'protocols') diff --git a/protocols/JabberG/jabber.vcxproj b/protocols/JabberG/jabber.vcxproj index c6efee4881..74dddceefa 100755 --- a/protocols/JabberG/jabber.vcxproj +++ b/protocols/JabberG/jabber.vcxproj @@ -35,6 +35,9 @@ + + {5D14CFF3-0D17-4528-99EA-DE9DCA47CC2E} + {620e0be7-3763-4f35-9dbd-4770104e269c} diff --git a/protocols/JabberG/src/jabber.cpp b/protocols/JabberG/src/jabber.cpp index 3a5282312c..fe30a49b98 100755 --- a/protocols/JabberG/src/jabber.cpp +++ b/protocols/JabberG/src/jabber.cpp @@ -60,7 +60,6 @@ PLUGININFOEX pluginInfo = { }; CLIST_INTERFACE* pcli; -FI_INTERFACE *FIP = nullptr; HANDLE hExtraActivity = nullptr; HANDLE hExtraMood = nullptr; @@ -186,12 +185,6 @@ extern "C" int __declspec(dllexport) Load() pci = Chat_GetInterface(); pcli = Clist_GetInterface(); - INT_PTR result = CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&FIP); - if (FIP == nullptr || result != S_OK) { - MessageBoxEx(nullptr, TranslateT("Fatal error, image services not found. Jabber Protocol will be disabled."), L"Error", MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); - return 1; - } - char mirVer[100]; Miranda_GetVersionText(mirVer, _countof(mirVer)); mir_wstrcpy(szCoreVersion, _A2T(mirVer)); diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index 02bf04ef50..ca396d758e 100755 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -658,7 +658,7 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP if (item->photoFileName) { photoInfo->ppro->debugLogW(L"Showing picture from %s", item->photoFileName); photoInfo->hBitmap = Bitmap_Load(item->photoFileName); - FIP->FI_Premultiply(photoInfo->hBitmap); + FreeImage_Premultiply(photoInfo->hBitmap); ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_SHOW); } } diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index e775b2b199..3191ea28de 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -296,7 +296,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR dat->ppro->debugLogW(L"Temp file = %s", szTempFileName); if (CopyFile(szAvatarFileName, szTempFileName, FALSE) == TRUE) { if ((dat->hBitmap = Bitmap_Load(szTempFileName)) != nullptr) { - FIP->FI_Premultiply(dat->hBitmap); + FreeImage_Premultiply(dat->hBitmap); mir_wstrcpy(dat->ppro->m_szPhotoFileName, szTempFileName); EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE); } diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index bbd82c7425..e9b233babc 100644 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -587,8 +587,6 @@ extern unsigned int g_nTempFileId; extern int g_cbCountries; extern struct CountryListEntry* g_countries; -extern FI_INTERFACE *FIP; - extern HANDLE hExtListInit, hDiscoInfoResult; extern bool bSecureIM, bMirOTR, bNewGPG, bPlatform; diff --git a/protocols/SkypeWeb/SkypeWeb.vcxproj b/protocols/SkypeWeb/SkypeWeb.vcxproj index ef2faedace..75292a9b36 100644 --- a/protocols/SkypeWeb/SkypeWeb.vcxproj +++ b/protocols/SkypeWeb/SkypeWeb.vcxproj @@ -50,6 +50,11 @@ + + + {5D14CFF3-0D17-4528-99EA-DE9DCA47CC2E} + + {f6a9340e-b8d9-4c75-be30-47dc66d0abc7} diff --git a/protocols/SkypeWeb/src/main.cpp b/protocols/SkypeWeb/src/main.cpp index 765b40ea7b..1b512abb87 100644 --- a/protocols/SkypeWeb/src/main.cpp +++ b/protocols/SkypeWeb/src/main.cpp @@ -20,7 +20,6 @@ along with this program. If not, see . int hLangpack; HINSTANCE g_hInstance; CLIST_INTERFACE *pcli; -FI_INTERFACE *fii = nullptr; char g_szMirVer[100]; HANDLE g_hCallEvent; CHAT_MANAGER *pci; @@ -58,7 +57,6 @@ extern "C" int __declspec(dllexport) Load(void) mir_getLP(&pluginInfo); pcli = Clist_GetInterface(); pci = Chat_GetInterface(); - CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&fii); Miranda_GetVersionText(g_szMirVer, sizeof(g_szMirVer)); PROTOCOLDESCRIPTOR pd = { 0 }; diff --git a/protocols/SkypeWeb/src/skype_avatars.cpp b/protocols/SkypeWeb/src/skype_avatars.cpp index 056ce171af..11f5535664 100644 --- a/protocols/SkypeWeb/src/skype_avatars.cpp +++ b/protocols/SkypeWeb/src/skype_avatars.cpp @@ -179,9 +179,7 @@ INT_PTR CSkypeProto::SvcSetMyAvatar(WPARAM, LPARAM lParam) mir_ptr data((PBYTE)mir_alloc(length)); if (data != NULL && fread(data, sizeof(BYTE), length, hFile) == length) { - const char *szMime = "image/jpeg"; - if (fii) - szMime = fii->FI_GetFIFMimeType(fii->FI_GetFIFFromFilenameU(path)); + const char *szMime = FreeImage_GetFIFMimeType(FreeImage_GetFIFFromFilenameU(path)); PushRequest(new SetAvatarRequest(data, length, szMime, li), &CSkypeProto::OnSentAvatar); fclose(hFile); diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h index f7166238cc..94abd8398d 100644 --- a/protocols/SkypeWeb/src/stdafx.h +++ b/protocols/SkypeWeb/src/stdafx.h @@ -60,7 +60,6 @@ struct CSkypeProto; extern HINSTANCE g_hInstance; extern char g_szMirVer[]; extern HANDLE g_hCallEvent; -extern FI_INTERFACE *fii; struct SESSION_INFO : public GCSessionInfoBase {}; diff --git a/protocols/Steam/Steam.vcxproj b/protocols/Steam/Steam.vcxproj index 32646d1950..0db6b56896 100644 --- a/protocols/Steam/Steam.vcxproj +++ b/protocols/Steam/Steam.vcxproj @@ -28,7 +28,12 @@ - + + + + {5D14CFF3-0D17-4528-99EA-DE9DCA47CC2E} + + Sync diff --git a/protocols/Steam/src/stdafx.h b/protocols/Steam/src/stdafx.h index a8aa969ca3..4bbc6f770b 100644 --- a/protocols/Steam/src/stdafx.h +++ b/protocols/Steam/src/stdafx.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/protocols/Steam/src/steam_dialogs.cpp b/protocols/Steam/src/steam_dialogs.cpp index b3731551b0..568156796f 100644 --- a/protocols/Steam/src/steam_dialogs.cpp +++ b/protocols/Steam/src/steam_dialogs.cpp @@ -156,40 +156,27 @@ INT_PTR CSteamCaptchaDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_PAINT) { - FI_INTERFACE *fei = nullptr; - - INT_PTR result = CALLSERVICE_NOTFOUND; - if (ServiceExists(MS_IMG_GETINTERFACE)) - result = CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&fei); - - if (fei == nullptr || result != S_OK) { - MessageBox(nullptr, TranslateT("Fatal error, image services not found. Avatar services will be disabled."), TranslateT("Avatar Service"), MB_OK); - return 0; - } - - FIMEMORY *stream = fei->FI_OpenMemory(m_captchaImage, m_captchaImageSize); - FREE_IMAGE_FORMAT fif = fei->FI_GetFileTypeFromMemory(stream, 0); - FIBITMAP *bitmap = fei->FI_LoadFromMemory(fif, stream, 0); - fei->FI_CloseMemory(stream); + FIMEMORY *stream = FreeImage_OpenMemory(m_captchaImage, m_captchaImageSize); + FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(stream, 0); + FIBITMAP *bitmap = FreeImage_LoadFromMemory(fif, stream, 0); + FreeImage_CloseMemory(stream); PAINTSTRUCT ps; HDC hDC = BeginPaint(m_hwnd, &ps); - //SetStretchBltMode(hDC, COLORONCOLOR); StretchDIBits( hDC, 11, 11, - fei->FI_GetWidth(bitmap) - 13, - fei->FI_GetHeight(bitmap), + FreeImage_GetWidth(bitmap) - 13, + FreeImage_GetHeight(bitmap), 0, 0, - fei->FI_GetWidth(bitmap), - fei->FI_GetHeight(bitmap), - fei->FI_GetBits(bitmap), - fei->FI_GetInfo(bitmap), + FreeImage_GetWidth(bitmap), + FreeImage_GetHeight(bitmap), + FreeImage_GetBits(bitmap), + FreeImage_GetInfo(bitmap), DIB_RGB_COLORS, SRCCOPY); - fei->FI_Unload(bitmap); - //fei->FI_DeInitialise(); + FreeImage_Unload(bitmap); EndPaint(m_hwnd, &ps); diff --git a/protocols/VKontakte/src/main.cpp b/protocols/VKontakte/src/main.cpp index 28ce73acae..8f367d6c02 100644 --- a/protocols/VKontakte/src/main.cpp +++ b/protocols/VKontakte/src/main.cpp @@ -21,7 +21,6 @@ along with this program. If not, see . HINSTANCE hInst; int hLangpack; CLIST_INTERFACE *pcli; -FI_INTERFACE *fii; PLUGININFOEX pluginInfo = { @@ -71,7 +70,7 @@ extern "C" int __declspec(dllexport) Load() { mir_getLP(&pluginInfo); pcli = Clist_GetInterface(); - CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&fii); + InitIcons(); // Register protocol module diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index b9d155e48b..1169de5b01 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -1469,16 +1469,16 @@ void CVkProto::ShowCaptchaInBrowser(HBITMAP hBitmap) if (pFile == nullptr) return; - FIBITMAP *dib = fii->FI_CreateDIBFromHBITMAP(hBitmap); - FIMEMORY *hMem = fii->FI_OpenMemory(nullptr, 0); - fii->FI_SaveToMemory(FIF_PNG, dib, hMem, 0); + FIBITMAP *dib = FreeImage_CreateDIBFromHBITMAP(hBitmap); + FIMEMORY *hMem = FreeImage_OpenMemory(nullptr, 0); + FreeImage_SaveToMemory(FIF_PNG, dib, hMem, 0); BYTE *buf = nullptr; DWORD bufLen; - fii->FI_AcquireMemory(hMem, &buf, &bufLen); + FreeImage_AcquireMemory(hMem, &buf, &bufLen); ptrA base64(mir_base64_encode(buf, bufLen)); - fii->FI_CloseMemory(hMem); - fii->FI_Unload(dib); + FreeImage_CloseMemory(hMem); + FreeImage_Unload(dib); CMStringA szHTML(FORMAT, "", base64); fwrite(szHTML, 1, szHTML.GetLength(), pFile); diff --git a/protocols/VKontakte/src/stdafx.h b/protocols/VKontakte/src/stdafx.h index 6a78386a59..148637c0a0 100644 --- a/protocols/VKontakte/src/stdafx.h +++ b/protocols/VKontakte/src/stdafx.h @@ -56,7 +56,6 @@ along with this program. If not, see . #include "win2k.h" -extern FI_INTERFACE *fii; extern HINSTANCE hInst; #include "resource.h" diff --git a/protocols/VKontakte/vk.vcxproj b/protocols/VKontakte/vk.vcxproj index b4090002ff..7452affb5e 100644 --- a/protocols/VKontakte/vk.vcxproj +++ b/protocols/VKontakte/vk.vcxproj @@ -34,5 +34,8 @@ {f6a9340e-b8d9-4c75-be30-47dc66d0abc7} + + {5D14CFF3-0D17-4528-99EA-DE9DCA47CC2E} + \ No newline at end of file -- cgit v1.2.3