From 9c3c74d055bbf7998ab2acff49e87ef09d0e41a6 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 10 Aug 2025 10:52:10 +0300 Subject: [PATCH] fix: ensure correct skin format Signed-off-by: Trial97 --- launcher/minecraft/skins/SkinModel.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/launcher/minecraft/skins/SkinModel.cpp b/launcher/minecraft/skins/SkinModel.cpp index 209207215..f3d865ea8 100644 --- a/launcher/minecraft/skins/SkinModel.cpp +++ b/launcher/minecraft/skins/SkinModel.cpp @@ -23,10 +23,16 @@ #include "FileSystem.h" #include "Json.h" -static QImage improveSkin(const QImage& skin) +static QImage improveSkin(QImage skin) { + // It seems some older skins may use this format, which can't be drawn onto + // https://github.com/PrismLauncher/PrismLauncher/issues/4032 + // https://doc.qt.io/qt-6/qpainter.html#begin + if (skin.format() == QImage::Format_Indexed8) { + skin = skin.convertToFormat(QImage::Format_RGB32); + } if (skin.size() == QSize(64, 32)) { // old format - QImage newSkin = QImage(QSize(64, 64), skin.format()); + auto newSkin = QImage(QSize(64, 64), skin.format()); newSkin.fill(Qt::transparent); QPainter p(&newSkin); p.drawImage(QPoint(0, 0), skin.copy(QRect(0, 0, 64, 32))); // copy head @@ -110,7 +116,7 @@ SkinModel::SkinModel(QDir skinDir, QJsonObject obj) m_model = Model::SLIM; } m_path = skinDir.absoluteFilePath(name) + ".png"; - m_texture = QImage(getSkin(m_path)); + m_texture = getSkin(m_path); m_preview = generatePreviews(m_texture, m_model == Model::SLIM); }