summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-04-11 18:58:18 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-04-11 18:58:18 +0300
commitcaf9d58899a7d059de9ebdfa7f7ee65177d265dc (patch)
tree370b9e919d92d17e44f2ed808db348c0c53422ba /plugins/TabSRMM/src
parent22977408e43caa45687e0c9d5a003b800700bea9 (diff)
TabSRMM:
- one shall not mix width & height; - CSkin::ResizeBitmap became completely useless after linking FreeImage in
Diffstat (limited to 'plugins/TabSRMM/src')
-rw-r--r--plugins/TabSRMM/src/sidebar.cpp3
-rw-r--r--plugins/TabSRMM/src/taskbar.cpp5
-rw-r--r--plugins/TabSRMM/src/themes.cpp40
-rw-r--r--plugins/TabSRMM/src/themes.h35
-rw-r--r--plugins/TabSRMM/src/utils.cpp3
5 files changed, 27 insertions, 59 deletions
diff --git a/plugins/TabSRMM/src/sidebar.cpp b/plugins/TabSRMM/src/sidebar.cpp
index 9dd8649657..5edaaf8bbd 100644
--- a/plugins/TabSRMM/src/sidebar.cpp
+++ b/plugins/TabSRMM/src/sidebar.cpp
@@ -1063,11 +1063,10 @@ void __fastcall CSideBar::m_AdvancedContentRenderer(const HDC hdc, const RECT *r
if (dat->m_ace && dat->m_ace->hbmPic) { // we have an avatar
double dNewHeight, dNewWidth;
LONG maxHeight = cy - 8;
- bool fFree = false;
Utils::scaleAvatarHeightLimited(dat->m_ace->hbmPic, dNewWidth, dNewHeight, maxHeight);
- HBITMAP hbmResized = CSkin::ResizeBitmap(dat->m_ace->hbmPic, dNewWidth, dNewHeight, fFree);
+ HBITMAP hbmResized = ::Image_Resize(dat->m_ace->hbmPic, RESIZEBITMAP_STRETCH, dNewWidth, dNewHeight);
HDC dc = CreateCompatibleDC(hdc);
HBITMAP hbmOld = reinterpret_cast<HBITMAP>(::SelectObject(dc, hbmResized));
diff --git a/plugins/TabSRMM/src/taskbar.cpp b/plugins/TabSRMM/src/taskbar.cpp
index 8db16253aa..20fe504dfc 100644
--- a/plugins/TabSRMM/src/taskbar.cpp
+++ b/plugins/TabSRMM/src/taskbar.cpp
@@ -748,12 +748,11 @@ void CThumbIM::update()
void CThumbIM::renderContent()
{
double dNewWidth = 0.0, dNewHeight = 0.0;
- bool fFree = false;
HBITMAP hbmAvatar = (m_dat->m_ace && m_dat->m_ace->hbmPic) ? m_dat->m_ace->hbmPic : PluginConfig.g_hbmUnknown;
Utils::scaleAvatarHeightLimited(hbmAvatar, dNewWidth, dNewHeight, m_rcIcon.bottom - m_rcIcon.top);
- HBITMAP hbmResized = CSkin::ResizeBitmap(hbmAvatar, dNewWidth, dNewHeight, fFree);
+ HBITMAP hbmResized = ::Image_Resize(hbmAvatar, RESIZEBITMAP_STRETCH, dNewWidth, dNewHeight);
HDC dc = CreateCompatibleDC(m_hdc);
HBITMAP hbmOldAv = reinterpret_cast<HBITMAP>(::SelectObject(dc, hbmResized));
@@ -773,7 +772,7 @@ void CThumbIM::renderContent()
if (hbmResized != hbmAvatar)
::DeleteObject(hbmResized);
- ::DeleteDC(dc);
+ ::DeleteDC(dc);
m_rcBottom.bottom -= 16;
/*
diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp
index 4791b19699..0031803d07 100644
--- a/plugins/TabSRMM/src/themes.cpp
+++ b/plugins/TabSRMM/src/themes.cpp
@@ -1590,7 +1590,6 @@ void CSkin::setupTabCloseBitmap(bool fDeleteOnly)
return;
}
- bool fFree = false;
RECT rc = { 0, 0, 20, 20 };
HDC dc = ::GetDC(PluginConfig.g_hwndHotkeyHandler);
m_tabCloseHDC = ::CreateCompatibleDC(dc);
@@ -1621,9 +1620,12 @@ void CSkin::setupTabCloseBitmap(bool fDeleteOnly)
::DrawIconEx(m_tabCloseHDC, 2, 2, PluginConfig.g_buttonBarIcons[ICON_BUTTON_CANCEL], 16, 16, 0, nullptr, DI_NORMAL);
::SelectObject(m_tabCloseHDC, m_tabCloseOldBitmap);
- HBITMAP hbmTemp = ResizeBitmap(m_tabCloseBitmap, 16, 16, fFree);
- ::DeleteObject(m_tabCloseBitmap);
- m_tabCloseBitmap = hbmTemp;
+ HBITMAP hbmTemp = ::Image_Resize(m_tabCloseBitmap, RESIZEBITMAP_STRETCH, 16, 16);
+ if (hbmTemp != m_tabCloseBitmap) {
+ ::DeleteObject(m_tabCloseBitmap);
+ m_tabCloseBitmap = hbmTemp;
+ }
+
CImageItem::PreMultiply(m_tabCloseBitmap, 1);
m_tabCloseOldBitmap = reinterpret_cast<HBITMAP>(::SelectObject(m_tabCloseHDC, m_tabCloseBitmap));
@@ -2060,36 +2062,6 @@ int CSkin::RenderText(HDC hdc, HANDLE hTheme, const wchar_t *szText, RECT *rc, D
}
/////////////////////////////////////////////////////////////////////////////////////////
-// Resize a bitmap using image service. The function does not care about the image aspect ratio.
-// The caller is responsible to submit proper values for the desired height and width.
-//
-// @param hBmpSrc HBITMAP: the source bitmap
-// @param width LONG: width of the destination bitmap
-// @param height LONG: height of the new bitmap
-// @param mustFree bool: indicates that the new bitmap had been
-//resized and either the source or destination
-//bitmap should be freed.
-//
-// @return HBTIAMP: handle to a bitmap with the desired size.
-
-HBITMAP CSkin::ResizeBitmap(HBITMAP hBmpSrc, LONG width, LONG height, bool &mustFree)
-{
- BITMAP bm;
-
- GetObject(hBmpSrc, sizeof(bm), &bm);
- if (bm.bmHeight != height || bm.bmWidth != width) {
- HBITMAP hbmNew = Image_Resize(hBmpSrc, RESIZEBITMAP_STRETCH, height, width);
- if (hbmNew != hBmpSrc)
- mustFree = true;
- return(hbmNew);
- }
- else {
- mustFree = false;
- return(hBmpSrc);
- }
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
// Draw the given skin item to the target rectangle and dc
//
// @param hdc HDC: device context
diff --git a/plugins/TabSRMM/src/themes.h b/plugins/TabSRMM/src/themes.h
index a626a1936a..5695081a3f 100644
--- a/plugins/TabSRMM/src/themes.h
+++ b/plugins/TabSRMM/src/themes.h
@@ -366,24 +366,23 @@ public:
/*
* static member functions
*/
- static void TSAPI SkinDrawBGFromDC(HWND hwndClient, HWND hwnd, RECT *rcClient, HDC hdcTarget);
- static void TSAPI SkinDrawBG(HWND hwndClient, HWND hwnd, TContainerData *pContainer, RECT *rcClient, HDC hdcTarget);
- static void TSAPI DrawDimmedIcon(HDC hdc, LONG left, LONG top, LONG dx, LONG dy, HICON hIcon, BYTE alpha);
- static DWORD __fastcall HexStringToLong(const wchar_t *szSource);
- static UINT TSAPI DrawRichEditFrame(HWND hwnd, const CTabBaseDlg *mwdat, UINT skinID, UINT msg, WPARAM wParam, LPARAM lParam, WNDPROC OldWndProc);
- static UINT TSAPI NcCalcRichEditFrame(HWND hwnd, const CTabBaseDlg *mwdat, UINT skinID, UINT msg, WPARAM wParam, LPARAM lParam, WNDPROC OldWndProc);
- static HBITMAP TSAPI CreateAeroCompatibleBitmap(const RECT &rc, HDC dc);
- static int TSAPI RenderText(HDC hdc, HANDLE hTheme, const wchar_t *szText, RECT *rc, DWORD dtFlags, const int iGlowSize = DEFAULT_GLOW_SIZE, COLORREF clr = 0, bool fForceAero = false);
- static void TSAPI MapClientToParent(HWND hwndClient, HWND hwndParent, RECT &rc);
- static HBITMAP TSAPI ResizeBitmap(HBITMAP hBmpSrc, LONG width, LONG height, bool &mustFree);
- static void TSAPI ApplyAeroEffect(const HDC hdc, const RECT* rc, int iEffectArea);
- static void TSAPI setAeroEffect(const LRESULT effect);
- static void TSAPI initAeroEffect();
- static HANDLE TSAPI InitiateBufferedPaint(const HDC hdcSrc, RECT& rc, HDC& hdcOut);
- static void TSAPI FinalizeBufferedPaint(HANDLE hbp, RECT *rc);
- static bool __fastcall DrawItem(const HDC hdc, const RECT *rc, const CSkinItem *item);
- static void TSAPI FillBack(const HDC hdc, RECT* rc);
- static bool TSAPI IsThemed(void);
+ static void TSAPI SkinDrawBGFromDC(HWND hwndClient, HWND hwnd, RECT *rcClient, HDC hdcTarget);
+ static void TSAPI SkinDrawBG(HWND hwndClient, HWND hwnd, TContainerData *pContainer, RECT *rcClient, HDC hdcTarget);
+ static void TSAPI DrawDimmedIcon(HDC hdc, LONG left, LONG top, LONG dx, LONG dy, HICON hIcon, BYTE alpha);
+ static DWORD TSAPI HexStringToLong(const wchar_t *szSource);
+ static UINT TSAPI DrawRichEditFrame(HWND hwnd, const CTabBaseDlg *mwdat, UINT skinID, UINT msg, WPARAM wParam, LPARAM lParam, WNDPROC OldWndProc);
+ static UINT TSAPI NcCalcRichEditFrame(HWND hwnd, const CTabBaseDlg *mwdat, UINT skinID, UINT msg, WPARAM wParam, LPARAM lParam, WNDPROC OldWndProc);
+ static HBITMAP TSAPI CreateAeroCompatibleBitmap(const RECT &rc, HDC dc);
+ static int TSAPI RenderText(HDC hdc, HANDLE hTheme, const wchar_t *szText, RECT *rc, DWORD dtFlags, const int iGlowSize = DEFAULT_GLOW_SIZE, COLORREF clr = 0, bool fForceAero = false);
+ static void TSAPI MapClientToParent(HWND hwndClient, HWND hwndParent, RECT &rc);
+ static void TSAPI ApplyAeroEffect(const HDC hdc, const RECT* rc, int iEffectArea);
+ static void TSAPI setAeroEffect(const LRESULT effect);
+ static void TSAPI initAeroEffect();
+ static HANDLE TSAPI InitiateBufferedPaint(const HDC hdcSrc, RECT& rc, HDC& hdcOut);
+ static void TSAPI FinalizeBufferedPaint(HANDLE hbp, RECT *rc);
+ static bool TSAPI DrawItem(const HDC hdc, const RECT *rc, const CSkinItem *item);
+ static void TSAPI FillBack(const HDC hdc, RECT* rc);
+ static bool TSAPI IsThemed(void);
public:
static bool m_DisableScrollbars, m_bClipBorder;
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp
index bf8ce4e585..8956becb97 100644
--- a/plugins/TabSRMM/src/utils.cpp
+++ b/plugins/TabSRMM/src/utils.cpp
@@ -657,8 +657,7 @@ HICON CTabBaseDlg::IconFromAvatar() const
// resize picture to fit it on the task bar, use an image list for converting it to
// 32bpp icon format. hTaskbarIcon will cache it until avatar is changed
- bool fFree = false;
- HBITMAP hbmResized = CSkin::ResizeBitmap(ace->hbmPic, (LONG)dNewWidth, (LONG)dNewHeight, fFree);
+ HBITMAP hbmResized = ::Image_Resize(ace->hbmPic, RESIZEBITMAP_STRETCH, dNewWidth, dNewHeight);
HIMAGELIST hIml_c = ::ImageList_Create(lIconSize, lIconSize, ILC_COLOR32 | ILC_MASK, 1, 0);
RECT rc = { 0, 0, lIconSize, lIconSize };