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 --- plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp | 56 ++++++++++++------------- plugins/UserInfoEx/src/commonheaders.cpp | 1 - plugins/UserInfoEx/src/init.cpp | 10 ----- plugins/UserInfoEx/src/stdafx.h | 1 - 4 files changed, 28 insertions(+), 40 deletions(-) (limited to 'plugins/UserInfoEx/src') diff --git a/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp b/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp index 7dc3e80f3e..347c7c95e3 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp @@ -162,31 +162,31 @@ FIBITMAP* ConvertTo(FIBITMAP* dib, UINT destBits, bool greyscale) case 8: // convert to 8Bits if (greyscale) { - dib_res = FIP->FI_ConvertTo8Bits(dib); + dib_res = FreeImage_ConvertTo8Bits(dib); } else { - FIBITMAP* dib_tmp = FIP->FI_ConvertTo24Bits(dib); + FIBITMAP* dib_tmp = FreeImage_ConvertTo24Bits(dib); if (dib_tmp) { - dib_res = FIP->FI_ColorQuantize(dib_tmp, FIQ_WUQUANT/*FIQ_NNQUANT*/); - FIP->FI_Unload(dib_tmp); + dib_res = FreeImage_ColorQuantize(dib_tmp, FIQ_WUQUANT/*FIQ_NNQUANT*/); + FreeImage_Unload(dib_tmp); } } break; case 16: // convert to 16Bits - dib_res = FIP->FI_ConvertTo16Bits555(dib); + dib_res = FreeImage_ConvertTo16Bits555(dib); break; case 24: // convert to 24Bits - dib_res = FIP->FI_ConvertTo24Bits(dib); + dib_res = FreeImage_ConvertTo24Bits(dib); break; case 32: // convert to 32Bits - dib_res = FIP->FI_ConvertTo32Bits(dib); + dib_res = FreeImage_ConvertTo32Bits(dib); break; default: break; } - FIP->FI_Unload(dib); + FreeImage_Unload(dib); return dib_res; } @@ -201,13 +201,13 @@ FIBITMAP* LoadResource(UINT ID, LPTSTR lpType) if (buffer) { // attach the binary data to a memory stream - FIMEMORY *hmem = FIP->FI_OpenMemory(buffer, ResSize); + FIMEMORY *hmem = FreeImage_OpenMemory(buffer, ResSize); // get the file type - FREE_IMAGE_FORMAT fif = FIP->FI_GetFileTypeFromMemory(hmem, 0); + FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(hmem, 0); // load an image from the memory stream - dib = FIP->FI_LoadFromMemory(fif, hmem, 0); + dib = FreeImage_LoadFromMemory(fif, hmem, 0); // always close the memory stream - FIP->FI_CloseMemory(hmem); + FreeImage_CloseMemory(hmem); UnlockResource(buffer); } @@ -217,7 +217,7 @@ FIBITMAP* LoadResource(UINT ID, LPTSTR lpType) HBITMAP hScrBM = (HBITMAP)LoadImage(ghInst,MAKEINTRESOURCE(ID), IMAGE_BITMAP, 0, 0,LR_SHARED); if (hScrBM == nullptr) return dib; - dib = FIP->FI_CreateDIBFromHBITMAP(hScrBM); + dib = FreeImage_CreateDIBFromHBITMAP(hScrBM); DeleteObject(hScrBM); } return dib; @@ -288,31 +288,31 @@ void InitIcons() if (dib == nullptr) return; - if (FIP->FI_GetBPP(dib) != ILC_COLOR32) + if (FreeImage_GetBPP(dib) != ILC_COLOR32) if (nullptr == (dib = ConvertTo(dib, ILC_COLOR32, 0))) return; // create new dib - FIBITMAP *dib_ico = FIP->FI_Allocate(FIP->FI_GetWidth(dib), 16, ILC_COLOR32, 0, 0, 0); + FIBITMAP *dib_ico = FreeImage_Allocate(FreeImage_GetWidth(dib), 16, ILC_COLOR32, 0, 0, 0); if (dib_ico == nullptr) { - FIP->FI_Unload(dib); + FreeImage_Unload(dib); return; } - UINT h = FIP->FI_GetHeight(dib_ico); - UINT w = FIP->FI_GetWidth(dib_ico); - UINT t = ((h - FIP->FI_GetHeight(dib)) / 2) + 1; - UINT b = t + FIP->FI_GetHeight(dib); + UINT h = FreeImage_GetHeight(dib_ico); + UINT w = FreeImage_GetWidth(dib_ico); + UINT t = ((h - FreeImage_GetHeight(dib)) / 2) + 1; + UINT b = t + FreeImage_GetHeight(dib); // copy dib to new dib_ico (centered) - if (FIP->FI_Paste(dib_ico, dib, 0, t - 1, 255 + 1)) { - FIP->FI_Unload(dib); dib = nullptr; + if (FreeImage_Paste(dib_ico, dib, 0, t - 1, 255 + 1)) { + FreeImage_Unload(dib); dib = nullptr; // Calculate the number of bytes per pixel (3 for 24-bit or 4 for 32-bit) - int bytespp = FIP->FI_GetLine(dib_ico) / w; + int bytespp = FreeImage_GetLine(dib_ico) / w; // set alpha schannel for (unsigned y = 0; y < h; y++) { - BYTE *bits = FIP->FI_GetScanLine(dib_ico, y); + BYTE *bits = FreeImage_GetScanLine(dib_ico, y); for (unsigned x = 0; x < w; x++) { bits[FI_RGBA_ALPHA] = (y < t || y >= b) ? 0 : 255; // jump to next pixel @@ -321,13 +321,13 @@ void InitIcons() } } else { - FIP->FI_Unload(dib); - FIP->FI_Unload(dib_ico); + FreeImage_Unload(dib); + FreeImage_Unload(dib_ico); return; } - HBITMAP hScrBM = FIP->FI_CreateHBITMAPFromDIB(dib_ico); - FIP->FI_Unload(dib_ico); + HBITMAP hScrBM = FreeImage_CreateHBITMAPFromDIB(dib_ico); + FreeImage_Unload(dib_ico); if (!hScrBM) return; diff --git a/plugins/UserInfoEx/src/commonheaders.cpp b/plugins/UserInfoEx/src/commonheaders.cpp index 81851c8948..1cfa8ca83b 100644 --- a/plugins/UserInfoEx/src/commonheaders.cpp +++ b/plugins/UserInfoEx/src/commonheaders.cpp @@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // global: HINSTANCE ghInst = nullptr; -FI_INTERFACE *FIP = nullptr; //freeimage interface CLIST_INTERFACE *pcli = nullptr; MGLOBAL myGlobals; diff --git a/plugins/UserInfoEx/src/init.cpp b/plugins/UserInfoEx/src/init.cpp index 72e20d8806..74e09292cd 100644 --- a/plugins/UserInfoEx/src/init.cpp +++ b/plugins/UserInfoEx/src/init.cpp @@ -169,16 +169,6 @@ extern "C" int __declspec(dllexport) Load(void) // init clist interface pcli = Clist_GetInterface(); - // init freeimage interface - INT_PTR result = CALLSERVICE_NOTFOUND; - if (ServiceExists(MS_IMG_GETINTERFACE)) - 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. Flags module will be disabled."), L"Error", MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); - return 1; - } - if (IsWinVerVistaPlus()) { hDwmApi = LoadLibraryA("dwmapi.dll"); if (hDwmApi) diff --git a/plugins/UserInfoEx/src/stdafx.h b/plugins/UserInfoEx/src/stdafx.h index b8605c48ea..ae64b4d4b6 100644 --- a/plugins/UserInfoEx/src/stdafx.h +++ b/plugins/UserInfoEx/src/stdafx.h @@ -171,7 +171,6 @@ typedef struct _MGLOBAL extern HINSTANCE ghInst; extern MGLOBAL myGlobals; -extern FI_INTERFACE* FIP; extern int nCountriesCount; extern struct CountryListEntry *countries; -- cgit v1.2.3