summaryrefslogtreecommitdiff
path: root/plugins/AVS/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/AVS/src')
-rw-r--r--plugins/AVS/src/acc.cpp83
-rw-r--r--plugins/AVS/src/image_utils.cpp38
-rw-r--r--plugins/AVS/src/main.cpp38
-rw-r--r--plugins/AVS/src/poll.cpp2
-rw-r--r--plugins/AVS/src/services.cpp12
-rw-r--r--plugins/AVS/src/stdafx.h2
-rw-r--r--plugins/AVS/src/utils.cpp4
7 files changed, 78 insertions, 101 deletions
diff --git a/plugins/AVS/src/acc.cpp b/plugins/AVS/src/acc.cpp
index 32c9eccf83..99beff22c7 100644
--- a/plugins/AVS/src/acc.cpp
+++ b/plugins/AVS/src/acc.cpp
@@ -77,32 +77,32 @@ typedef struct
BOOL AnimatedGifGetData(ACCData *data)
{
- FIBITMAP *page = fei->FI_LockPage(data->ag.multi, 0);
+ FIBITMAP *page = FreeImage_LockPage(data->ag.multi, 0);
if (page == nullptr)
return FALSE;
// Get info
FITAG *tag = nullptr;
- if (!fei->FI_GetMetadata(FIMD_ANIMATION, page, "LogicalWidth", &tag))
+ if (!FreeImage_GetMetadata(FIMD_ANIMATION, page, "LogicalWidth", &tag))
goto ERR;
- data->ag.logicalWidth = *(WORD *)fei->FI_GetTagValue(tag);
+ data->ag.logicalWidth = *(WORD *)FreeImage_GetTagValue(tag);
- if (!fei->FI_GetMetadata(FIMD_ANIMATION, page, "LogicalHeight", &tag))
+ if (!FreeImage_GetMetadata(FIMD_ANIMATION, page, "LogicalHeight", &tag))
goto ERR;
- data->ag.logicalHeight = *(WORD *)fei->FI_GetTagValue(tag);
+ data->ag.logicalHeight = *(WORD *)FreeImage_GetTagValue(tag);
- if (!fei->FI_GetMetadata(FIMD_ANIMATION, page, "Loop", &tag))
+ if (!FreeImage_GetMetadata(FIMD_ANIMATION, page, "Loop", &tag))
goto ERR;
- data->ag.loop = (*(LONG *)fei->FI_GetTagValue(tag) > 0);
+ data->ag.loop = (*(LONG *)FreeImage_GetTagValue(tag) > 0);
- if (fei->FI_HasBackgroundColor(page))
- fei->FI_GetBackgroundColor(page, &data->ag.background);
+ if (FreeImage_HasBackgroundColor(page))
+ FreeImage_GetBackgroundColor(page, &data->ag.background);
- fei->FI_UnlockPage(data->ag.multi, page, FALSE);
+ FreeImage_UnlockPage(data->ag.multi, page, FALSE);
return TRUE;
ERR:
- fei->FI_UnlockPage(data->ag.multi, page, FALSE);
+ FreeImage_UnlockPage(data->ag.multi, page, FALSE);
return FALSE;
}
@@ -113,7 +113,7 @@ void AnimatedGifDispodeFrame(ACCData *data)
}
else if (data->ag.frame.disposal_method == GIF_DISPOSAL_BACKGROUND) {
for (int y = 0; y < data->ag.frame.height; y++) {
- RGBQUAD *scanline = (RGBQUAD*)fei->FI_GetScanLine(data->ag.dib, data->ag.logicalHeight - (y + data->ag.frame.top) - 1) + data->ag.frame.left;
+ RGBQUAD *scanline = (RGBQUAD*)FreeImage_GetScanLine(data->ag.dib, data->ag.logicalHeight - (y + data->ag.frame.top) - 1) + data->ag.frame.left;
for (int x = 0; x < data->ag.frame.width; x++)
*scanline++ = data->ag.background;
}
@@ -129,41 +129,41 @@ void AnimatedGifMountFrame(ACCData* data, int page)
return;
}
- FIBITMAP *dib = fei->FI_LockPage(data->ag.multi, data->ag.frame.num);
+ FIBITMAP *dib = FreeImage_LockPage(data->ag.multi, data->ag.frame.num);
if (dib == nullptr)
return;
FITAG *tag = nullptr;
- if (fei->FI_GetMetadata(FIMD_ANIMATION, dib, "FrameLeft", &tag))
- data->ag.frame.left = *(WORD *)fei->FI_GetTagValue(tag);
+ if (FreeImage_GetMetadata(FIMD_ANIMATION, dib, "FrameLeft", &tag))
+ data->ag.frame.left = *(WORD *)FreeImage_GetTagValue(tag);
else
data->ag.frame.left = 0;
- if (fei->FI_GetMetadata(FIMD_ANIMATION, dib, "FrameTop", &tag))
- data->ag.frame.top = *(WORD *)fei->FI_GetTagValue(tag);
+ if (FreeImage_GetMetadata(FIMD_ANIMATION, dib, "FrameTop", &tag))
+ data->ag.frame.top = *(WORD *)FreeImage_GetTagValue(tag);
else
data->ag.frame.top = 0;
- if (fei->FI_GetMetadata(FIMD_ANIMATION, dib, "FrameTime", &tag))
- data->ag.times[page] = *(LONG *)fei->FI_GetTagValue(tag);
+ if (FreeImage_GetMetadata(FIMD_ANIMATION, dib, "FrameTime", &tag))
+ data->ag.times[page] = *(LONG *)FreeImage_GetTagValue(tag);
else
data->ag.times[page] = 0;
- if (fei->FI_GetMetadata(FIMD_ANIMATION, dib, "DisposalMethod", &tag))
- data->ag.frame.disposal_method = *(BYTE *)fei->FI_GetTagValue(tag);
+ if (FreeImage_GetMetadata(FIMD_ANIMATION, dib, "DisposalMethod", &tag))
+ data->ag.frame.disposal_method = *(BYTE *)FreeImage_GetTagValue(tag);
else
data->ag.frame.disposal_method = 0;
- data->ag.frame.width = fei->FI_GetWidth(dib);
- data->ag.frame.height = fei->FI_GetHeight(dib);
+ data->ag.frame.width = FreeImage_GetWidth(dib);
+ data->ag.frame.height = FreeImage_GetHeight(dib);
//decode page
- RGBQUAD *pal = fei->FI_GetPalette(dib);
+ RGBQUAD *pal = FreeImage_GetPalette(dib);
bool have_transparent = false;
int transparent_color = -1;
- if (fei->FI_IsTransparent(dib)) {
- int count = fei->FI_GetTransparencyCount(dib);
- BYTE *table = fei->FI_GetTransparencyTable(dib);
+ if (FreeImage_IsTransparent(dib)) {
+ int count = FreeImage_GetTransparencyCount(dib);
+ BYTE *table = FreeImage_GetTransparencyTable(dib);
for (int i = 0; i < count; i++) {
if (table[i] == 0) {
have_transparent = true;
@@ -175,8 +175,8 @@ void AnimatedGifMountFrame(ACCData* data, int page)
//copy page data into logical buffer, with full alpha opaqueness
for (int y = 0; y < data->ag.frame.height; y++) {
- RGBQUAD *scanline = (RGBQUAD*)fei->FI_GetScanLine(data->ag.dib, data->ag.logicalHeight - (y + data->ag.frame.top) - 1) + data->ag.frame.left;
- BYTE *pageline = fei->FI_GetScanLine(dib, data->ag.frame.height - y - 1);
+ RGBQUAD *scanline = (RGBQUAD*)FreeImage_GetScanLine(data->ag.dib, data->ag.logicalHeight - (y + data->ag.frame.top) - 1) + data->ag.frame.left;
+ BYTE *pageline = FreeImage_GetScanLine(dib, data->ag.frame.height - y - 1);
for (int x = 0; x < data->ag.frame.width; x++) {
if (!have_transparent || *pageline != transparent_color) {
*scanline = pal[*pageline];
@@ -187,20 +187,20 @@ void AnimatedGifMountFrame(ACCData* data, int page)
}
}
- data->ag.hbms[page] = fei->FI_CreateHBITMAPFromDIB(data->ag.dib);
+ data->ag.hbms[page] = FreeImage_CreateHBITMAPFromDIB(data->ag.dib);
- fei->FI_UnlockPage(data->ag.multi, dib, FALSE);
+ FreeImage_UnlockPage(data->ag.multi, dib, FALSE);
}
void AnimatedGifDeleteTmpValues(ACCData* data)
{
if (data->ag.multi != nullptr) {
- fei->FI_CloseMultiBitmap(data->ag.multi, 0);
+ FreeImage_CloseMultiBitmap(data->ag.multi, 0);
data->ag.multi = nullptr;
}
if (data->ag.dib != nullptr) {
- fei->FI_Unload(data->ag.dib);
+ FreeImage_Unload(data->ag.dib);
data->ag.dib = nullptr;
}
}
@@ -232,9 +232,6 @@ void DestroyAnimatedGif(ACCData* data)
void StartAnimatedGif(ACCData* data)
{
- if (fei == nullptr)
- return;
-
AVATARCACHEENTRY *ace = nullptr;
if (data->hContact != NULL)
ace = (AVATARCACHEENTRY*)GetAvatarBitmap(data->hContact, 0);
@@ -248,15 +245,15 @@ void StartAnimatedGif(ACCData* data)
if (format != PA_FORMAT_GIF)
return;
- FREE_IMAGE_FORMAT fif = fei->FI_GetFileTypeU(ace->szFilename, 0);
+ FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeU(ace->szFilename, 0);
if (fif == FIF_UNKNOWN)
- fif = fei->FI_GetFIFFromFilenameU(ace->szFilename);
+ fif = FreeImage_GetFIFFromFilenameU(ace->szFilename);
- data->ag.multi = fei->FI_OpenMultiBitmapU(fif, ace->szFilename, FALSE, TRUE, FALSE, GIF_LOAD256);
+ data->ag.multi = FreeImage_OpenMultiBitmapU(fif, ace->szFilename, FALSE, TRUE, FALSE, GIF_LOAD256);
if (data->ag.multi == nullptr)
return;
- data->ag.frameCount = fei->FI_GetPageCount(data->ag.multi);
+ data->ag.frameCount = FreeImage_GetPageCount(data->ag.multi);
if (data->ag.frameCount <= 1)
goto ERR;
@@ -264,13 +261,13 @@ void StartAnimatedGif(ACCData* data)
goto ERR;
// allocate entire logical area
- data->ag.dib = fei->FI_Allocate(data->ag.logicalWidth, data->ag.logicalHeight, 32, 0, 0, 0);
+ data->ag.dib = FreeImage_Allocate(data->ag.logicalWidth, data->ag.logicalHeight, 32, 0, 0, 0);
if (data->ag.dib == nullptr)
goto ERR;
// fill with background color to start
for (int y = 0; y < data->ag.logicalHeight; y++) {
- RGBQUAD *scanline = (RGBQUAD*)fei->FI_GetScanLine(data->ag.dib, y);
+ RGBQUAD *scanline = (RGBQUAD*)FreeImage_GetScanLine(data->ag.dib, y);
for (int x = 0; x < data->ag.logicalWidth; x++)
*scanline++ = data->ag.background;
}
@@ -287,7 +284,7 @@ void StartAnimatedGif(ACCData* data)
return;
ERR:
- fei->FI_CloseMultiBitmap(data->ag.multi, 0);
+ FreeImage_CloseMultiBitmap(data->ag.multi, 0);
data->ag.multi = nullptr;
}
diff --git a/plugins/AVS/src/image_utils.cpp b/plugins/AVS/src/image_utils.cpp
index 020b618285..0e2107f87b 100644
--- a/plugins/AVS/src/image_utils.cpp
+++ b/plugins/AVS/src/image_utils.cpp
@@ -62,7 +62,7 @@ HBITMAP CopyBitmapTo32(HBITMAP hBitmap)
DeleteObject(hdcOrig);
// Set alpha
- fei->FI_CorrectBitmap32Alpha(hDirectBitmap, FALSE);
+ FreeImage_CorrectBitmap32Alpha(hDirectBitmap, FALSE);
}
else {
GetBitmapBits(hBitmap, dwLen, p);
@@ -161,38 +161,35 @@ void SetHIMETRICtoDP(HDC hdc, SIZE* sz)
HBITMAP BmpFilterLoadBitmap(BOOL *bIsTransparent, const wchar_t *ptszFilename)
{
- if (fei == nullptr)
- return nullptr;
-
FIBITMAP *dib = (FIBITMAP*)CallService(MS_IMG_LOAD, (WPARAM)ptszFilename, IMGL_RETURNDIB | IMGL_WCHAR);
if (dib == nullptr)
return nullptr;
FIBITMAP *dib32 = nullptr;
- if (fei->FI_GetBPP(dib) != 32) {
- dib32 = fei->FI_ConvertTo32Bits(dib);
- fei->FI_Unload(dib);
+ if (FreeImage_GetBPP(dib) != 32) {
+ dib32 = FreeImage_ConvertTo32Bits(dib);
+ FreeImage_Unload(dib);
}
else dib32 = dib;
if (dib32 == nullptr)
return nullptr;
- if (fei->FI_IsTransparent(dib32))
+ if (FreeImage_IsTransparent(dib32))
if (bIsTransparent)
*bIsTransparent = TRUE;
- if (fei->FI_GetWidth(dib32) > 128 || fei->FI_GetHeight(dib32) > 128) {
- FIBITMAP *dib_new = fei->FI_MakeThumbnail(dib32, 128, FALSE);
- fei->FI_Unload(dib32);
+ if (FreeImage_GetWidth(dib32) > 128 || FreeImage_GetHeight(dib32) > 128) {
+ FIBITMAP *dib_new = FreeImage_MakeThumbnail(dib32, 128, FALSE);
+ FreeImage_Unload(dib32);
if (dib_new == nullptr)
return nullptr;
dib32 = dib_new;
}
- HBITMAP bitmap = fei->FI_CreateHBITMAPFromDIB(dib32);
- fei->FI_Unload(dib32);
- fei->FI_CorrectBitmap32Alpha(bitmap, FALSE);
+ HBITMAP bitmap = FreeImage_CreateHBITMAPFromDIB(dib32);
+ FreeImage_Unload(dib32);
+ FreeImage_CorrectBitmap32Alpha(bitmap, FALSE);
return bitmap;
}
@@ -205,9 +202,6 @@ static HWND hwndClui = nullptr;
int BmpFilterSaveBitmap(HBITMAP hBmp, const wchar_t *ptszFile, int flags)
{
- if (fei == nullptr)
- return -1;
-
wchar_t tszFilename[MAX_PATH];
if (!PathToAbsoluteW(ptszFile, tszFilename))
wcsncpy_s(tszFilename, ptszFile, _TRUNCATE);
@@ -299,14 +293,14 @@ DWORD GetImgHash(HBITMAP hBitmap)
HBITMAP MakeGrayscale(HBITMAP hBitmap)
{
if (hBitmap) {
- FIBITMAP *dib = fei->FI_CreateDIBFromHBITMAP(hBitmap);
+ FIBITMAP *dib = FreeImage_CreateDIBFromHBITMAP(hBitmap);
if (dib) {
- FIBITMAP *dib_new = fei->FI_ConvertToGreyscale(dib);
- fei->FI_Unload(dib);
+ FIBITMAP *dib_new = FreeImage_ConvertToGreyscale(dib);
+ FreeImage_Unload(dib);
if (dib_new) {
DeleteObject(hBitmap);
- HBITMAP hbm_new = fei->FI_CreateHBITMAPFromDIB(dib_new);
- fei->FI_Unload(dib_new);
+ HBITMAP hbm_new = FreeImage_CreateHBITMAPFromDIB(dib_new);
+ FreeImage_Unload(dib_new);
return hbm_new;
}
}
diff --git a/plugins/AVS/src/main.cpp b/plugins/AVS/src/main.cpp
index 802396eb9d..774b5c5218 100644
--- a/plugins/AVS/src/main.cpp
+++ b/plugins/AVS/src/main.cpp
@@ -63,8 +63,6 @@ char *g_szMetaName = nullptr;
int OnDetailsInit(WPARAM wParam, LPARAM lParam);
int OptInit(WPARAM wParam, LPARAM lParam);
-FI_INTERFACE *fei = nullptr;
-
PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -283,11 +281,11 @@ void InternalDrawAvatar(AVATARDRAWREQUEST *r, HBITMAP hbm, LONG bmWidth, LONG bm
StretchBlt(r->hTargetDC, r->rcDraw.left + leftoffset, r->rcDraw.top + topoffset, newWidth, newHeight, hdcAvatar, 0, 0, bmWidth, bmHeight, SRCCOPY);
else {
// get around SUCKY AlphaBlend() rescaling quality...
- FIBITMAP *fb = fei->FI_CreateDIBFromHBITMAP(hbm);
- FIBITMAP *fbResized = fei->FI_Rescale(fb, newWidth, newHeight, FILTER_BICUBIC);
- HBITMAP hbmResized = fei->FI_CreateHBITMAPFromDIB(fbResized);
- fei->FI_Unload(fb);
- fei->FI_Unload(fbResized);
+ FIBITMAP *fb = FreeImage_CreateDIBFromHBITMAP(hbm);
+ FIBITMAP *fbResized = FreeImage_Rescale(fb, newWidth, newHeight, FILTER_BICUBIC);
+ HBITMAP hbmResized = FreeImage_CreateHBITMAPFromDIB(fbResized);
+ FreeImage_Unload(fb);
+ FreeImage_Unload(fbResized);
HBITMAP hbmTempOld;
HDC hdcTemp = CreateCompatibleDC(r->hTargetDC);
@@ -337,17 +335,15 @@ static int ModulesLoaded(WPARAM, LPARAM)
PROTOACCOUNT **accs = nullptr;
Proto_EnumAccounts(&accCount, &accs);
- if (fei != nullptr) {
- LoadDefaultInfo();
+ LoadDefaultInfo();
- int protoCount;
- PROTOCOLDESCRIPTOR **proto;
- Proto_EnumProtocols(&protoCount, &proto);
- for (int i = 0; i < protoCount; i++)
- LoadProtoInfo(proto[i]);
- for (int i = 0; i < accCount; i++)
- LoadAccountInfo(accs[i]);
- }
+ int protoCount;
+ PROTOCOLDESCRIPTOR **proto;
+ Proto_EnumProtocols(&protoCount, &proto);
+ for (int i = 0; i < protoCount; i++)
+ LoadProtoInfo(proto[i]);
+ for (int i = 0; i < accCount; i++)
+ LoadAccountInfo(accs[i]);
// Load global avatar
protoPicCacheEntry *pce = new protoPicCacheEntry;
@@ -401,14 +397,6 @@ extern "C" int __declspec(dllexport) Load(void)
mir_getLP(&pluginInfoEx);
pcli = Clist_GetInterface();
- 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 1;
- }
LoadACC();
return LoadAvatarModule();
}
diff --git a/plugins/AVS/src/poll.cpp b/plugins/AVS/src/poll.cpp
index 3a2a091e3b..1c567c815b 100644
--- a/plugins/AVS/src/poll.cpp
+++ b/plugins/AVS/src/poll.cpp
@@ -114,7 +114,7 @@ static void QueueRemove(MCONTACT hContact)
// Add an contact to a queue
void QueueAdd(MCONTACT hContact, int waitTime)
{
- if (fei == nullptr || g_shutDown)
+ if (g_shutDown)
return;
mir_cslock lck(cs);
diff --git a/plugins/AVS/src/services.cpp b/plugins/AVS/src/services.cpp
index 1e0b389369..1ac14d16dc 100644
--- a/plugins/AVS/src/services.cpp
+++ b/plugins/AVS/src/services.cpp
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
INT_PTR GetAvatarBitmap(WPARAM hContact, LPARAM)
{
- if (hContact == 0 || g_shutDown || fei == nullptr)
+ if (hContact == 0 || g_shutDown)
return 0;
hContact = GetContactThatHaveTheAvatar(hContact);
@@ -46,7 +46,7 @@ INT_PTR ProtectAvatar(WPARAM hContact, LPARAM lParam)
{
BYTE was_locked = db_get_b(hContact, "ContactPhoto", "Locked", 0);
- if (fei == nullptr || was_locked == (BYTE)lParam) // no need for redundant lockings...
+ if (was_locked == (BYTE)lParam) // no need for redundant lockings...
return 0;
if (hContact) {
@@ -121,7 +121,7 @@ INT_PTR SetAvatar(WPARAM hContact, LPARAM lParam)
wchar_t *szFinalName;
BYTE locking_request;
- if (hContact == NULL || fei == nullptr)
+ if (hContact == NULL)
return 0;
int is_locked = db_get_b(hContact, "ContactPhoto", "Locked", 0);
@@ -179,7 +179,7 @@ INT_PTR SetAvatar(WPARAM hContact, LPARAM lParam)
static INT_PTR CanSetMyAvatar(WPARAM wParam, LPARAM)
{
char *protocol = (char *)wParam;
- if (protocol == nullptr || fei == nullptr)
+ if (protocol == nullptr)
return 0;
return ProtoServiceExists(protocol, PS_SETMYAVATAR);
@@ -718,7 +718,7 @@ INT_PTR DrawAvatarPicture(WPARAM, LPARAM lParam)
AVATARCACHEENTRY *ace = nullptr;
AVATARDRAWREQUEST *r = (AVATARDRAWREQUEST*)lParam;
- if (fei == nullptr || r == nullptr || IsBadReadPtr((void *)r, sizeof(AVATARDRAWREQUEST)))
+ if (r == nullptr || IsBadReadPtr((void *)r, sizeof(AVATARDRAWREQUEST)))
return 0;
if (r->cbSize != sizeof(AVATARDRAWREQUEST))
@@ -764,7 +764,7 @@ INT_PTR DrawAvatarPicture(WPARAM, LPARAM lParam)
INT_PTR GetMyAvatar(WPARAM wParam, LPARAM lParam)
{
- if (wParam || g_shutDown || fei == nullptr)
+ if (wParam || g_shutDown)
return 0;
char *szProto = (char *)lParam;
diff --git a/plugins/AVS/src/stdafx.h b/plugins/AVS/src/stdafx.h
index bdcd322ad6..d055b0f886 100644
--- a/plugins/AVS/src/stdafx.h
+++ b/plugins/AVS/src/stdafx.h
@@ -99,8 +99,6 @@ struct SetMyAvatarHookData
BOOL thumbnail;
};
-extern FI_INTERFACE *fei;
-
#define GAIR_FAILED 1000
#define AVS_IGNORENOTIFY 0x1000
diff --git a/plugins/AVS/src/utils.cpp b/plugins/AVS/src/utils.cpp
index 1aa82f4515..bb794dd84d 100644
--- a/plugins/AVS/src/utils.cpp
+++ b/plugins/AVS/src/utils.cpp
@@ -202,12 +202,12 @@ int CreateAvatarInCache(MCONTACT hContact, AVATARCACHEENTRY *ace, char *szProto)
ace->hbmPic = MakeGrayscale(ace->hbmPic);
if (noTransparency) {
- fei->FI_CorrectBitmap32Alpha(ace->hbmPic, TRUE);
+ FreeImage_CorrectBitmap32Alpha(ace->hbmPic, TRUE);
isTransparentImage = FALSE;
}
if (bminfo.bmBitsPixel == 32 && isTransparentImage) {
- if (fei->FI_Premultiply(ace->hbmPic))
+ if (FreeImage_Premultiply(ace->hbmPic))
ace->dwFlags |= AVS_HASTRANSPARENCY;
ace->dwFlags |= AVS_PREMULTIPLIED;