mirror of
https://github.com/Open-Shell/Open-Shell-Menu.git
synced 2026-06-14 03:16:38 +10:00
Display monochrome icons using color of corresponding text item
Some icons (modern settings, jump-list tasks) are monochrome, basically they are defined just by alpha channel. Thus they can be displayed in any color (white is default). Since these icons are white by default, they look nice on dark backgrounds. But they are not very visible on light backgrounds. Thus the idea is to 'colorize' such icon using color of corresponding text item. That way they will always have proper color. Fixes #466.
This commit is contained in:
@@ -176,6 +176,27 @@ static void CreateMonochromeImage( unsigned int *bits, int stride, int width, in
|
||||
}
|
||||
}
|
||||
|
||||
HBITMAP ColorizeMonochromeImage(HBITMAP bitmap, DWORD color)
|
||||
{
|
||||
{
|
||||
BITMAP info{};
|
||||
GetObject(bitmap, sizeof(info), &info);
|
||||
if (!DetectGrayscaleImage((const unsigned int*)info.bmBits, info.bmWidth, info.bmWidth, info.bmHeight))
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HBITMAP bmp = (HBITMAP)CopyImage(bitmap, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
|
||||
if (bmp)
|
||||
{
|
||||
BITMAP info{};
|
||||
GetObject(bmp, sizeof(info), &info);
|
||||
|
||||
CreateMonochromeImage((unsigned int*)info.bmBits, info.bmWidth, info.bmWidth, info.bmHeight, color);
|
||||
}
|
||||
|
||||
return bmp;
|
||||
}
|
||||
|
||||
static HBITMAP BitmapFromMetroIcon( HICON hIcon, int bitmapSize, int iconSize, DWORD metroColor, bool bDestroyIcon=true )
|
||||
{
|
||||
ICONINFO info;
|
||||
|
||||
Reference in New Issue
Block a user