Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
krlvm committed Mar 17, 2023
1 parent 01b012c commit 443bcc6
Show file tree
Hide file tree
Showing 16 changed files with 350 additions and 347 deletions.
6 changes: 3 additions & 3 deletions AccentColorizer/AccentColorHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "AccentColorHelper.h"
#include "ColorHelper.h"

COLORREF accent;
COLORREF g_dwAccent;

bool UpdateAccentColors()
{
Expand All @@ -12,11 +12,11 @@ bool UpdateAccentColors()

DWORD dwAccent = RGB2BGR(dwAccentRGB);

if (accent == dwAccent)
if (g_dwAccent == dwAccent)
{
return false;
}

accent = dwAccent;
g_dwAccent = dwAccent;
return true;
}
2 changes: 1 addition & 1 deletion AccentColorizer/AccentColorHelper.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include "framework.h"

extern COLORREF accent;
extern COLORREF g_dwAccent;

bool UpdateAccentColors();
4 changes: 0 additions & 4 deletions AccentColorizer/AccentColorizer.h

This file was deleted.

3 changes: 1 addition & 2 deletions AccentColorizer/AccentColorizer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="AccentColorHelper.h" />
<ClInclude Include="AccentColorizer.h" />
<ClInclude Include="BitmapHelper.h" />
<ClInclude Include="ColorHelper.h" />
<ClInclude Include="SettingsHelper.h" />
Expand All @@ -230,7 +229,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="AccentColorHelper.cpp" />
<ClCompile Include="AccentColorizer.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="BitmapHelper.cpp" />
<ClCompile Include="ColorHelper.cpp" />
<ClCompile Include="SettingsHelper.cpp" />
Expand Down
5 changes: 1 addition & 4 deletions AccentColorizer/AccentColorizer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ClCompile Include="AccentColorHelper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AccentColorizer.cpp">
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="BitmapHelper.cpp">
Expand All @@ -30,9 +30,6 @@
<ClInclude Include="AccentColorHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AccentColorizer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BitmapHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
8 changes: 4 additions & 4 deletions AccentColorizer/BitmapHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ bool RecolorizeBitmap(HBITMAP hbm, BitmapHandler handler) {

if (!hbm || bm.bmBitsPixel != 32)
{
return FALSE;
return false;
}

BYTE* pBits = new BYTE[bm.bmWidth * bm.bmHeight * 4];
GetBitmapBits(hbm, bm.bmWidth * bm.bmHeight * 4, pBits);

for (int y = 0; y < bm.bmHeight; y++)
{
BYTE* pPixel = (BYTE*)pBits + bm.bmWidth * 4 * y;
BYTE* pPixel = pBits + bm.bmWidth * 4 * y;

for (int x = 0; x < bm.bmWidth; x++)
{
Expand All @@ -47,7 +47,7 @@ bool RecolorizeBitmap(HBITMAP hbm, BitmapHandler handler) {
int b = PixB(pPixel); // [0]
int a = PixA(pPixel); // [3]

handler(&r, &g, &b, &a);
handler(r, g, b, a);

pPixel[2] = r;
pPixel[1] = g;
Expand All @@ -61,5 +61,5 @@ bool RecolorizeBitmap(HBITMAP hbm, BitmapHandler handler) {
SetBitmapBits(hbm, bm.bmWidth * bm.bmHeight * 4, pBits);

delete[] pBits;
return TRUE;
return true;
}
2 changes: 1 addition & 1 deletion AccentColorizer/BitmapHelper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "framework.h"

typedef void (*BitmapHandler)(int* r, int* g, int* b, int* a);
typedef void (*BitmapHandler)(int& r, int& g, int& b, int& a);
bool RecolorizeBitmap(HBITMAP hbm, BitmapHandler handler);
12 changes: 6 additions & 6 deletions AccentColorizer/ColorHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ hsv rgb2hsv(rgb in)
// if max is 0, then r = g = b = 0
// s = 0, h is undefined
out.s = 0.0;
out.h = NAN; // its now undefined
//out.h = NAN; // its now undefined
return out;
}
if (in.r >= max) // > is bogus, just keeps compilor happy
Expand Down Expand Up @@ -107,11 +107,11 @@ rgb hsv2rgb(hsv in)

int GetHSVh(COLORREF dwColor)
{
rgb rgbVal = {
return rgb2hsv(
{
(double)GetRValue(dwColor),
(double)GetGValue(dwColor),
(double)GetBValue(dwColor)
};
hsv hsvVal = rgb2hsv(rgbVal);
return hsvVal.h;
(double)GetBValue(dwColor)
}
).h;
}
10 changes: 6 additions & 4 deletions AccentColorizer/SettingsHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "SettingsHelper.h"
#include "SystemHelper.h"
#include <VersionHelpers.h>

bool IsRegistryValueEnabled(LPCWSTR key, LPCWSTR value)
Expand All @@ -11,7 +12,7 @@ bool IsRegistryValueEnabled(LPCWSTR key, LPCWSTR value)

if (!hKey)
{
return FALSE;
return false;
}

DWORD dwBufferSize(sizeof(DWORD));
Expand All @@ -24,15 +25,16 @@ bool IsRegistryValueEnabled(LPCWSTR key, LPCWSTR value)

RegCloseKey(hKey);

return ERROR_SUCCESS == nError ? nResult : FALSE;
return ERROR_SUCCESS == nError ? nResult : false;
}

bool IsMenuColorizationEnabled()
{
if (!IsWindows10OrGreater())
if (g_winver < WIN_10)
{
return TRUE;
return true;
}

return INVALID_FILE_ATTRIBUTES == GetFileAttributes(L"C:\\Windows\\ContextMenuNormalizer.exe")
&& GetLastError() == ERROR_FILE_NOT_FOUND;
}
Expand Down
Loading

0 comments on commit 443bcc6

Please sign in to comment.