From 777dc2174f34c2a4d4499c3d63ef8914ed9ecb81 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 7 Mar 2018 23:38:31 +0300 Subject: old AdvaImg services converted into Image_* functions --- plugins/Toaster/src/utils.h | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'plugins/Toaster/src') diff --git a/plugins/Toaster/src/utils.h b/plugins/Toaster/src/utils.h index 2aa4802b8c..524a96730e 100644 --- a/plugins/Toaster/src/utils.h +++ b/plugins/Toaster/src/utils.h @@ -14,22 +14,19 @@ public: __inline explicit ToasterImage(HICON hIcon) : _hBitmap(NULL), tszId(CMStringW(FORMAT, L"%p", hIcon).Detach()) { ICONINFO icon = { 0 }; - if (GetIconInfo(hIcon, &icon)) - { + if (GetIconInfo(hIcon, &icon)) { _hBitmap = icon.hbmColor; DeleteObject(icon.hbmMask); } } __inline explicit ToasterImage(HBITMAP bmp) : _hBitmap(bmp), tszId(CMStringW(FORMAT, L"%p", bmp).Detach()) - { - } + {} __inline explicit ToasterImage(const char *szProto) : _hBitmap(NULL), tszId(mir_a2u(szProto)) { ICONINFO icon = { 0 }; - if (GetIconInfo(Skin_LoadProtoIcon(szProto, ID_STATUS_ONLINE, 1), &icon)) - { + if (GetIconInfo(Skin_LoadProtoIcon(szProto, ID_STATUS_ONLINE, 1), &icon)) { _hBitmap = icon.hbmColor; DeleteObject(icon.hbmMask); } @@ -45,26 +42,19 @@ public: wchar_t wszSavePath[MAX_PATH]; mir_snwprintf(wszSavePath, L"%s\\MirandaToaster.%s.png", wszTempDir, tszId); - if (!(GetFileAttributes(wszSavePath) < 0xFFFFFFF)) - { + if (!(GetFileAttributes(wszSavePath) < 0xFFFFFFF)) { IMGSRVC_INFO isi = { sizeof(isi) }; - isi.wszName = mir_wstrdup(wszSavePath); + isi.szName.w = wszSavePath; isi.hbm = _hBitmap; isi.dwMask = IMGI_HBITMAP; isi.fif = FREE_IMAGE_FORMAT::FIF_PNG; - __try - { - CallService(MS_IMG_SAVE, (WPARAM)&isi, IMGL_WCHAR); - } - __except (EXCEPTION_EXECUTE_HANDLER) - { - return nullptr; - } + Image_Save(&isi, IMGL_WCHAR); } return mir_wstrdup(wszSavePath); } __inline operator wchar_t*() - { return Save(); + { + return Save(); } -}; \ No newline at end of file +}; -- cgit v1.2.3