Skip to content

Commit 8688677

Browse files
committed
Fix low-color icon loading bug
1 parent 58830b7 commit 8688677

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

3RVX/Skin.cpp

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#include "Skin.h"
22

33
#include <algorithm>
4+
#include <CommCtrl.h>
45
#include <memory>
56
#include <vector>
67
#include <Shlwapi.h>
78

9+
#include "CommCtl.h"
810
#include "Error.h"
911
#include "MeterWnd/Meters/MeterTypes.h"
1012
#include "StringUtils.h"
@@ -170,20 +172,25 @@ std::vector<HICON> Skin::Iconset(char *osdName) {
170172
continue;
171173
}
172174

173-
QCLOG(L"%s", (iconDir + iconName).c_str());
174-
Gdiplus::Bitmap *iconBmp = Gdiplus::Bitmap::FromFile(
175-
(iconDir + iconName).c_str());
176-
if (iconBmp == NULL) {
177-
CLOG(L"Failed to load icon!");
175+
std::wstring iconPath = iconDir + iconName;
176+
std::wstring ext = StringUtils::FileExtension(iconName);
177+
if (ext != L"ico") {
178+
QCLOG(L"Ignoring non-ico file: %s", iconPath.c_str());
179+
continue;
178180
}
179181

180-
HICON icon;
181-
if (iconBmp->GetHICON(&icon) == Gdiplus::Status::Ok) {
182+
HICON icon = NULL;
183+
HRESULT hr = LoadIconMetric(
184+
NULL,
185+
iconPath.c_str(),
186+
LIM_SMALL,
187+
&icon);
188+
189+
if (icon != NULL) {
190+
QCLOG(L"%s", iconPath.c_str());
182191
iconset.push_back(icon);
183192
}
184193

185-
delete iconBmp;
186-
187194
} while (FindNextFile(hFind, &fd));
188195
FindClose(hFind);
189196

0 commit comments

Comments
 (0)