diff options
author | George Hazan <george.hazan@gmail.com> | 2015-07-11 20:58:33 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-07-11 20:58:33 +0000 |
commit | 53ed793fb92d7a7175eda46aad41b30228bac44f (patch) | |
tree | 52b1bfbced3cf5c8de74a8368e9f5dfca88c10d6 /src | |
parent | 6559743974a7abb8fb2ce43d30689b95e7fc13f4 (diff) |
unused code removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@14538 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/genmenu.h | 2 | ||||
-rw-r--r-- | src/mir_app/src/icolib.cpp | 33 | ||||
-rw-r--r-- | src/mir_app/src/imgconv.cpp | 95 | ||||
-rw-r--r-- | src/mir_app/src/menu_clist.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/menu_utils.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/miranda.h | 2 |
6 files changed, 27 insertions, 113 deletions
diff --git a/src/mir_app/src/genmenu.h b/src/mir_app/src/genmenu.h index ca58c6936f..1c29b4c6e0 100644 --- a/src/mir_app/src/genmenu.h +++ b/src/mir_app/src/genmenu.h @@ -24,8 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef GENMENU_H
#define GENMENU_H
-//general menu object module
-#include "m_genmenu.h"
/* genmenu structs */
diff --git a/src/mir_app/src/icolib.cpp b/src/mir_app/src/icolib.cpp index e45501ef37..75bc74dba5 100644 --- a/src/mir_app/src/icolib.cpp +++ b/src/mir_app/src/icolib.cpp @@ -151,13 +151,12 @@ static int BytesPerScanLine(int PixelsPerScanline, int BitsPerPixel, int Alignme static int InitializeBitmapInfoHeader(HBITMAP bitmap, BITMAPINFOHEADER* bi)
{
DIBSECTION DS;
- int bytes;
-
DS.dsBmih.biSize = 0;
- bytes = GetObject(bitmap, sizeof(DS), &DS);
- if (bytes == 0) return 1; // Failure
- else if ((bytes >= (sizeof(DS.dsBm) + sizeof(DS.dsBmih))) &&
- (DS.dsBmih.biSize >= DWORD(sizeof(DS.dsBmih))))
+ int bytes = GetObject(bitmap, sizeof(DS), &DS);
+ if (bytes == 0) // Failure
+ return 1;
+
+ if ((bytes >= (sizeof(DS.dsBm) + sizeof(DS.dsBmih))) && (DS.dsBmih.biSize >= DWORD(sizeof(DS.dsBmih))))
*bi = DS.dsBmih;
else {
memset(bi, 0, sizeof(BITMAPINFOHEADER));
@@ -174,39 +173,39 @@ static int InitializeBitmapInfoHeader(HBITMAP bitmap, BITMAPINFOHEADER* bi) return 0; // Success
}
-static int InternalGetDIBSizes(HBITMAP bitmap, int* InfoHeaderSize, int* ImageSize)
+static int InternalGetDIBSizes(HBITMAP bitmap, int *InfoHeaderSize, int *ImageSize)
{
BITMAPINFOHEADER bi;
-
- if (InitializeBitmapInfoHeader(bitmap, &bi)) return 1; // Failure
+ if (InitializeBitmapInfoHeader(bitmap, &bi)) // Failure
+ return 1;
+
+ *InfoHeaderSize = sizeof(bi);
if (bi.biBitCount > 8) {
- *InfoHeaderSize = sizeof(BITMAPINFOHEADER);
if ((bi.biCompression & BI_BITFIELDS) != 0)
*InfoHeaderSize += 12;
}
else {
if (bi.biClrUsed == 0)
- *InfoHeaderSize = sizeof(BITMAPINFOHEADER) +
- sizeof(RGBQUAD) * (int)(1 << bi.biBitCount);
+ *InfoHeaderSize += sizeof(RGBQUAD) * (int)(1 << bi.biBitCount);
else
- *InfoHeaderSize = sizeof(BITMAPINFOHEADER) +
- sizeof(RGBQUAD) * bi.biClrUsed;
+ *InfoHeaderSize += sizeof(RGBQUAD) * bi.biClrUsed;
}
*ImageSize = bi.biSizeImage;
return 0; // Success
}
-static int InternalGetDIB(HBITMAP bitmap, HPALETTE palette, void* bitmapInfo, void* Bits)
+static int InternalGetDIB(HBITMAP bitmap, HPALETTE palette, void *bitmapInfo, void *Bits)
{
- HPALETTE oldPal = 0;
-
if (InitializeBitmapInfoHeader(bitmap, (BITMAPINFOHEADER*)bitmapInfo)) return 1; // Failure
HDC DC = CreateCompatibleDC(0);
+ HPALETTE oldPal;
if (palette) {
oldPal = SelectPalette(DC, palette, FALSE);
RealizePalette(DC);
}
+ else oldPal = NULL;
+
int result = GetDIBits(DC, bitmap, 0, ((BITMAPINFOHEADER*)bitmapInfo)->biHeight, Bits, (BITMAPINFO*)bitmapInfo, DIB_RGB_COLORS) == 0;
if (oldPal) SelectPalette(DC, oldPal, FALSE);
diff --git a/src/mir_app/src/imgconv.cpp b/src/mir_app/src/imgconv.cpp index bf1486b226..8be46a92ef 100644 --- a/src/mir_app/src/imgconv.cpp +++ b/src/mir_app/src/imgconv.cpp @@ -26,93 +26,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. typedef DWORD ARGB;
-void InitBitmapInfo(BITMAPINFO &bmi, const SIZE &size)
+HBITMAP ConvertIconToBitmap(HIMAGELIST hIml, int iconId)
{
- memset(&bmi, 0, sizeof(BITMAPINFO));
+ BITMAPINFO bmi = {};
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biBitCount = 32;
-
- bmi.bmiHeader.biWidth = size.cx;
- bmi.bmiHeader.biHeight = size.cy;
-}
-
-void ConvertToPARGB32(HDC hdc, ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow)
-{
- BITMAPINFO bmi;
- InitBitmapInfo(bmi, sizImage);
-
- void *pvBits = malloc(sizImage.cx * 4 * sizImage.cy);
- if (GetDIBits(hdc, hbmp, 0, bmi.bmiHeader.biHeight, pvBits, &bmi, DIB_RGB_COLORS) == bmi.bmiHeader.biHeight) {
- ULONG cxDelta = cxRow - bmi.bmiHeader.biWidth;
- ARGB *pargbMask = (ARGB *)pvBits;
-
- for (ULONG y = bmi.bmiHeader.biHeight + 1; --y;) {
- for (ULONG x = bmi.bmiHeader.biWidth + 1; --x;) {
- if (*pargbMask++) {
- // transparent pixel
- *pargb++=0;
- }
- else {
- // opaque pixel
- *pargb++ |= 0xFF000000;
- }
- }
-
- pargb += cxDelta;
- }
- }
- free(pvBits);
-}
-
-bool HasAlpha(ARGB *pargb, SIZE& sizImage, int cxRow)
-{
- ULONG cxDelta = cxRow - sizImage.cx;
- for (ULONG y = sizImage.cy; y--;) {
- for (ULONG x = sizImage.cx; x--;) {
- if (*pargb++ & 0xFF000000)
- return true;
- }
- pargb += cxDelta;
- }
-
- return false;
-}
-
-void ConvertBufferToPARGB32(HANDLE hPaintBuffer, HDC hdc, HICON hIcon, SIZE& sizIcon)
-{
- RGBQUAD *prgbQuad;
- int cxRow;
- HRESULT hr = getBufferedPaintBits(hPaintBuffer, &prgbQuad, &cxRow);
- if (SUCCEEDED(hr)) {
- ARGB *pargb = (ARGB *)prgbQuad;
- if (!HasAlpha(pargb, sizIcon, cxRow)) {
- ICONINFO info;
- if (GetIconInfo(hIcon, &info)) {
- if (info.hbmMask)
- ConvertToPARGB32(hdc, pargb, info.hbmMask, sizIcon, cxRow);
-
- DeleteObject(info.hbmColor);
- DeleteObject(info.hbmMask);
- }
- }
- }
-}
-
-HBITMAP ConvertIconToBitmap(HICON hicon, HIMAGELIST hIml, int iconId)
-{
- SIZE sizIcon;
- sizIcon.cx = g_iIconSX;
- sizIcon.cy = g_iIconSY;
-
- RECT rcIcon = { 0, 0, sizIcon.cx, sizIcon.cy };
+ bmi.bmiHeader.biWidth = g_iIconSX;
+ bmi.bmiHeader.biHeight = g_iIconSY;
HDC hdc = CreateCompatibleDC(NULL);
-
- BITMAPINFO bmi;
- InitBitmapInfo(bmi, sizIcon);
-
HBITMAP hbmp = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, NULL, NULL, 0);
HBITMAP hbmpOld = (HBITMAP)SelectObject(hdc, hbmp);
@@ -123,17 +47,10 @@ HBITMAP ConvertIconToBitmap(HICON hicon, HIMAGELIST hIml, int iconId) paintParams.pBlendFunction = &bfAlpha;
HDC hdcBuffer;
+ RECT rcIcon = { 0, 0, g_iIconSX, g_iIconSY };
HANDLE hPaintBuffer = beginBufferedPaint(hdc, &rcIcon, BPBF_DIB, &paintParams, &hdcBuffer);
if (hPaintBuffer) {
- if (hIml)
- ImageList_Draw(hIml, iconId, hdc, 0, 0, ILD_TRANSPARENT);
- else
- DrawIconEx(hdcBuffer, 0, 0, hicon, sizIcon.cx, sizIcon.cy, 0, NULL, DI_NORMAL);
-
- // If icon did not have an alpha channel we need to convert buffer to PARGB
- ConvertBufferToPARGB32(hPaintBuffer, hdc, hicon, sizIcon);
-
- // This will write the buffer contents to the destination bitmap
+ ImageList_Draw(hIml, iconId, hdc, 0, 0, ILD_TRANSPARENT);
endBufferedPaint(hPaintBuffer, TRUE);
}
diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp index b3c70c5c4d..18afbc785a 100644 --- a/src/mir_app/src/menu_clist.cpp +++ b/src/mir_app/src/menu_clist.cpp @@ -472,19 +472,19 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) timiParent = MO_GetIntMenuItem(pimi->mi.root);
- MenuItemData it = { 0 };
+ MenuItemData it = {};
if (FindMenuHandleByGlobalID(hStatusMenu, timiParent, &it)) {
TCHAR d[100];
GetMenuString(it.OwnerMenu, it.position, d, _countof(d), MF_BYPOSITION);
- MENUITEMINFO mii = { 0 };
+ MENUITEMINFO mii = {};
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING | MIIM_STATE;
if (pimi->iconId != -1) {
mii.fMask |= MIIM_BITMAP;
if (IsWinVerVistaPlus() && IsThemeActive()) {
if (pimi->hBmp == NULL)
- pimi->hBmp = ConvertIconToBitmap(NULL, pimi->parent->m_hMenuIcons, pimi->iconId);
+ pimi->hBmp = ConvertIconToBitmap(pimi->parent->m_hMenuIcons, pimi->iconId);
mii.hbmpItem = pimi->hBmp;
}
else mii.hbmpItem = HBMMENU_CALLBACK;
diff --git a/src/mir_app/src/menu_utils.cpp b/src/mir_app/src/menu_utils.cpp index ba2917a6d0..a0e278981d 100644 --- a/src/mir_app/src/menu_utils.cpp +++ b/src/mir_app/src/menu_utils.cpp @@ -928,7 +928,7 @@ static HMENU BuildRecursiveMenu(HMENU hMenu, TMO_IntMenuItem *pRootMenu, WPARAM mii.fMask |= MIIM_BITMAP;
if (IsWinVerVistaPlus() && IsThemeActive()) {
if (pmi->hBmp == NULL)
- pmi->hBmp = ConvertIconToBitmap(NULL, pmi->parent->m_hMenuIcons, pmi->iconId);
+ pmi->hBmp = ConvertIconToBitmap(pmi->parent->m_hMenuIcons, pmi->iconId);
mii.hbmpItem = pmi->hBmp;
}
else mii.hbmpItem = HBMMENU_CALLBACK;
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index 7bae22e83c..1d7024a2bb 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -173,7 +173,7 @@ INT_PTR stubChainRecv(WPARAM, LPARAM); void HotkeyToName(TCHAR *buf, int size, BYTE shift, BYTE key);
WORD GetHotkeyValue(INT_PTR idHotkey);
-HBITMAP ConvertIconToBitmap(HICON hIcon, HIMAGELIST hIml, int iconId);
+HBITMAP ConvertIconToBitmap(HIMAGELIST hIml, int iconId);
///////////////////////////////////////////////////////////////////////////////
|