various fixes

This commit is contained in:
Geoffray Levasseur committed 2026-11-03 10:38:49 +01:00
1 parent ef2e1b4680
commit d1074096aa
2 files changed
+21 -4

No files matched your search

+17 -4
View File
@@ -51,6 +51,11 @@ QColor colorFromDelphi(int value)
return QColor(value & 0xFF, (value >> 8) & 0xFF, (value >> 16) & 0xFF);
}
int colorToDelphi(const QColor &color)
{
return color.red() | (color.green() << 8) | (color.blue() << 16);
}
int gamma = 100;
GraphicSets grExt;
QString graphicsDir;
@@ -124,14 +129,22 @@ GraphicSet *loadGraphicSet(const QString &name, bool transparency)
return result;
result = &grExt.addNew(name);
const QString fileName = graphicsDir + QLatin1Char('/') + name;
const QString baseFileName = graphicsDir + QLatin1Char('/') + name;
// The original's LoadGraphicFile auto-appends ".png" when the name has
// no extension, but that is a by-value parameter so it does NOT affect
// the (possibly extension-less) base name used below for the .grs
// sidecar path - replicate both quirks exactly.
QString imageFileName = baseFileName;
if (QFileInfo(imageFileName).suffix().isEmpty())
imageFileName += QLatin1String(".png");
// Do not apply gamma during file load as it would affect transparency colors too.
result->data.loadFromFile(fileName);
result->data.loadFromFile(imageFileName);
if (result->data.width() == 0 || result->data.height() == 0)
return nullptr;
const QString grsFileName = QFileInfo(fileName).path() + QLatin1Char('/') +
QFileInfo(fileName).completeBaseName() + QLatin1String(GraphicSetFileExt);
const QFileInfo baseInfo(baseFileName);
const QString grsFileName = baseInfo.path() + QLatin1Char('/') +
baseInfo.completeBaseName() + QLatin1String(GraphicSetFileExt);
if (QFileInfo::exists(grsFileName))
result->loadFromFile(grsFileName);