diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-01 22:15:26 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-01 22:15:26 +0000 |
commit | 612fc2f36903f0168f88622f61e1a0de4dae5b92 (patch) | |
tree | 7ba72966a7ed48a480b01e4b964d85fecdcbb725 | |
parent | acd4daf132c8ff3b05df7615e95f60be2fb82ddb (diff) |
- 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
41 files changed, 148 insertions, 543 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib Binary files differindex f3202d04eb..3bf29e05d2 100644 --- a/bin10/lib/mir_core.lib +++ b/bin10/lib/mir_core.lib diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib Binary files differindex cdd92f5529..674f7b3e93 100644 --- a/bin10/lib/mir_core64.lib +++ b/bin10/lib/mir_core64.lib diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib Binary files differindex f73ab631f1..fe3d629dfc 100644 --- a/bin12/lib/mir_core.lib +++ b/bin12/lib/mir_core.lib diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib Binary files differindex 4a7b8d10ea..5ba24ac023 100644 --- a/bin12/lib/mir_core64.lib +++ b/bin12/lib/mir_core64.lib diff --git a/include/m_utils.h b/include/m_utils.h index d4662d3370..3f716cc069 100644 --- a/include/m_utils.h +++ b/include/m_utils.h @@ -318,35 +318,14 @@ __forceinline INT_PTR Utils_AssertInsideScreen(RECT *rc) { #define CPM_GETDEFAULTCOLOUR 0x1003 //returns colour
#define CPN_COLOURCHANGED 1 //sent through WM_COMMAND
-/***************************** Bitmap Filter (0.1.2.1+) *************************/
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Loads a bitmap v0.1.2.1+
-// wParam = 0
-// lParam = (LPARAM)(const char*)filename
-// returns HBITMAP on success, NULL on failure
-// This function uses OleLoadPicturePath() so supports BMP, JPEG and GIF. It may
-// support PNG on future versions of Windows (or XP for that matter)
-// For speed, if the file extension is .bmp or .rle it'll use LoadImage() so as
-// to avoid the big lag loading OLE.
-// Remember to DeleteObject() when you're done
-
-#define MS_UTILS_LOADBITMAP "Utils/LoadBitmap"
-#define MS_UTILS_LOADBITMAPW "Utils/LoadBitmapW"
-
-#ifdef _UNICODE
- #define MS_UTILS_LOADBITMAPT MS_UTILS_LOADBITMAPW
-#else
- #define MS_UTILS_LOADBITMAPT MS_UTILS_LOADBITMAP
-#endif
-
/////////////////////////////////////////////////////////////////////////////////////////
// Gets the filter strings for use in the open file dialog
// See the MSDN under OPENFILENAME.lpstrFilter for the formatting
// An 'All Bitmaps' item is always first and 'All Files' is last.
// The returned string is already translated.
-EXTERN_C MIR_CORE_DLL(void) BmpFilterGetStrings(TCHAR *dest, size_t destLen);
+EXTERN_C MIR_CORE_DLL(HBITMAP) Bitmap_Load(const TCHAR *ptszFileName);
+EXTERN_C MIR_CORE_DLL(void) Bitmap_GetFilter(TCHAR *dest, size_t destLen);
/////////////////////////////////////////////////////////////////////////////////////////
// Saves a path to a relative path (from the miranda directory)
diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp index 4dc593fcd2..8cd31b023b 100644 --- a/plugins/AVS/src/options.cpp +++ b/plugins/AVS/src/options.cpp @@ -100,7 +100,7 @@ static void RemoveProtoPic(const char *szProto) static void SetProtoPic(char *szProto) { TCHAR FileName[MAX_PATH], filter[256]; - BmpFilterGetStrings(filter, SIZEOF(filter));
+ Bitmap_GetFilter(filter, SIZEOF(filter)); OPENFILENAME ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; @@ -706,7 +706,7 @@ INT_PTR CALLBACK DlgProcAvatarOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA int OptInit(WPARAM wParam, LPARAM) { - OPTIONSDIALOGPAGE odp = { 0 };
+ OPTIONSDIALOGPAGE odp = { 0 }; odp.hInstance = g_hInst; odp.flags = ODPF_BOLDGROUPS; odp.pszGroup = LPGEN("Contacts"); @@ -1101,7 +1101,7 @@ static INT_PTR CALLBACK DlgProcAvatarProtoInfo(HWND hwndDlg, UINT msg, WPARAM wP int OnDetailsInit(WPARAM wParam, LPARAM lParam) { - OPTIONSDIALOGPAGE odp = { 0 };
+ OPTIONSDIALOGPAGE odp = { 0 }; odp.hIcon = g_hIcon; odp.hInstance = g_hInst; odp.pszTitle = LPGEN("Avatar"); diff --git a/plugins/AVS/src/services.cpp b/plugins/AVS/src/services.cpp index 7411849efa..1f3fd7441b 100644 --- a/plugins/AVS/src/services.cpp +++ b/plugins/AVS/src/services.cpp @@ -128,7 +128,7 @@ static INT_PTR avSetAvatar(MCONTACT hContact, TCHAR *tszPath) if (tszPath == NULL) {
TCHAR filter[256];
- BmpFilterGetStrings(filter, SIZEOF(filter));
+ Bitmap_GetFilter(filter, SIZEOF(filter));
OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
diff --git a/plugins/AvatarHistory/src/AvatarDlg.cpp b/plugins/AvatarHistory/src/AvatarDlg.cpp index 3489960f50..a6e8a24029 100644 --- a/plugins/AvatarHistory/src/AvatarDlg.cpp +++ b/plugins/AvatarHistory/src/AvatarDlg.cpp @@ -538,7 +538,7 @@ static INT_PTR ShowDialogSvc(WPARAM wParam, LPARAM lParam) int ShowSaveDialog(HWND hwnd, TCHAR* fn, MCONTACT hContact)
{
TCHAR filter[MAX_PATH], file[MAX_PATH];
- BmpFilterGetStrings(filter, SIZEOF(filter));
+ Bitmap_GetFilter(filter, SIZEOF(filter));
OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
diff --git a/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp index 49cfb9bd80..a472ded4b1 100644 --- a/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp +++ b/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp @@ -2506,29 +2506,29 @@ int OnFrameTitleBarBackgroundChange(WPARAM, LPARAM) {
if (MirandaExiting()) return 0;
{
- DBVARIANT dbv = { 0 };
-
AlignCOLLIconToLeft = db_get_b(NULL, "FrameTitleBar", "AlignCOLLIconToLeft", CLCDEFAULT_COLLICONTOLEFT);
bkColour = sttGetColor("FrameTitleBar", "BkColour", CLCDEFAULT_BKCOLOUR);
bkUseWinColours = db_get_b(NULL, "FrameTitleBar", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS);
SelBkColour = sttGetColor("FrameTitleBar", "TextColour", CLCDEFAULT_TEXTCOLOUR);
- if (hBmpBackground) { DeleteObject(hBmpBackground); hBmpBackground = NULL; }
+
+ if (hBmpBackground) {
+ DeleteObject(hBmpBackground);
+ hBmpBackground = NULL;
+ }
if (g_CluiData.fDisableSkinEngine) {
if (db_get_b(NULL, "FrameTitleBar", "UseBitmap", CLCDEFAULT_USEBITMAP)) {
- if (!db_get_s(NULL, "FrameTitleBar", "BkBitmap", &dbv)) {
- hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.pszVal);
- db_free(&dbv);
- }
+ ptrT tszBitmapName(db_get_tsa(NULL, "FrameTitleBar", "BkBitmap"));
+ if (tszBitmapName)
+ hBmpBackground = Bitmap_Load(tszBitmapName);
}
backgroundBmpUse = db_get_w(NULL, "FrameTitleBar", "BkBmpUse", CLCDEFAULT_BKBMPUSE);
}
- };
+ }
CLUI__cliInvalidateRect(pcli->hwndContactList, 0, 0);
RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_ERASE | RDW_INVALIDATE);
-
return 0;
}
diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp index 57c9025fe5..9d762dd183 100644 --- a/plugins/Clist_modern/src/modern_clcopts.cpp +++ b/plugins/Clist_modern/src/modern_clcopts.cpp @@ -1369,7 +1369,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_COMMAND:
if (LOWORD(wParam) == IDC_BROWSE) {
TCHAR str[MAX_PATH], filter[512];
- BmpFilterGetStrings(filter, SIZEOF(filter));
+ Bitmap_GetFilter(filter, SIZEOF(filter));
GetDlgItemText(hwndDlg, IDC_FILENAME, str, SIZEOF(str));
OPENFILENAME ofn = { 0 };
diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp index 33734e5199..f68832d1b9 100644 --- a/plugins/Clist_modern/src/modern_clcutils.cpp +++ b/plugins/Clist_modern/src/modern_clcutils.cpp @@ -673,9 +673,9 @@ void LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst) dat->MenuTextHiColor = sttGetColor("Menu", "SelTextColour", CLCDEFAULT_MODERN_SELTEXTCOLOUR);
if (db_get_b(NULL, "Menu", "UseBitmap", CLCDEFAULT_USEBITMAP)) {
- ptrA szBitmap(db_get_sa(NULL, "Menu", "BkBitmap"));
- if (szBitmap)
- dat->hMenuBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, szBitmap);
+ ptrT tszBitmap(db_get_tsa(NULL, "Menu", "BkBitmap"));
+ if (tszBitmap != NULL)
+ dat->hMenuBackground = Bitmap_Load(tszBitmap);
}
dat->MenuBmpUse = db_get_w(NULL, "Menu", "BkBmpUse", CLCDEFAULT_BKBMPUSE);
}
diff --git a/plugins/Clist_modern/src/modern_clistevents.cpp b/plugins/Clist_modern/src/modern_clistevents.cpp index c03ed3b766..a23b0cfad6 100644 --- a/plugins/Clist_modern/src/modern_clistevents.cpp +++ b/plugins/Clist_modern/src/modern_clistevents.cpp @@ -260,15 +260,13 @@ static int ehhEventAreaBackgroundSettingsChanged(WPARAM, LPARAM) DeleteObject(event_area.hBmpBackground);
event_area.hBmpBackground = NULL;
}
- if (g_CluiData.fDisableSkinEngine)
- {
- DBVARIANT dbv;
+
+ if (g_CluiData.fDisableSkinEngine) {
event_area.bkColour = sttGetColor("EventArea", "BkColour", CLCDEFAULT_BKCOLOUR);
if (db_get_b(NULL, "EventArea", "UseBitmap", CLCDEFAULT_USEBITMAP)) {
- if (!db_get_s(NULL, "EventArea", "BkBitmap", &dbv)) {
- event_area.hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.pszVal);
- db_free(&dbv);
- }
+ ptrT tszBitmap(db_get_tsa(NULL, "EventArea", "BkBitmap"));
+ if (tszBitmap != NULL)
+ event_area.hBmpBackground = Bitmap_Load(tszBitmap);
}
event_area.useWinColors = db_get_b(NULL, "EventArea", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS);
event_area.backgroundBmpUse = db_get_w(NULL, "EventArea", "BkBmpUse", CLCDEFAULT_BKBMPUSE);
diff --git a/plugins/Clist_modern/src/modern_skinengine.cpp b/plugins/Clist_modern/src/modern_skinengine.cpp index d2625f1943..d24d5c82e2 100644 --- a/plugins/Clist_modern/src/modern_skinengine.cpp +++ b/plugins/Clist_modern/src/modern_skinengine.cpp @@ -86,7 +86,7 @@ static void ske_AddParseSkinFont(char * szFontID, char * szDefineString); static int ske_GetSkinFromDB(char * szSection, SKINOBJECTSLIST * Skin); static LPSKINOBJECTDESCRIPTOR ske_FindObject(const char *szName, SKINOBJECTSLIST *Skin); static int ske_LoadSkinFromResource(BOOL bOnlyObjects); -static void ske_PreMultiplyChanells(HBITMAP hbmp, BYTE Mult); +static void ske_PreMultiplyChannels(HBITMAP hbmp, BYTE Mult); static int ske_ValidateSingleFrameImage(FRAMEWND * Frame, BOOL SkipBkgBlitting); static INT_PTR ske_Service_UpdateFrameImage(WPARAM wParam, LPARAM lParam); static INT_PTR ske_Service_InvalidateFrameImage(WPARAM wParam, LPARAM lParam); @@ -1411,7 +1411,7 @@ INT_PTR ske_Service_DrawGlyph(WPARAM wParam, LPARAM lParam) } -void ske_PreMultiplyChanells(HBITMAP hbmp, BYTE Mult) +void ske_PreMultiplyChannels(HBITMAP hbmp, BYTE Mult) { BITMAP bmp; BOOL flag = FALSE; @@ -1476,237 +1476,33 @@ int ske_GetFullFilename(TCHAR *buf, const TCHAR *file, TCHAR *skinfolder, BOOL m return 0; } -/* -This function is required to load TGA to dib buffer myself -Major part of routines is from http://tfcduke.developpez.com/tutoriel/format/tga/fichiers/tga.c -*/ - -static BOOL ske_ReadTGAImageData(void * From, DWORD fromSize, BYTE * destBuf, DWORD bufSize, BOOL RLE) -{ - BYTE * pos = destBuf; - BYTE * from = fromSize ? (BYTE*)From : NULL; - FILE * fp = !fromSize ? (FILE*)From : NULL; - DWORD destCount = 0; - DWORD fromCount = 0; - if (!RLE) { - while (((from && fromCount < fromSize) || (fp && fromCount < bufSize)) - && (destCount < bufSize)) { - BYTE r = from ? from[fromCount++] : (BYTE)fgetc(fp); - BYTE g = from ? from[fromCount++] : (BYTE)fgetc(fp); - BYTE b = from ? from[fromCount++] : (BYTE)fgetc(fp); - BYTE a = from ? from[fromCount++] : (BYTE)fgetc(fp); - pos[destCount++] = r; - pos[destCount++] = g; - pos[destCount++] = b; - pos[destCount++] = a; - - if (destCount > bufSize) break; - if (from) if (fromCount < fromSize) break; - } - } - else { - BYTE rgba[4]; - BYTE packet_header; - BYTE *ptr = pos; - BYTE size; - int i; - while (ptr < pos + bufSize) { - /* read first byte */ - packet_header = from ? from[fromCount] : (BYTE)fgetc(fp); - if (from) from++; - size = 1 + (packet_header & 0x7f); - if (packet_header & 0x80) { - /* run-length packet */ - if (from) { - *((DWORD*)rgba) = *((DWORD*)(from + fromCount)); - fromCount += 4; - } - else fread(rgba, sizeof(BYTE), 4, fp); - for (i = 0; i < size; ++i, ptr += 4) { - ptr[2] = rgba[2]; - ptr[1] = rgba[1]; - ptr[0] = rgba[0]; - ptr[3] = rgba[3]; - } - } - else { /* not run-length packet */ - for (i = 0; i < size; ++i, ptr += 4) { - ptr[0] = from ? from[fromCount++] : (BYTE)fgetc(fp); - ptr[1] = from ? from[fromCount++] : (BYTE)fgetc(fp); - ptr[2] = from ? from[fromCount++] : (BYTE)fgetc(fp); - ptr[3] = from ? from[fromCount++] : (BYTE)fgetc(fp); - } - } - } - } - return TRUE; -} - -static HBITMAP ske_LoadGlyphImage_TGA(const TCHAR *szFilename) -{ - BYTE *colormap = NULL; - int cx = 0, cy = 0; - BOOL err = FALSE; - tga_header_t header; - if (!szFilename) return NULL; - if (!wildcmpit(szFilename, _T("*\\*%.tga"))) { - //Loading TGA image from file - FILE *fp = _tfopen(szFilename, _T("rb")); - if (!fp) { - TRACEVAR("error: couldn't open \"%s\"!\n", szFilename); - return NULL; - } - /* read header */ - fread(&header, sizeof(tga_header_t), 1, fp); - if ((header.pixel_depth != 32) || ((header.image_type != 10) && (header.image_type != 2))) { - fclose(fp); - return NULL; - } - - /*memory allocation */ - colormap = (BYTE*)malloc(header.width*header.height * 4); - cx = header.width; - cy = header.height; - fseek(fp, header.id_lenght, SEEK_CUR); - fseek(fp, header.cm_length, SEEK_CUR); - err = !ske_ReadTGAImageData((void*)fp, 0, colormap, header.width*header.height * 4, header.image_type == 10); - fclose(fp); - } - else { - /* reading from resources IDR_TGA_DEFAULT_SKIN */ - HRSRC hRSrc = FindResourceA(g_hInst, MAKEINTRESOURCEA(IDR_TGA_DEFAULT_SKIN), "TGA"); - if (!hRSrc) return NULL; - HGLOBAL hRes = LoadResource(g_hInst, hRSrc); - if (!hRes) return NULL; - DWORD size = SizeofResource(g_hInst, hRSrc); - BYTE *mem = (BYTE*)LockResource(hRes); - if (size > sizeof(header)) { - tga_header_t * header = (tga_header_t *)mem; - if (header->pixel_depth == 32 && (header->image_type == 2 || header->image_type == 10)) { - colormap = (BYTE*)malloc(header->width*header->height * 4); - cx = header->width; - cy = header->height; - ske_ReadTGAImageData((void*)(mem + sizeof(tga_header_t) + header->id_lenght + header->cm_length), size - (sizeof(tga_header_t) + header->id_lenght + header->cm_length), colormap, cx*cy * 4, header->image_type == 10); - } - } - FreeResource(hRes); - } - - if (colormap) { //create dib section - BYTE * pt; - HBITMAP hbmp = ske_CreateDIB32Point(cx, cy, (void**)&pt); - if (hbmp) - memcpy(pt, colormap, cx*cy * 4); - free(colormap); - return hbmp; - } - return NULL; -} - - -//this function is required to load PNG to dib buffer myself -static HBITMAP ske_LoadGlyphImage_Png2Dib(const TCHAR *tszFilename) -{ - HANDLE hFile, hMap = NULL; - BYTE* ppMap = NULL; - long cbFileSize = 0; - BITMAPINFOHEADER* pDib = { 0 }; - BYTE* pDibBits = NULL; - - if (!ServiceExists(MS_PNG2DIB)) { - MessageBox(NULL, TranslateT("You need an image services plugin to process PNG images."), TranslateT("Error"), MB_OK); - return (HBITMAP)NULL; - } - - if ((hFile = CreateFile(tszFilename, 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); - else - cbFileSize = 0; - } - - if (ppMap != NULL) UnmapViewOfFile(ppMap); - if (hMap != NULL) CloseHandle(hMap); - if (hFile != NULL) CloseHandle(hFile); - - if (cbFileSize == 0) - return (HBITMAP)NULL; - - HBITMAP hBitmap; - BITMAPINFO* bi = (BITMAPINFO*)pDib; - BYTE *pt = (BYTE*)bi; - pt += bi->bmiHeader.biSize; - if (bi->bmiHeader.biBitCount != 32) { - HDC sDC = GetDC(NULL); - hBitmap = CreateDIBitmap(sDC, pDib, CBM_INIT, pDibBits, bi, DIB_PAL_COLORS); - SelectObject(sDC, hBitmap); - DeleteDC(sDC); - } - else { - BYTE *ptPixels = pt; - hBitmap = CreateDIBSection(NULL, bi, DIB_RGB_COLORS, (void **)&ptPixels, NULL, 0); - memcpy(ptPixels, pt, bi->bmiHeader.biSizeImage); - } - GlobalFree(pDib); - return hBitmap; -} - static HBITMAP ske_LoadGlyphImageByDecoders(const TCHAR *tszFileName) { - // Loading image from file by imgdecoder... - HBITMAP hBitmap = NULL; - TCHAR ext[5]; - BYTE f = 0; - - BITMAP bmpInfo; - { - size_t l = mir_tstrlen(tszFileName); - mir_tstrncpy(ext, tszFileName + (l - 4), 5); - } if (!_tcschr(tszFileName, '%') && !PathFileExists(tszFileName)) return NULL; - if (!mir_tstrcmpi(ext, _T(".tga"))) { - hBitmap = ske_LoadGlyphImage_TGA(tszFileName); - f = 1; - } - else if (ServiceExists("Image/Png2Dib") && !mir_tstrcmpi(ext, _T(".png"))) { - hBitmap = ske_LoadGlyphImage_Png2Dib(tszFileName); - GetObject(hBitmap, sizeof(BITMAP), &bmpInfo); - f = (bmpInfo.bmBits != NULL); - } - else if (mir_tstrcmpi(ext, _T(".png"))) { - hBitmap = (HBITMAP)CallService(MS_UTILS_LOADBITMAPT, 0, (LPARAM)tszFileName); - } + HBITMAP hBitmap = Bitmap_Load(tszFileName); + if (hBitmap == NULL) + return NULL; - if (hBitmap) { - GetObject(hBitmap, sizeof(BITMAP), &bmpInfo); - if (bmpInfo.bmBitsPixel == 32) - ske_PreMultiplyChanells(hBitmap, f); - else { - HDC dc32 = CreateCompatibleDC(NULL); - HDC dc24 = CreateCompatibleDC(NULL); - HBITMAP hBitmap32 = ske_CreateDIB32(bmpInfo.bmWidth, bmpInfo.bmHeight); - HBITMAP obmp24 = (HBITMAP)SelectObject(dc24, hBitmap); - HBITMAP obmp32 = (HBITMAP)SelectObject(dc32, hBitmap32); - BitBlt(dc32, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, dc24, 0, 0, SRCCOPY); - SelectObject(dc24, obmp24); - SelectObject(dc32, obmp32); - DeleteDC(dc24); - DeleteDC(dc32); - DeleteObject(hBitmap); - hBitmap = hBitmap32; - ske_PreMultiplyChanells(hBitmap, 0); - } + BITMAP bmpInfo; + GetObject(hBitmap, sizeof(BITMAP), &bmpInfo); + if (bmpInfo.bmBitsPixel == 32) + ske_PreMultiplyChannels(hBitmap, 0); + else { + HDC dc32 = CreateCompatibleDC(NULL); + HDC dc24 = CreateCompatibleDC(NULL); + HBITMAP hBitmap32 = ske_CreateDIB32(bmpInfo.bmWidth, bmpInfo.bmHeight); + HBITMAP obmp24 = (HBITMAP)SelectObject(dc24, hBitmap); + HBITMAP obmp32 = (HBITMAP)SelectObject(dc32, hBitmap32); + BitBlt(dc32, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, dc24, 0, 0, SRCCOPY); + SelectObject(dc24, obmp24); + SelectObject(dc32, obmp32); + DeleteDC(dc24); + DeleteDC(dc32); + DeleteObject(hBitmap); + hBitmap = hBitmap32; + ske_PreMultiplyChannels(hBitmap, 0); } return hBitmap; } diff --git a/plugins/Clist_modern/src/modern_statusbar.cpp b/plugins/Clist_modern/src/modern_statusbar.cpp index e5ba279caf..a282791ae2 100644 --- a/plugins/Clist_modern/src/modern_statusbar.cpp +++ b/plugins/Clist_modern/src/modern_statusbar.cpp @@ -108,13 +108,11 @@ int LoadStatusBarData() if (g_StatusBarData.hBmpBackground) { DeleteObject(g_StatusBarData.hBmpBackground); g_StatusBarData.hBmpBackground = NULL; }
if (g_CluiData.fDisableSkinEngine) {
- DBVARIANT dbv;
g_StatusBarData.bkColour = sttGetColor("StatusBar", "BkColour", CLCDEFAULT_BKCOLOUR);
if (db_get_b(NULL, "StatusBar", "UseBitmap", CLCDEFAULT_USEBITMAP)) {
- if (!db_get_s(NULL, "StatusBar", "BkBitmap", &dbv)) {
- g_StatusBarData.hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.pszVal);
- db_free(&dbv);
- }
+ ptrT tszBitmapName(db_get_tsa(NULL, "StatusBar", "BkBitmap"));
+ if (tszBitmapName)
+ g_StatusBarData.hBmpBackground = Bitmap_Load(tszBitmapName);
}
g_StatusBarData.bkUseWinColors = db_get_b(NULL, "StatusBar", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS);
g_StatusBarData.backgroundBmpUse = db_get_w(NULL, "StatusBar", "BkBmpUse", CLCDEFAULT_BKBMPUSE);
diff --git a/plugins/Clist_modern/src/modern_toolbar.cpp b/plugins/Clist_modern/src/modern_toolbar.cpp index cee0d5137a..3771fc2324 100644 --- a/plugins/Clist_modern/src/modern_toolbar.cpp +++ b/plugins/Clist_modern/src/modern_toolbar.cpp @@ -138,14 +138,13 @@ static int ehhToolBarBackgroundSettingsChanged(WPARAM, LPARAM) DeleteObject(tbdat.mtb_hBmpBackground);
tbdat.mtb_hBmpBackground = NULL;
}
+
if (g_CluiData.fDisableSkinEngine) {
- DBVARIANT dbv;
tbdat.mtb_bkColour = sttGetColor("ToolBar", "BkColour", CLCDEFAULT_BKCOLOUR);
if (db_get_b(NULL, "ToolBar", "UseBitmap", CLCDEFAULT_USEBITMAP)) {
- if (!db_get_s(NULL, "ToolBar", "BkBitmap", &dbv, DBVT_TCHAR)) {
- tbdat.mtb_hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.ptszVal);
- db_free(&dbv);
- }
+ ptrT tszBitmapName(db_get_tsa(NULL, "ToolBar", "BkBitmap"));
+ if (tszBitmapName)
+ tbdat.mtb_hBmpBackground = Bitmap_Load(tszBitmapName);
}
tbdat.mtb_useWinColors = db_get_b(NULL, "ToolBar", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS);
tbdat.mtb_backgroundBmpUse = db_get_b(NULL, "ToolBar", "BkBmpUse", CLCDEFAULT_BKBMPUSE);
diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp index 4d1b3cc2c6..62280566a4 100644 --- a/plugins/Clist_modern/src/modern_viewmodebar.cpp +++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp @@ -1165,13 +1165,11 @@ static int ehhViewModeBackgroundSettingsChanged(WPARAM, LPARAM) }
if (g_CluiData.fDisableSkinEngine) {
- DBVARIANT dbv;
view_mode.bkColour = sttGetColor("ViewMode", "BkColour", CLCDEFAULT_BKCOLOUR);
if (db_get_b(NULL, "ViewMode", "UseBitmap", CLCDEFAULT_USEBITMAP)) {
- if (!db_get_s(NULL, "ViewMode", "BkBitmap", &dbv)) {
- view_mode.hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.pszVal);
- db_free(&dbv);
- }
+ ptrT tszBitmapName(db_get_tsa(NULL, "ViewMode", "BkBitmap"));
+ if (tszBitmapName)
+ view_mode.hBmpBackground = Bitmap_Load(tszBitmapName);
}
view_mode.useWinColors = db_get_b(NULL, "ViewMode", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS);
view_mode.backgroundBmpUse = db_get_w(NULL, "ViewMode", "BkBmpUse", CLCDEFAULT_BKBMPUSE);
diff --git a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp index 6ce2df5ff9..d9a2614206 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp +++ b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp @@ -2332,10 +2332,7 @@ boolean AlignCOLLIconToLeft; //will hide frame icon int OnFrameTitleBarBackgroundChange() { - DBVARIANT dbv; - AlignCOLLIconToLeft = cfg::getByte("FrameTitleBar", "AlignCOLLIconToLeft", 0); - bkColour = cfg::getDword("FrameTitleBar", "BkColour", CLCDEFAULT_BKCOLOUR); if (hBmpBackground) { @@ -2343,10 +2340,9 @@ int OnFrameTitleBarBackgroundChange() hBmpBackground = NULL; } if (cfg::getByte("FrameTitleBar", "UseBitmap", CLCDEFAULT_USEBITMAP)) { - if (!db_get(NULL, "FrameTitleBar", "BkBitmap", &dbv)) { - hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.pszVal); - mir_free(dbv.pszVal); - } + ptrT tszBitmapName(db_get_tsa(NULL, "FrameTitleBar", "BkBitmap"));
+ if (tszBitmapName != NULL)
+ hBmpBackground = Bitmap_Load(tszBitmapName);
} backgroundBmpUse = cfg::getWord("FrameTitleBar", "BkBmpUse", CLCDEFAULT_BKBMPUSE); diff --git a/plugins/Clist_nicer/src/clcopts.cpp b/plugins/Clist_nicer/src/clcopts.cpp index 23a6b172d4..ccff06c1b1 100644 --- a/plugins/Clist_nicer/src/clcopts.cpp +++ b/plugins/Clist_nicer/src/clcopts.cpp @@ -745,7 +745,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, if (LOWORD(wParam) == IDC_BROWSE) {
TCHAR str[MAX_PATH], filter[512];
GetDlgItemText(hwndDlg, IDC_FILENAME, str, SIZEOF(str));
- BmpFilterGetStrings(filter, SIZEOF(filter));
+ Bitmap_GetFilter(filter, SIZEOF(filter));
OPENFILENAME ofn = { 0 };
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp index 4e441c8c98..3b3d478c1c 100644 --- a/plugins/Clist_nicer/src/extBackg.cpp +++ b/plugins/Clist_nicer/src/extBackg.cpp @@ -625,7 +625,7 @@ static void CorrectBitmap32Alpha(HBITMAP hBitmap) static HBITMAP LoadPNG(const char *szFilename)
{
- HBITMAP hBitmap = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)szFilename);
+ HBITMAP hBitmap = Bitmap_Load(_A2T(szFilename));
if (hBitmap != 0)
CorrectBitmap32Alpha(hBitmap);
diff --git a/plugins/FloatingContacts/src/main.cpp b/plugins/FloatingContacts/src/main.cpp index f0e6295ad7..03101b7fb8 100644 --- a/plugins/FloatingContacts/src/main.cpp +++ b/plugins/FloatingContacts/src/main.cpp @@ -564,7 +564,7 @@ static void CreateBackgroundBrush() hBkBrush = NULL;
}
- if ( db_get_b(NULL, MODULE, "DrawBorder", FLT_DEFAULT_DRAWBORDER)) {
+ if (db_get_b(NULL, MODULE, "DrawBorder", FLT_DEFAULT_DRAWBORDER)) {
COLORREF cr = (COLORREF)db_get_dw(NULL, MODULE, "LTEdgesColor", FLT_DEFAULT_LTEDGESCOLOR);
hLTEdgesPen = CreatePen(PS_SOLID, 1, cr);
cr = (COLORREF)db_get_dw(NULL, MODULE, "RBEdgesColor", FLT_DEFAULT_RBEDGESCOLOR);
@@ -572,11 +572,9 @@ static void CreateBackgroundBrush() }
if (db_get_b(NULL, MODULE, "BkUseBitmap", FLT_DEFAULT_BKGNDUSEBITMAP)) {
- DBVARIANT dbv;
- if ( !db_get_ts(NULL, MODULE, "BkBitmap", &dbv)) {
- hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAPT, 0, (LPARAM)dbv.ptszVal);
- db_free(&dbv);
- }
+ ptrT tszBitmapName(db_get_tsa(NULL, MODULE, "BkBitmap"));
+ if (tszBitmapName != NULL)
+ hBmpBackground = Bitmap_Load(tszBitmapName);
}
nBackgroundBmpUse = (WORD)db_get_w(NULL, MODULE, "BkBitmapOpt", FLT_DEFAULT_BKGNDBITMAPOPT);
diff --git a/plugins/FloatingContacts/src/options.cpp b/plugins/FloatingContacts/src/options.cpp index 0571b83aa8..fbc0a79f65 100644 --- a/plugins/FloatingContacts/src/options.cpp +++ b/plugins/FloatingContacts/src/options.cpp @@ -246,7 +246,7 @@ static INT_PTR APIENTRY OptSknWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP {
TCHAR str[MAX_PATH], filter[512];
GetDlgItemText(hwndDlg, IDC_FILENAME, str, SIZEOF(str));
- BmpFilterGetStrings(filter, SIZEOF(filter));
+ Bitmap_GetFilter(filter, SIZEOF(filter));
OPENFILENAME ofn = {0};
ofn.lStructSize = sizeof(ofn);
diff --git a/plugins/ModernOpt/src/mopt_selector.cpp b/plugins/ModernOpt/src/mopt_selector.cpp index df9fdc565b..994ba7489a 100644 --- a/plugins/ModernOpt/src/mopt_selector.cpp +++ b/plugins/ModernOpt/src/mopt_selector.cpp @@ -46,15 +46,9 @@ static void sttPreviewSkin(MODERNOPTOBJECT *obj, TCHAR *fn, LPDRAWITEMSTRUCT lps return;
}
- char *afn = mir_t2a(fn);
- char *fnpreview = (char *)mir_alloc(mir_strlen(afn) + 10);
- mir_strcpy(fnpreview, afn);
- mir_strcat(fnpreview, ".png");
- HBITMAP hbmPreview = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)fnpreview);
- mir_free(afn);
- mir_free(fnpreview);
-
- if (!hbmPreview) return;
+ HBITMAP hbmPreview = Bitmap_Load(CMString(fn) + _T(".png"));
+ if (!hbmPreview)
+ return;
BITMAP bmp;
GetObject(hbmPreview, sizeof(bmp), &bmp);
diff --git a/plugins/SimpleStatusMsg/src/msgbox.cpp b/plugins/SimpleStatusMsg/src/msgbox.cpp index 87bac02d81..3ce328a87a 100644 --- a/plugins/SimpleStatusMsg/src/msgbox.cpp +++ b/plugins/SimpleStatusMsg/src/msgbox.cpp @@ -453,26 +453,26 @@ VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, HWND edit_control) break; case ID__VARIABLES_MOREVARIABLES: - { - VARHELPINFO vhi = {0}; - vhi.cbSize = sizeof(vhi); - vhi.flags = VHF_FULLDLG | VHF_SETLASTSUBJECT; - vhi.hwndCtrl = edit_control; - vhi.szSubjectDesc = NULL; - vhi.szExtraTextDesc = NULL; - CallService(MS_VARS_SHOWHELPEX, (WPARAM)hwnd, (LPARAM)&vhi); + { + VARHELPINFO vhi = {0}; + vhi.cbSize = sizeof(vhi); + vhi.flags = VHF_FULLDLG | VHF_SETLASTSUBJECT; + vhi.hwndCtrl = edit_control; + vhi.szSubjectDesc = NULL; + vhi.szExtraTextDesc = NULL; + CallService(MS_VARS_SHOWHELPEX, (WPARAM)hwnd, (LPARAM)&vhi); + } break; - } default: if (!OpenClipboard(GetParent(hwnd))) break; + if (EmptyClipboard()) { TCHAR item_string[128]; - int len; - GetMenuString(hmenu, m_selection, (LPTSTR)&item_string, 128, MF_BYCOMMAND); - len = mir_tstrlen(item_string); + + int len = (int)mir_tstrlen(item_string); if (len) { LPTSTR lptstrCopy; HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(TCHAR)); @@ -486,7 +486,6 @@ VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, HWND edit_control) GlobalUnlock(hglbCopy); SetClipboardData(CF_UNICODETEXT, hglbCopy); - } } CloseClipboard(); diff --git a/plugins/TopToolBar/src/toolbarwnd.cpp b/plugins/TopToolBar/src/toolbarwnd.cpp index ec2505917d..08ce75a4bf 100644 --- a/plugins/TopToolBar/src/toolbarwnd.cpp +++ b/plugins/TopToolBar/src/toolbarwnd.cpp @@ -293,7 +293,6 @@ INT_PTR OnEventFire(WPARAM wParam, LPARAM lParam) int LoadBackgroundOptions()
{
- //load options
bkColour = db_get_dw(NULL, TTB_OPTDIR, "BkColour", TTBDEFAULT_BKCOLOUR);
if (hBmpBackground) {
DeleteObject(hBmpBackground);
@@ -301,11 +300,9 @@ int LoadBackgroundOptions() }
if (db_get_b(NULL, TTB_OPTDIR, "UseBitmap", TTBDEFAULT_USEBITMAP)) {
- DBVARIANT dbv;
- if (!db_get(NULL, TTB_OPTDIR, "BkBitmap", &dbv)) {
- hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.pszVal);
- db_free(&dbv);
- }
+ ptrT tszBitmapName(db_get_tsa(NULL, TTB_OPTDIR, "BkBitmap"));
+ if (tszBitmapName != NULL)
+ hBmpBackground = Bitmap_Load(tszBitmapName);
}
backgroundBmpUse = db_get_w(NULL, TTB_OPTDIR, "BkBmpUse", TTBDEFAULT_BKBMPUSE);
diff --git a/protocols/IcqOscarJ/src/icqosc_svcs.cpp b/protocols/IcqOscarJ/src/icqosc_svcs.cpp index b7d887bad7..6d4b130956 100644 --- a/protocols/IcqOscarJ/src/icqosc_svcs.cpp +++ b/protocols/IcqOscarJ/src/icqosc_svcs.cpp @@ -482,59 +482,58 @@ INT_PTR CIcqProto::SendYouWereAdded(WPARAM, LPARAM lParam) INT_PTR CIcqProto::SetMyAvatar(WPARAM, LPARAM lParam)
{
- TCHAR* tszFile = (TCHAR*)lParam;
- int iRet = -1;
-
- if (!m_bAvatarsEnabled || !m_bSsiEnabled) return -2;
+ if (!m_bAvatarsEnabled || !m_bSsiEnabled)
+ return -2;
+ TCHAR *tszFile = (TCHAR*)lParam;
if (tszFile) { // set file for avatar
int dwPaFormat = ::ProtoGetAvatarFileFormat(tszFile);
if (dwPaFormat != PA_FORMAT_XML) {
// if it should be image, check if it is valid
- HBITMAP avt = (HBITMAP)CallService(MS_UTILS_LOADBITMAPT, 0, (WPARAM)tszFile);
- if (!avt) return iRet;
+ HBITMAP avt = Bitmap_Load(tszFile);
+ if (!avt)
+ return -1;
+
DeleteObject(avt);
}
TCHAR tszMyFile[MAX_PATH + 1];
GetFullAvatarFileName(0, NULL, dwPaFormat, tszMyFile, MAX_PATH);
+
// if not in our storage, copy
if (mir_tstrcmp(tszFile, tszMyFile) && !CopyFile(tszFile, tszMyFile, FALSE)) {
debugLogA("Failed to copy our avatar to local storage.");
- return iRet;
+ return -1;
}
BYTE *hash = calcMD5HashOfFile(tszMyFile);
- if (hash) {
- BYTE ihash[0x14];
- // upload hash to server
- ihash[0] = 0; //unknown
- ihash[1] = dwPaFormat == PA_FORMAT_XML ? AVATAR_HASH_FLASH : AVATAR_HASH_STATIC; //hash type
- ihash[2] = 1; //hash status
- ihash[3] = 0x10; //hash len
- memcpy((ihash + 4), hash, 0x10);
- updateServAvatarHash(ihash, 0x14);
-
- if (setSettingBlob(NULL, "AvatarHash", ihash, 0x14))
- debugLogA("Failed to save avatar hash.");
-
- TCHAR tmp[MAX_PATH];
- PathToRelativeT(tszMyFile, tmp);
- setTString(NULL, "AvatarFile", tmp);
-
- iRet = 0;
-
- SAFE_FREE((void**)&hash);
- }
+ if (hash == NULL)
+ return -1;
+
+ BYTE ihash[0x14];
+ // upload hash to server
+ ihash[0] = 0; //unknown
+ ihash[1] = dwPaFormat == PA_FORMAT_XML ? AVATAR_HASH_FLASH : AVATAR_HASH_STATIC; //hash type
+ ihash[2] = 1; //hash status
+ ihash[3] = 0x10; //hash len
+ memcpy((ihash + 4), hash, 0x10);
+ updateServAvatarHash(ihash, 0x14);
+
+ if (setSettingBlob(NULL, "AvatarHash", ihash, 0x14))
+ debugLogA("Failed to save avatar hash.");
+
+ TCHAR tmp[MAX_PATH];
+ PathToRelativeT(tszMyFile, tmp);
+ setTString(NULL, "AvatarFile", tmp);
+ SAFE_FREE((void**)&hash);
}
- else { // delete user avatar
+ else {
+ // delete user avatar
delSetting("AvatarFile");
setSettingBlob(NULL, "AvatarHash", hashEmptyAvatar, 9);
updateServAvatarHash(hashEmptyAvatar, 9); // set blank avatar
- iRet = 0;
}
-
- return iRet;
+ return 0;
}
INT_PTR CIcqProto::SetNickName(WPARAM wParam, LPARAM lParam)
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index 3b5af188c2..d3958b3436 100644 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -651,7 +651,7 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP if (item != NULL) { if (item->photoFileName) { photoInfo->ppro->debugLog(_T("Showing picture from %s"), item->photoFileName); - photoInfo->hBitmap = (HBITMAP)CallService(MS_UTILS_LOADBITMAPT, 0, (LPARAM)item->photoFileName); + photoInfo->hBitmap = Bitmap_Load(item->photoFileName); FIP->FI_Premultiply(photoInfo->hBitmap); ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_SHOW); } diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index 8350193384..c4860f67ad 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -295,7 +295,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (GetTempFileName(szTempPath, _T("jab"), 0, szTempFileName) > 0) {
dat->ppro->debugLog(_T("Temp file = %s"), szTempFileName);
if (CopyFile(szAvatarFileName, szTempFileName, FALSE) == TRUE) {
- if ((dat->hBitmap = (HBITMAP)CallService(MS_UTILS_LOADBITMAPT, 0, (LPARAM)szTempFileName)) != NULL) {
+ if ((dat->hBitmap = Bitmap_Load(szTempFileName)) != NULL) {
FIP->FI_Premultiply(dat->hBitmap);
mir_tstrcpy(dat->ppro->m_szPhotoFileName, szTempFileName);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
@@ -334,7 +334,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case IDC_LOAD:
TCHAR szFilter[512], szFileName[MAX_PATH];
- BmpFilterGetStrings(szFilter, SIZEOF(szFilter));
+ Bitmap_GetFilter(szFilter, SIZEOF(szFilter));
OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
@@ -356,11 +356,11 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR }
if (GetTempPath(SIZEOF(szTempPath), szTempPath) <= 0)
mir_tstrcpy(szTempPath, _T(".\\"));
+
if (GetTempFileName(szTempPath, _T("jab"), 0, szTempFileName) > 0) {
dat->ppro->debugLog(_T("Temp file = %s"), szTempFileName);
if (CopyFile(szFileName, szTempFileName, FALSE) == TRUE) {
- char* pszTemp = mir_t2a(szTempFileName);
- if ((hNewBitmap = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)pszTemp)) != NULL) {
+ if ((hNewBitmap = Bitmap_Load(szTempFileName)) != NULL) {
if (dat->hBitmap) {
DeleteObject(dat->hBitmap);
DeleteFile(dat->ppro->m_szPhotoFileName);
@@ -376,8 +376,6 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
else DeleteFile(szTempFileName);
-
- mir_free(pszTemp);
}
else DeleteFile(szTempFileName);
}
diff --git a/protocols/Tlen/src/tlen_picture.cpp b/protocols/Tlen/src/tlen_picture.cpp index adfd6ea1ca..ea3fb7e2bb 100644 --- a/protocols/Tlen/src/tlen_picture.cpp +++ b/protocols/Tlen/src/tlen_picture.cpp @@ -260,7 +260,7 @@ BOOL SendPicture(TlenProtocol *proto, MCONTACT hContact) { char *jid = dbv.pszVal;
TCHAR tszFilter[512], tszFileName[MAX_PATH];
- BmpFilterGetStrings(tszFilter, SIZEOF(tszFilter));
+ Bitmap_GetFilter(tszFilter, SIZEOF(tszFilter));
tszFileName[0] = '\0';
OPENFILENAME ofn = {0};
diff --git a/protocols/WhatsApp/src/avatars.cpp b/protocols/WhatsApp/src/avatars.cpp index 35feb6d1ad..22266ae931 100644 --- a/protocols/WhatsApp/src/avatars.cpp +++ b/protocols/WhatsApp/src/avatars.cpp @@ -90,7 +90,7 @@ int WhatsAppProto::InternalSetAvatar(MCONTACT hContact, const char *szJid, const return errno;
ResizeBitmap resize = { 0 };
- if ((resize.hBmp = (HBITMAP)CallService(MS_UTILS_LOADBITMAPT, 0, (LPARAM)ptszFileName)) == NULL)
+ if ((resize.hBmp = Bitmap_Load(ptszFileName)) == NULL)
return 2;
resize.size = sizeof(resize);
resize.fit = RESIZEBITMAP_KEEP_PROPORTIONS;
diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp index 1910128775..9a80485c3f 100644 --- a/protocols/WhatsApp/src/chat.cpp +++ b/protocols/WhatsApp/src/chat.cpp @@ -166,7 +166,7 @@ void WhatsAppProto::EditChatSubject(WAChatInfo *pInfo) void WhatsAppProto::SetChatAvatar(WAChatInfo *pInfo)
{
TCHAR tszFileName[MAX_PATH], filter[256];
- BmpFilterGetStrings(filter, SIZEOF(filter));
+ Bitmap_GetFilter(filter, SIZEOF(filter));
OPENFILENAME ofn = { 0 };
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
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 <m_imgsrvc.h>
+
+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 @@ <ClCompile Include="modules\srmm\statusicon.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
- <ClCompile Include="modules\utils\bmpfilter.cpp">
- <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
- </ClCompile>
<ClCompile Include="modules\utils\colourpicker.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
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 @@ <ClCompile Include="modules\skin\sounds.cpp">
<Filter>Modules\skin</Filter>
</ClCompile>
- <ClCompile Include="modules\utils\bmpfilter.cpp">
- <Filter>Modules\utils</Filter>
- </ClCompile>
<ClCompile Include="modules\utils\colourpicker.cpp">
<Filter>Modules\utils</Filter>
</ClCompile>
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 @@ <ClCompile Include="modules\srmm\statusicon.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
- <ClCompile Include="modules\utils\bmpfilter.cpp">
- <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
- </ClCompile>
<ClCompile Include="modules\utils\colourpicker.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
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 @@ <ClCompile Include="modules\skin\sounds.cpp">
<Filter>Modules\skin</Filter>
</ClCompile>
- <ClCompile Include="modules\utils\bmpfilter.cpp">
- <Filter>Modules\utils</Filter>
- </ClCompile>
<ClCompile Include="modules\utils\colourpicker.cpp">
<Filter>Modules\utils</Filter>
</ClCompile>
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 <olectl.h>
-
-#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();
|