parent
8a898bae3f
commit
5908166a63
|
@ -16,8 +16,9 @@
|
||||||
|
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <memory>
|
||||||
#include "ImageListSet.h"
|
#include "ImageListSet.h"
|
||||||
|
#include "NppDarkMode.h"
|
||||||
|
|
||||||
void IconList::init(HINSTANCE hInst, int iconSize)
|
void IconList::init(HINSTANCE hInst, int iconSize)
|
||||||
{
|
{
|
||||||
|
@ -122,12 +123,87 @@ void ToolBarIcons::reInit(int size)
|
||||||
_iconListVector[HLIST_DEFAULT2].addIcon(i._hIcon);
|
_iconListVector[HLIST_DEFAULT2].addIcon(i._hIcon);
|
||||||
_iconListVector[HLIST_DISABLE2].addIcon(i._hIcon);
|
_iconListVector[HLIST_DISABLE2].addIcon(i._hIcon);
|
||||||
|
|
||||||
|
if (i._hIcon_DM)
|
||||||
|
{
|
||||||
_iconListVector[HLIST_DEFAULT_DM].addIcon(i._hIcon_DM ? i._hIcon_DM : i._hIcon);
|
_iconListVector[HLIST_DEFAULT_DM].addIcon(i._hIcon_DM ? i._hIcon_DM : i._hIcon);
|
||||||
_iconListVector[HLIST_DISABLE_DM].addIcon(i._hIcon_DM ? i._hIcon_DM : i._hIcon);
|
_iconListVector[HLIST_DISABLE_DM].addIcon(i._hIcon_DM ? i._hIcon_DM : i._hIcon);
|
||||||
_iconListVector[HLIST_DEFAULT_DM2].addIcon(i._hIcon_DM ? i._hIcon_DM : i._hIcon);
|
_iconListVector[HLIST_DEFAULT_DM2].addIcon(i._hIcon_DM ? i._hIcon_DM : i._hIcon);
|
||||||
_iconListVector[HLIST_DISABLE_DM2].addIcon(i._hIcon_DM ? i._hIcon_DM : i._hIcon);
|
_iconListVector[HLIST_DISABLE_DM2].addIcon(i._hIcon_DM ? i._hIcon_DM : i._hIcon);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ICONINFO iconinfoSrc;
|
||||||
|
GetIconInfo(i._hIcon, &iconinfoSrc);
|
||||||
|
|
||||||
|
HDC dcScreen = ::GetDC(NULL);
|
||||||
|
|
||||||
|
BITMAP bmp;
|
||||||
|
::GetObject(iconinfoSrc.hbmColor, sizeof(BITMAP), &bmp);
|
||||||
|
|
||||||
|
BITMAPINFOHEADER bi = { 0 };
|
||||||
|
|
||||||
|
bi.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
bi.biWidth = bmp.bmWidth;
|
||||||
|
bi.biHeight = bmp.bmHeight;
|
||||||
|
bi.biPlanes = 1;
|
||||||
|
bi.biBitCount = 32;
|
||||||
|
bi.biCompression = BI_RGB;
|
||||||
|
bi.biSizeImage = 0;
|
||||||
|
bi.biXPelsPerMeter = 0;
|
||||||
|
bi.biYPelsPerMeter = 0;
|
||||||
|
bi.biClrUsed = 0;
|
||||||
|
bi.biClrImportant = 0;
|
||||||
|
|
||||||
|
DWORD dwLineSize = ((bmp.bmWidth * bi.biBitCount + 31) / 32) * 4;
|
||||||
|
DWORD dwBmpSize = dwLineSize * bmp.bmHeight;
|
||||||
|
|
||||||
|
std::unique_ptr<BYTE[]> dibits(new BYTE[dwBmpSize]);
|
||||||
|
|
||||||
|
GetDIBits(dcScreen, iconinfoSrc.hbmColor, 0, bi.biHeight, dibits.get(), (BITMAPINFO*)&bi, DIB_RGB_COLORS);
|
||||||
|
|
||||||
|
for (int scanLine = 0; scanLine < bi.biHeight; ++scanLine)
|
||||||
|
{
|
||||||
|
BYTE* rawLine = dibits.get() + (dwLineSize * scanLine);
|
||||||
|
RGBQUAD* pLine = (RGBQUAD*)rawLine;
|
||||||
|
|
||||||
|
for (int pixel = 0; pixel < bi.biWidth; ++pixel)
|
||||||
|
{
|
||||||
|
RGBQUAD rgba = pLine[pixel];
|
||||||
|
|
||||||
|
COLORREF c = RGB(rgba.rgbRed, rgba.rgbGreen, rgba.rgbBlue);
|
||||||
|
COLORREF invert = NppDarkMode::invertLightness(c);
|
||||||
|
|
||||||
|
rgba.rgbRed = GetRValue(invert);
|
||||||
|
rgba.rgbBlue = GetBValue(invert);
|
||||||
|
rgba.rgbGreen = GetGValue(invert);
|
||||||
|
|
||||||
|
pLine[pixel] = rgba;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HBITMAP hBmpNew = ::CreateCompatibleBitmap(dcScreen, bmp.bmWidth, bmp.bmHeight);
|
||||||
|
|
||||||
|
SetDIBits(dcScreen, hBmpNew, 0, bi.biHeight, dibits.get(), (BITMAPINFO*)&bi, DIB_RGB_COLORS);
|
||||||
|
|
||||||
|
::ReleaseDC(NULL, dcScreen);
|
||||||
|
|
||||||
|
ICONINFO iconinfoDest = { 0 };
|
||||||
|
iconinfoDest.fIcon = TRUE;
|
||||||
|
iconinfoDest.hbmColor = hBmpNew;
|
||||||
|
iconinfoDest.hbmMask = iconinfoSrc.hbmMask;
|
||||||
|
|
||||||
|
HICON hIcon = ::CreateIconIndirect(&iconinfoDest);
|
||||||
|
|
||||||
|
::DeleteObject(hBmpNew);
|
||||||
|
::DeleteObject(iconinfoSrc.hbmColor);
|
||||||
|
::DeleteObject(iconinfoSrc.hbmMask);
|
||||||
|
|
||||||
|
_iconListVector[HLIST_DEFAULT_DM].addIcon(hIcon);
|
||||||
|
_iconListVector[HLIST_DISABLE_DM].addIcon(hIcon);
|
||||||
|
_iconListVector[HLIST_DEFAULT_DM2].addIcon(hIcon);
|
||||||
|
_iconListVector[HLIST_DISABLE_DM2].addIcon(hIcon);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue