Skip to content

Commit

Permalink
Tab indent
Browse files Browse the repository at this point in the history
  • Loading branch information
lededev committed Nov 19, 2024
1 parent 1531235 commit 4ef3caf
Showing 1 changed file with 43 additions and 44 deletions.
87 changes: 43 additions & 44 deletions Src/TitleBarHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,50 +338,49 @@ void CTitleBarHelper::ReloadAccentColor()

HICON CTitleBarHelper::CreateGrayIcon(HICON hIcon)
{
ICONINFO iconInfo;
GetIconInfo(hIcon, &iconInfo);

BITMAP bitmap;
GetObject(iconInfo.hbmColor, sizeof(BITMAP), &bitmap);
const int width = bitmap.bmWidth;
const int height = bitmap.bmHeight;
const int pixsize = width * height;

BITMAPINFO bmi;
ZeroMemory(&bmi, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = height;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;

RGBQUAD* pixels = new RGBQUAD[pixsize];
HDC hdc = GetDC(NULL);
GetDIBits(hdc, iconInfo.hbmColor, 0, height, pixels, &bmi, DIB_RGB_COLORS);

for (int i = 0; i < pixsize; i++)
{
BYTE gray = (BYTE)(0.3 * pixels[i].rgbRed + 0.59 * pixels[i].rgbGreen + 0.11 * pixels[i].rgbBlue);
pixels[i].rgbRed = gray;
pixels[i].rgbGreen = gray;
pixels[i].rgbBlue = gray;
}

HBITMAP hbmGray = CreateCompatibleBitmap(hdc, width, height);
SetDIBits(hdc, hbmGray, 0, height, pixels, &bmi, DIB_RGB_COLORS);

ICONINFO grayIconInfo = iconInfo;
grayIconInfo.hbmColor = hbmGray;
HICON hGrayIcon = CreateIconIndirect(&grayIconInfo);

DeleteObject(iconInfo.hbmColor);
DeleteObject(iconInfo.hbmMask);
DeleteObject(hbmGray);
ReleaseDC(NULL, hdc);
delete[] pixels;

return hGrayIcon;
ICONINFO iconInfo;
GetIconInfo(hIcon, &iconInfo);

BITMAP bitmap;
GetObject(iconInfo.hbmColor, sizeof(BITMAP), &bitmap);
const int width = bitmap.bmWidth;
const int height = bitmap.bmHeight;
const int pixsize = width * height;

BITMAPINFO bmi = {0};
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = height;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;

RGBQUAD* pixels = new RGBQUAD[pixsize];
HDC hdc = GetDC(NULL);
GetDIBits(hdc, iconInfo.hbmColor, 0, height, pixels, &bmi, DIB_RGB_COLORS);

for (int i = 0; i < pixsize; i++)
{
BYTE gray = (BYTE)(0.3 * pixels[i].rgbRed + 0.59 * pixels[i].rgbGreen + 0.11 * pixels[i].rgbBlue);
pixels[i].rgbRed = gray;
pixels[i].rgbGreen = gray;
pixels[i].rgbBlue = gray;
}

HBITMAP hbmGray = CreateCompatibleBitmap(hdc, width, height);
SetDIBits(hdc, hbmGray, 0, height, pixels, &bmi, DIB_RGB_COLORS);

ICONINFO grayIconInfo = iconInfo;
grayIconInfo.hbmColor = hbmGray;
HICON hGrayIcon = CreateIconIndirect(&grayIconInfo);

DeleteObject(iconInfo.hbmColor);
DeleteObject(iconInfo.hbmMask);
DeleteObject(hbmGray);
ReleaseDC(NULL, hdc);
delete[] pixels;

return hGrayIcon;
}

void CTitleBarHelper::LazyLoadIcon(CWnd* pWnd)
Expand Down

0 comments on commit 4ef3caf

Please sign in to comment.