summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-10-04 12:22:51 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-10-04 12:22:51 +0000
commit73c4eeff66a56dc1df1c19dd1841c77e6458f4a7 (patch)
treedc5fa75f61338ccc66749a8fd6f0b927a787ae89 /plugins
parent8b242ddc84896c59f2a53cbfe37f94b275238a7c (diff)
ancient junk removed from AVS
git-svn-id: http://svn.miranda-ng.org/main/trunk@10682 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/AVS/src/commonheaders.h1
-rw-r--r--plugins/AVS/src/image_utils.cpp120
-rw-r--r--plugins/AVS/src/image_utils.h34
-rw-r--r--plugins/AVS/src/services.cpp15
-rw-r--r--plugins/AVS/src/utils.cpp4
-rw-r--r--plugins/AVS/src/version.h2
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.cpp2
7 files changed, 41 insertions, 137 deletions
diff --git a/plugins/AVS/src/commonheaders.h b/plugins/AVS/src/commonheaders.h
index b00ce8ea1f..f483b7dac3 100644
--- a/plugins/AVS/src/commonheaders.h
+++ b/plugins/AVS/src/commonheaders.h
@@ -37,6 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_protosvc.h>
#include <m_skin.h>
#include <m_userinfo.h>
+#include <m_avatars.h>
#include <m_acc.h>
#include <m_imgsrvc.h>
#include <m_string.h>
diff --git a/plugins/AVS/src/image_utils.cpp b/plugins/AVS/src/image_utils.cpp
index 50b4c22f6a..849396a4e7 100644
--- a/plugins/AVS/src/image_utils.cpp
+++ b/plugins/AVS/src/image_utils.cpp
@@ -22,16 +22,7 @@ void MakeBmpTransparent(HBITMAP hBitmap)
free(p);
}
-// Resize /////////////////////////////////////////////////////////////////////////////////////////
-// Returns a copy of the bitmap with the size especified
-// wParam = ResizeBitmap *
-// lParam = NULL
-
-INT_PTR BmpFilterResizeBitmap(WPARAM wParam, LPARAM lParam)
-{
- // Call freeiamge service (is here only for backward compatibility)
- return CallService(MS_IMG_RESIZE, wParam, lParam);
-}
+/////////////////////////////////////////////////////////////////////////////////////////
HBITMAP CopyBitmapTo32(HBITMAP hBitmap)
{
@@ -168,12 +159,12 @@ void SetHIMETRICtoDP(HDC hdc, SIZE* sz)
sz->cy = pt.y;
}
-INT_PTR BmpFilterLoadBitmap32(WPARAM wParam, LPARAM lParam)
+HBITMAP BmpFilterLoadBitmap(BOOL *bIsTransparent, const TCHAR *ptszFilename)
{
if (fei == NULL)
return 0;
- FIBITMAP *dib = (FIBITMAP *)CallService(MS_IMG_LOAD, lParam, IMGL_RETURNDIB | IMGL_TCHAR);
+ FIBITMAP *dib = (FIBITMAP*)CallService(MS_IMG_LOAD, (WPARAM)ptszFilename, IMGL_RETURNDIB | IMGL_TCHAR);
if (dib == NULL)
return 0;
@@ -184,28 +175,25 @@ INT_PTR BmpFilterLoadBitmap32(WPARAM wParam, LPARAM lParam)
}
else dib32 = dib;
- if (dib32) {
- if (fei->FI_IsTransparent(dib32)) {
- if (wParam) {
- DWORD *dwTrans = (DWORD *)wParam;
- *dwTrans = 1;
- }
- }
- 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 (dib_new == NULL)
- return 0;
- dib32 = dib_new;
- }
+ if (dib32 == NULL)
+ return NULL;
- HBITMAP bitmap = fei->FI_CreateHBITMAPFromDIB(dib32);
+ if (fei->FI_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);
- fei->FI_CorrectBitmap32Alpha(bitmap, FALSE);
- return (INT_PTR)bitmap;
+ if (dib_new == NULL)
+ return 0;
+ dib32 = dib_new;
}
- return 0;
+
+ HBITMAP bitmap = fei->FI_CreateHBITMAPFromDIB(dib32);
+ fei->FI_Unload(dib32);
+ fei->FI_CorrectBitmap32Alpha(bitmap, FALSE);
+ return bitmap;
}
static HWND hwndClui = 0;
@@ -215,76 +203,26 @@ static HWND hwndClui = 0;
// PNG and BMP will be saved as 32bit images, jpg as 24bit with default quality (75)
// returns 1 on success, 0 on failure
-int BmpFilterSaveBitmap(HBITMAP hBmp, char *szFile, int flags)
+int BmpFilterSaveBitmap(HBITMAP hBmp, const TCHAR *ptszFile, int flags)
{
- IMGSRVC_INFO i = { 0 };
- i.cbSize = sizeof(IMGSRVC_INFO);
- i.szName = szFile;
- i.hbm = hBmp;
- i.dwMask = IMGI_HBITMAP;
- i.fif = FIF_UNKNOWN;
-
- return !CallService(MS_IMG_SAVE, (WPARAM)&i, MAKELONG(0, flags));
-}
+ if (fei == NULL)
+ return -1;
+ TCHAR tszFilename[MAX_PATH];
+ if (!PathToAbsoluteT(ptszFile, tszFilename))
+ _tcsncpy_s(tszFilename, ptszFile, _TRUNCATE);
-int BmpFilterSaveBitmapW(HBITMAP hBmp, wchar_t *wszFile, int flags)
-{
+ if (_tcslen(tszFilename) <= 4)
+ return -1;
+
IMGSRVC_INFO i = { 0 };
i.cbSize = sizeof(IMGSRVC_INFO);
- i.wszName = wszFile;
+ i.wszName = tszFilename;
i.hbm = hBmp;
i.dwMask = IMGI_HBITMAP;
i.fif = FIF_UNKNOWN;
- return !CallService(MS_IMG_SAVE, (WPARAM)&i, MAKELONG(IMGL_WCHAR, flags));
-}
-
-// Save an HBITMAP to an image
-// wParam = HBITMAP
-// lParam = filename
-INT_PTR BmpFilterSaveBitmap(WPARAM wParam, LPARAM lParam)
-{
- if (fei == NULL)
- return -1;
-
- const char *szFile = (const char*)lParam;
- char szFilename[MAX_PATH];
- if (!PathToAbsolute(szFile, szFilename))
- mir_snprintf(szFilename, SIZEOF(szFilename), "%s", szFile);
-
- int filenameLen = lstrlenA(szFilename);
- if (filenameLen > 4)
- return BmpFilterSaveBitmap((HBITMAP)wParam, szFilename, 0);
-
- return -1;
-}
-
-INT_PTR BmpFilterSaveBitmapW(WPARAM wParam, LPARAM lParam)
-{
- if (fei == NULL)
- return -1;
-
- const wchar_t *wszFile = (const wchar_t *)lParam;
- wchar_t wszFilename[MAX_PATH];
- if (!PathToAbsoluteW(wszFile, wszFilename))
- mir_sntprintf(wszFilename, SIZEOF(wszFilename), _T("%s"), wszFile);
-
- int filenameLen = lstrlenW(wszFilename);
- if (filenameLen > 4)
- return BmpFilterSaveBitmapW((HBITMAP)wParam, wszFilename, 0);
-
- return -1;
-}
-
-// Returns != 0 if can save that type of image, = 0 if cant
-// wParam = 0
-// lParam = PA_FORMAT_* // image format
-// kept for compatibilty - with freeimage we can save all common formats
-
-INT_PTR BmpFilterCanSaveBitmap(WPARAM wParam, LPARAM lParam)
-{
- return 1;
+ return !CallService(MS_IMG_SAVE, (WPARAM)&i, MAKELONG(IMGL_TCHAR, flags));
}
// Other utilities ////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/AVS/src/image_utils.h b/plugins/AVS/src/image_utils.h
index 1807e20132..e69e3b8b69 100644
--- a/plugins/AVS/src/image_utils.h
+++ b/plugins/AVS/src/image_utils.h
@@ -1,38 +1,8 @@
#ifndef __IMAGE_UTILS_H__
# define __IMAGE_UTILS_H__
-#define _WIN32_WINNT 0x0501
-#include <windows.h>
-
-#include <m_avatars.h>
-
-
-// Load an image
-// wParam = NULL
-// lParam = filename
-INT_PTR BmpFilterLoadBitmap32(WPARAM wParam,LPARAM lParam);
-
-// Save an HBITMAP to an image
-// wParam = HBITMAP
-// lParam = full path of filename
-INT_PTR BmpFilterSaveBitmap(WPARAM wParam,LPARAM lParam);
-INT_PTR BmpFilterSaveBitmapW(WPARAM wParam,LPARAM lParam);
-#define BmpFilterSaveBitmapT BmpFilterSaveBitmapW
-
-// Returns != 0 if can save that type of image, = 0 if cant
-// wParam = 0
-// lParam = PA_FORMAT_* // image format
-INT_PTR BmpFilterCanSaveBitmap(WPARAM wParam,LPARAM lParam);
-
-// Returns a copy of the bitmap with the size especified or the original bitmap if nothing has to be changed
-// wParam = ResizeBitmap *
-// lParam = NULL
-INT_PTR BmpFilterResizeBitmap(WPARAM wParam,LPARAM lParam);
-
-
-int BmpFilterSaveBitmap(HBITMAP hBmp, char *szFile, int flags);
-int BmpFilterSaveBitmapW(HBITMAP hBmp, wchar_t *wszFile, int flags);
-#define BmpFilterSaveBitmapT BmpFilterSaveBitmapW
+HBITMAP BmpFilterLoadBitmap(BOOL *bIsTransparent, const TCHAR *ptszFilename);
+int BmpFilterSaveBitmap(HBITMAP hBmp, const TCHAR *ptszFile, int flags);
HBITMAP CopyBitmapTo32(HBITMAP hBitmap);
diff --git a/plugins/AVS/src/services.cpp b/plugins/AVS/src/services.cpp
index ee1ff57b98..58f707b366 100644
--- a/plugins/AVS/src/services.cpp
+++ b/plugins/AVS/src/services.cpp
@@ -353,7 +353,7 @@ void SaveImage(SaveProtocolData &d, char *protocol, int format)
return;
mir_sntprintf(d.image_file_name, SIZEOF(d.image_file_name), _T("%s%s"), d.temp_file, ProtoGetAvatarExtension(format));
- if (BmpFilterSaveBitmapT(d.hBmpProto, d.image_file_name, format == PA_FORMAT_JPEG ? JPEG_QUALITYSUPERB : 0))
+ if (BmpFilterSaveBitmap(d.hBmpProto, d.image_file_name, format == PA_FORMAT_JPEG ? JPEG_QUALITYSUPERB : 0))
return;
if (d.max_size != 0 && GetFileSize(d.image_file_name) > d.max_size) {
@@ -361,7 +361,7 @@ void SaveImage(SaveProtocolData &d, char *protocol, int format)
if (format == PA_FORMAT_JPEG) {
// Try with lower quality
- if (!BmpFilterSaveBitmapT(d.hBmpProto, d.image_file_name, JPEG_QUALITYGOOD)) {
+ if (!BmpFilterSaveBitmap(d.hBmpProto, d.image_file_name, JPEG_QUALITYGOOD)) {
if (GetFileSize(d.image_file_name) > d.max_size) {
DeleteFile(d.image_file_name);
d.need_smaller_size = TRUE;
@@ -419,7 +419,7 @@ static int SetProtoMyAvatar(char *protocol, HBITMAP hBmp, TCHAR *originalFilenam
rb.fit = (grow ? 0 : RESIZEBITMAP_FLAG_DONT_GROW)
| (square ? RESIZEBITMAP_MAKE_SQUARE : RESIZEBITMAP_KEEP_PROPORTIONS);
- d.hBmpProto = (HBITMAP)BmpFilterResizeBitmap((WPARAM)&rb, 0);
+ d.hBmpProto = (HBITMAP)CallService(MS_IMG_RESIZE, WPARAM(&rb), 0);
if (d.hBmpProto == NULL) {
if (d.temp_file[0] != '\0')
@@ -580,7 +580,7 @@ static int InternalSetMyAvatar(char *protocol, TCHAR *szFinalName, SetMyAvatarHo
rb.fit = (data.grow ? 0 : RESIZEBITMAP_FLAG_DONT_GROW)
| (data.square ? RESIZEBITMAP_MAKE_SQUARE : RESIZEBITMAP_KEEP_PROPORTIONS);
- HBITMAP hBmpTmp = (HBITMAP)BmpFilterResizeBitmap((WPARAM)&rb, 0);
+ HBITMAP hBmpTmp = (HBITMAP)CallService(MS_IMG_RESIZE, WPARAM(&rb), 0);
// Check if need to resize
if (hBmpTmp == hBmp || hBmpTmp == NULL) {
@@ -591,7 +591,7 @@ static int InternalSetMyAvatar(char *protocol, TCHAR *szFinalName, SetMyAvatarHo
else {
// Save as PNG
mir_sntprintf(globalFile, SIZEOF(globalFile), _T("%s\\my_global_avatar.png"), globalFile);
- if (BmpFilterSaveBitmap((WPARAM)hBmpTmp, (LPARAM)globalFile))
+ if (BmpFilterSaveBitmap(hBmpTmp, globalFile, 0))
saved = FALSE;
DeleteObject(hBmpTmp);
@@ -877,9 +877,4 @@ void InitServices()
CreateServiceFunction(MS_AV_DRAWAVATAR, DrawAvatarPicture);
CreateServiceFunction(MS_AV_GETMYAVATAR, GetMyAvatar);
CreateServiceFunction(MS_AV_REPORTMYAVATARCHANGED, ReportMyAvatarChanged);
-
- CreateServiceFunction(MS_AV_LOADBITMAP32, BmpFilterLoadBitmap32);
- CreateServiceFunction(MS_AV_SAVEBITMAP, BmpFilterSaveBitmap);
- CreateServiceFunction(MS_AV_CANSAVEBITMAP, BmpFilterCanSaveBitmap);
- CreateServiceFunction(MS_AV_RESIZEBITMAP, BmpFilterResizeBitmap);
}
diff --git a/plugins/AVS/src/utils.cpp b/plugins/AVS/src/utils.cpp
index ba1f67abc2..945b11db2b 100644
--- a/plugins/AVS/src/utils.cpp
+++ b/plugins/AVS/src/utils.cpp
@@ -158,9 +158,9 @@ int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto)
return -2;
CloseHandle(hFile);
- WPARAM isTransparentImage = 0;
- ace->hbmPic = (HBITMAP)BmpFilterLoadBitmap32((WPARAM)&isTransparentImage, (LPARAM)tszFilename);
+ BOOL isTransparentImage = 0;
+ ace->hbmPic = BmpFilterLoadBitmap(&isTransparentImage, tszFilename);
ace->dwFlags = 0;
ace->bmHeight = 0;
ace->bmWidth = 0;
diff --git a/plugins/AVS/src/version.h b/plugins/AVS/src/version.h
index 77245e34bf..390bf57273 100644
--- a/plugins/AVS/src/version.h
+++ b/plugins/AVS/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 95
#define __RELEASE_NUM 3
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp
index 9ab8640666..9a1948f25d 100644
--- a/plugins/TabSRMM/src/msgdlgutils.cpp
+++ b/plugins/TabSRMM/src/msgdlgutils.cpp
@@ -303,7 +303,7 @@ int TSAPI MsgWindowUpdateMenu(TWindowData *dat, HMENU submenu, int menuID)
CheckMenuItem(visMenu, ID_VISIBILITY_VISIBLEFORTHISCONTACT, MF_BYCOMMAND | (avOverride == 1 ? MF_CHECKED : MF_UNCHECKED));
EnableMenuItem(submenu, ID_PICMENU_SETTINGS, MF_BYCOMMAND | (ServiceExists(MS_AV_GETAVATARBITMAP) ? MF_ENABLED : MF_GRAYED));
- EnableMenuItem(submenu, ID_PANELPICMENU_SAVETHISPICTUREAS, MF_BYCOMMAND | ((ServiceExists(MS_AV_SAVEBITMAP) && dat->ace && dat->ace->hbmPic && dat->ace->hbmPic != PluginConfig.g_hbmUnknown) ? MF_ENABLED : MF_GRAYED));
+ EnableMenuItem(submenu, ID_PANELPICMENU_SAVETHISPICTUREAS, MF_BYCOMMAND | ((dat->ace && dat->ace->hbmPic && dat->ace->hbmPic != PluginConfig.g_hbmUnknown) ? MF_ENABLED : MF_GRAYED));
}
return 0;
}