From 612fc2f36903f0168f88622f61e1a0de4dae5b92 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 1 Jun 2015 22:15:26 +0000 Subject: - atavism named MS_UTILS_LOADBITMAP removed; - bmpfilter.cpp also removed; - Bitmap_Load() function added instead; - various bitmap related crap fixed; git-svn-id: http://svn.miranda-ng.org/main/trunk@13966 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/stdclist/src/clcopts.cpp | 2 +- src/mir_core/src/bitmaps.cpp | 16 ++++- src/mir_core/src/mir_core.def | 5 +- src/mir_core/src/mir_core64.def | 5 +- src/miranda32_10.vcxproj | 3 - src/miranda32_10.vcxproj.filters | 3 - src/miranda32_12.vcxproj | 3 - src/miranda32_12.vcxproj.filters | 3 - src/modules/clist/clcutils.cpp | 2 +- src/modules/utils/bmpfilter.cpp | 146 -------------------------------------- src/modules/utils/utils.cpp | 2 - 11 files changed, 23 insertions(+), 167 deletions(-) delete mode 100644 src/modules/utils/bmpfilter.cpp (limited to 'src') diff --git a/src/core/stdclist/src/clcopts.cpp b/src/core/stdclist/src/clcopts.cpp index 2350d7d947..bbd013a7af 100644 --- a/src/core/stdclist/src/clcopts.cpp +++ b/src/core/stdclist/src/clcopts.cpp @@ -341,7 +341,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; ofn.hInstance = NULL; - BmpFilterGetStrings(filter, SIZEOF(filter)); + Bitmap_GetFilter(filter, SIZEOF(filter)); ofn.lpstrFilter = filter; ofn.lpstrFile = str; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; diff --git a/src/mir_core/src/bitmaps.cpp b/src/mir_core/src/bitmaps.cpp index 6393e4605b..8223a912b6 100644 --- a/src/mir_core/src/bitmaps.cpp +++ b/src/mir_core/src/bitmaps.cpp @@ -23,7 +23,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h" -MIR_CORE_DLL(void) BmpFilterGetStrings(TCHAR *dest, size_t destLen) +#include + +MIR_CORE_DLL(HBITMAP) Bitmap_Load(const TCHAR *ptszFileName) +{ + TCHAR szFilename[MAX_PATH]; + if (!PathToAbsoluteT(ptszFileName, szFilename)) + _tcsncpy_s(szFilename, ptszFileName, _TRUNCATE); + + if (!ServiceExists(MS_IMG_LOAD)) + return NULL; + + return (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)szFilename, IMGL_TCHAR); +} + +MIR_CORE_DLL(void) Bitmap_GetFilter(TCHAR *dest, size_t destLen) { if (dest == NULL) return; diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 82bbf9bb2a..07605d05dd 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1237,5 +1237,6 @@ Proto_RegisterModule @1074 NONAME ?isnull@JSONNode@@QBE_NXZ @1245 NONAME ??BJSONNode@@QBE_NXZ @1246 NONAME ?as_mstring@JSONNode@@QBE?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@XZ @1247 NONAME -BmpFilterGetStrings @1248 -CreateProtoServiceFunction @1249 +Bitmap_GetFilter @1248 +Bitmap_Load @1249 +CreateProtoServiceFunction @1250 diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index fb910e5329..5622d57702 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1237,5 +1237,6 @@ Proto_RegisterModule @1074 NONAME ?isnull@JSONNode@@QEBA_NXZ @1245 NONAME ??BJSONNode@@QEBA_NXZ @1246 NONAME ?as_mstring@JSONNode@@QEBA?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@XZ @1247 NONAME -BmpFilterGetStrings @1248 -CreateProtoServiceFunction @1249 +Bitmap_GetFilter @1248 +Bitmap_Load @1249 +CreateProtoServiceFunction @1250 diff --git a/src/miranda32_10.vcxproj b/src/miranda32_10.vcxproj index b8d1380851..157ff16114 100644 --- a/src/miranda32_10.vcxproj +++ b/src/miranda32_10.vcxproj @@ -501,9 +501,6 @@ ..\..\core\commonheaders.h - - ..\..\core\commonheaders.h - ..\..\core\commonheaders.h diff --git a/src/miranda32_10.vcxproj.filters b/src/miranda32_10.vcxproj.filters index 77e3bceb7a..1cf2c4f08f 100644 --- a/src/miranda32_10.vcxproj.filters +++ b/src/miranda32_10.vcxproj.filters @@ -390,9 +390,6 @@ Modules\skin - - Modules\utils - Modules\utils diff --git a/src/miranda32_12.vcxproj b/src/miranda32_12.vcxproj index 9e48fc9bfa..7d514d96d8 100644 --- a/src/miranda32_12.vcxproj +++ b/src/miranda32_12.vcxproj @@ -511,9 +511,6 @@ ..\..\core\commonheaders.h - - ..\..\core\commonheaders.h - ..\..\core\commonheaders.h diff --git a/src/miranda32_12.vcxproj.filters b/src/miranda32_12.vcxproj.filters index 3b97d6911c..9eaad6e492 100644 --- a/src/miranda32_12.vcxproj.filters +++ b/src/miranda32_12.vcxproj.filters @@ -396,9 +396,6 @@ Modules\skin - - Modules\utils - Modules\utils diff --git a/src/modules/clist/clcutils.cpp b/src/modules/clist/clcutils.cpp index 246c3ab893..1eddd43662 100644 --- a/src/modules/clist/clcutils.cpp +++ b/src/modules/clist/clcutils.cpp @@ -763,7 +763,7 @@ void fnLoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst) if (db_get_b(NULL, "CLC", "UseBitmap", CLCDEFAULT_USEBITMAP)) { ptrT tszBitmap(db_get_tsa(NULL, "CLC", "BkBitmap")); if (tszBitmap) - dat->hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAPT, 0, tszBitmap); + dat->hBmpBackground = Bitmap_Load(tszBitmap); } dat->backgroundBmpUse = db_get_w(NULL, "CLC", "BkBmpUse", CLCDEFAULT_BKBMPUSE); } diff --git a/src/modules/utils/bmpfilter.cpp b/src/modules/utils/bmpfilter.cpp deleted file mode 100644 index cd9d061e20..0000000000 --- a/src/modules/utils/bmpfilter.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "..\..\core\commonheaders.h" -#include - -#include "m_png.h" -#include "m_imgsrvc.h" - -static INT_PTR sttBitmapLoader(const TCHAR* ptszFileName) -{ - IPicture *pic; - HBITMAP hBmp, hBmpCopy; - HBITMAP hOldBitmap, hOldBitmap2; - BITMAP bmpInfo; - HDC hdc, hdcMem1, hdcMem2; - short picType; - - TCHAR szFilename[MAX_PATH]; - if (!PathToAbsoluteT(ptszFileName, szFilename)) - _tcsncpy_s(szFilename, ptszFileName, _TRUNCATE); - - size_t filenameLen = mir_tstrlen(szFilename); - if (filenameLen > 4) { - TCHAR* pszExt = szFilename + filenameLen - 4; - - if (ServiceExists(MS_IMG_LOAD)) - return CallService(MS_IMG_LOAD, (WPARAM)szFilename, IMGL_TCHAR); - - if (!mir_tstrcmpi(pszExt, _T(".bmp")) || !mir_tstrcmpi(pszExt, _T(".rle"))) { - //LoadImage can do this much faster - return (INT_PTR)LoadImage(hInst, szFilename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); - } - - if (!mir_tstrcmpi(pszExt, _T(".png"))) { - HANDLE hFile, hMap = NULL; - BYTE* ppMap = NULL; - INT_PTR cbFileSize = 0; - BITMAPINFOHEADER* pDib; - BYTE* pDibBits; - - if (!ServiceExists(MS_PNG2DIB)) { - MessageBox(NULL, TranslateT("You need an image services plugin to process PNG images."), TranslateT("Error"), MB_OK); - return 0; - } - - if ((hFile = CreateFile(szFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE) - if ((hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL) - if ((ppMap = (BYTE*)MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL) - cbFileSize = GetFileSize(hFile, NULL); - - if (cbFileSize != 0) { - PNG2DIB param; - param.pSource = ppMap; - param.cbSourceSize = cbFileSize; - param.pResult = &pDib; - if (CallService(MS_PNG2DIB, 0, (LPARAM)¶m)) { - pDibBits = (BYTE*)(pDib+1); - HDC sDC = GetDC(NULL); - HBITMAP hBitmap = CreateDIBitmap(sDC, pDib, CBM_INIT, pDibBits, (BITMAPINFO*)pDib, DIB_PAL_COLORS); - SelectObject(sDC, hBitmap); - ReleaseDC(NULL, sDC); - GlobalFree(pDib); - cbFileSize = (INT_PTR)hBitmap; - } - else cbFileSize = 0; - } - - if (ppMap != NULL) UnmapViewOfFile(ppMap); - if (hMap != NULL) CloseHandle(hMap); - if (hFile != NULL) CloseHandle(hFile); - - return (INT_PTR)cbFileSize; - } } - - if (S_OK != OleLoadPicturePath(LPOLESTR(szFilename), NULL, 0, 0, IID_IPicture, (PVOID*)&pic)) - return 0; - - pic->get_Type(&picType); - if (picType != PICTYPE_BITMAP) { - pic->Release(); - return 0; - } - OLE_HANDLE hOleBmp; - pic->get_Handle(&hOleBmp); - hBmp = (HBITMAP)hOleBmp; - GetObject(hBmp, sizeof(bmpInfo), &bmpInfo); - - //need to copy bitmap so we can free the IPicture - hdc = GetDC(NULL); - hdcMem1 = CreateCompatibleDC(hdc); - hdcMem2 = CreateCompatibleDC(hdc); - hOldBitmap = (HBITMAP)SelectObject(hdcMem1, hBmp); - hBmpCopy = CreateCompatibleBitmap(hdcMem1, bmpInfo.bmWidth, bmpInfo.bmHeight); - hOldBitmap2 = (HBITMAP)SelectObject(hdcMem2, hBmpCopy); - BitBlt(hdcMem2, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, hdcMem1, 0, 0, SRCCOPY); - SelectObject(hdcMem1, hOldBitmap); - SelectObject(hdcMem2, hOldBitmap2); - DeleteDC(hdcMem2); - DeleteDC(hdcMem1); - ReleaseDC(NULL, hdc); - - DeleteObject(hBmp); - pic->Release(); - return (INT_PTR)hBmpCopy; -} - -static INT_PTR BmpFilterLoadBitmap(WPARAM, LPARAM lParam) -{ - return sttBitmapLoader(_A2T((const char*)lParam)); -} - -static INT_PTR BmpFilterLoadBitmapW(WPARAM, LPARAM lParam) -{ - return sttBitmapLoader((const wchar_t*)lParam); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// - -int InitBitmapFilter(void) -{ - CreateServiceFunction(MS_UTILS_LOADBITMAP, BmpFilterLoadBitmap); - CreateServiceFunction(MS_UTILS_LOADBITMAPW, BmpFilterLoadBitmapW); - return 0; -} diff --git a/src/modules/utils/utils.cpp b/src/modules/utils/utils.cpp index 9373759ab5..abcca9426f 100644 --- a/src/modules/utils/utils.cpp +++ b/src/modules/utils/utils.cpp @@ -33,7 +33,6 @@ int InitWindowList(void); int InitPathUtils(void); int InitHyperlink(void); int InitColourPicker(void); -int InitBitmapFilter(void); void InitXmlApi(void); void InitTimeZones(void); @@ -482,7 +481,6 @@ int LoadUtilsModule(void) InitHyperlink(); InitPathUtils(); InitColourPicker(); - InitBitmapFilter(); InitXmlApi(); InitTimeZones(); InitCrypt(); -- cgit v1.2.3