Commit cba20605 authored by Stefan Brüns's avatar Stefan Brüns
Browse files

[ExeThumbnailer] Remove irrelevant iconNumber parameter

The application icon is stored in the first GROUP_ICON resource, see
https://docs.microsoft.com/en-us/windows/win32/menurc/about-icons#icon-display

Remove the iconNumber parameter, as the functions are always called with
the default value of 0.
parent 1a1e5c98
......@@ -27,9 +27,9 @@ class QImageReader;
namespace IcoUtils
{
bool loadIcoImageFromExe(QIODevice * inputDevice, QImage &image, int needWidth=512, int needHeight=512, const qint32 iconNumber=0);
bool loadIcoImageFromExe(const QString &inputPath, QImage &image, int needWidth=512, int needHeight=512, const qint32 iconNumber=0);
bool loadIcoImageFromExe(const QString &inputFileName, QIODevice *outputDevice, const qint32 iconNumber);
bool loadIcoImageFromExe(QIODevice * inputDevice, QImage &image, int needWidth=512, int needHeight=512);
bool loadIcoImageFromExe(const QString &inputPath, QImage &image, int needWidth=512, int needHeight=512);
bool loadIcoImageFromExe(const QString &inputFileName, QIODevice *outputDevice);
bool loadIcoImage(QIODevice * inputDevice, QImage &image, int needWidth=512, int needHeight=512);
bool loadIcoImage(const QString &inputFileName, QImage &image, int needWidth=512, int needHeight=512);
......
......@@ -45,7 +45,7 @@ qreal distance(int width, int height, int desiredWidth, int desiredHeight, int d
return targetSamples - effectiveSamples;
}
bool IcoUtils::loadIcoImageFromExe(QIODevice * inputDevice, QImage &image, int needWidth, int needHeight, const qint32 iconNumber)
bool IcoUtils::loadIcoImageFromExe(QIODevice * inputDevice, QImage &image, int needWidth, int needHeight)
{
QTemporaryFile inputFile;
......@@ -58,18 +58,18 @@ bool IcoUtils::loadIcoImageFromExe(QIODevice * inputDevice, QImage &image, int n
if ( inputFile.write(data) == -1 )
return false;
return IcoUtils::loadIcoImageFromExe(inputFile.fileName(), image, needWidth, needHeight, iconNumber);
return IcoUtils::loadIcoImageFromExe(inputFile.fileName(), image, needWidth, needHeight);
}
bool IcoUtils::loadIcoImageFromExe(const QString &inputFileName, QImage &image, int needWidth, int needHeight, const qint32 iconNumber)
bool IcoUtils::loadIcoImageFromExe(const QString &inputFileName, QImage &image, int needWidth, int needHeight)
{
QBuffer iconData;
if (!iconData.open(QIODevice::ReadWrite)) {
return false;
}
if ( ! IcoUtils::loadIcoImageFromExe(inputFileName, &iconData, iconNumber) )
if ( ! IcoUtils::loadIcoImageFromExe(inputFileName, &iconData) )
return false;
if (!iconData.seek(0)) {
......
......@@ -91,7 +91,7 @@ BOOL CALLBACK enumResNameCallback( HMODULE hModule, LPCTSTR lpszType, LPTSTR lps
return TRUE;
}
bool IcoUtils::loadIcoImageFromExe(const QString &inputFileName, QIODevice *outputDevice, const qint32 iconNumber)
bool IcoUtils::loadIcoImageFromExe(const QString &inputFileName, QIODevice *outputDevice)
{
HMODULE hModule;
......@@ -109,9 +109,9 @@ bool IcoUtils::loadIcoImageFromExe(const QString &inputFileName, QIODevice *outp
EnumResourceNames ( hModule, RT_GROUP_ICON, enumResNameCallback, (LONG_PTR) &iconResources );
if ( iconNumber < iconResources.size() )
if (!iconResources.isEmpty() )
{
HRSRC resourceInfo = FindResourceW ( hModule, (LPCTSTR) iconResources.at(iconNumber), RT_GROUP_ICON );
HRSRC resourceInfo = FindResourceW ( hModule, (LPCTSTR) iconResources.at(0), RT_GROUP_ICON );
if ( resourceInfo == 0 )
{
FreeLibrary( hModule );
......
......@@ -27,7 +27,7 @@
#define abs(n) ( ( n < 0 ) ? -n : n )
typedef QPair < QString, int > IconInExe;
bool IcoUtils::loadIcoImageFromExe(const QString &inputFileName, QIODevice *outputDevice, const qint32 iconNumber)
bool IcoUtils::loadIcoImageFromExe(const QString &inputFileName, QIODevice *outputDevice)
{
QProcess wrestool;
......@@ -66,11 +66,6 @@ bool IcoUtils::loadIcoImageFromExe(const QString &inputFileName, QIODevice *outp
if ( icons.isEmpty() )
return false;
// iconNumber 0 is ambiguous...
if (iconNumber > 0 && iconNumber < icons.count()) {
icons = {icons.at(iconNumber)};
}
for (const IconInExe &icon : qAsConst(icons)) {
QString name = icon.first;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment