From 97ef8e8d0ee063315aeae5c29abcdc53563c0431 Mon Sep 17 00:00:00 2001 From: maple! Date: Thu, 10 Aug 2023 15:32:47 +0200 Subject: Fix transparency in skin icon QPainter has a bug where drawing transparency to a freshly initialized, empty QPixmap causes garbage data to be drawn. This broke the rendering of the skin icon. The fix is simply to fill the QPixmap with empty transparent pixels beforehand. Signed-off-by: maple! --- launcher/SkinUtils.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'launcher/SkinUtils.cpp') diff --git a/launcher/SkinUtils.cpp b/launcher/SkinUtils.cpp index 20d3b52e..15be1cec 100644 --- a/launcher/SkinUtils.cpp +++ b/launcher/SkinUtils.cpp @@ -35,6 +35,7 @@ QPixmap getFaceFromCache(QString username, int height, int width) QPixmap skinTexture(fskin.fileName()); if (!skinTexture.isNull()) { QPixmap skin = QPixmap(8, 8); + skin.fill(QColorConstants::Transparent); QPainter painter(&skin); painter.drawPixmap(0, 0, skinTexture.copy(8, 8, 8, 8)); painter.drawPixmap(0, 0, skinTexture.copy(40, 8, 8, 8)); -- cgit From 73adac2501eb2279523531da9d04f514ab614853 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Thu, 10 Aug 2023 20:25:01 +0200 Subject: fix: use QColorConstants in Qt 5.14+ Signed-off-by: Sefa Eyeoglu --- launcher/SkinUtils.cpp | 4 ++++ launcher/minecraft/auth/MinecraftAccount.cpp | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'launcher/SkinUtils.cpp') diff --git a/launcher/SkinUtils.cpp b/launcher/SkinUtils.cpp index 15be1cec..989114ad 100644 --- a/launcher/SkinUtils.cpp +++ b/launcher/SkinUtils.cpp @@ -35,7 +35,11 @@ QPixmap getFaceFromCache(QString username, int height, int width) QPixmap skinTexture(fskin.fileName()); if (!skinTexture.isNull()) { QPixmap skin = QPixmap(8, 8); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) skin.fill(QColorConstants::Transparent); +#else + skin.fill(QColor(0, 0, 0, 0)); +#endif QPainter painter(&skin); painter.drawPixmap(0, 0, skinTexture.copy(8, 8, 8, 8)); painter.drawPixmap(0, 0, skinTexture.copy(40, 8, 8, 8)); diff --git a/launcher/minecraft/auth/MinecraftAccount.cpp b/launcher/minecraft/auth/MinecraftAccount.cpp index 79213fe9..6c2f0805 100644 --- a/launcher/minecraft/auth/MinecraftAccount.cpp +++ b/launcher/minecraft/auth/MinecraftAccount.cpp @@ -37,6 +37,7 @@ #include "MinecraftAccount.h" +#include #include #include #include @@ -126,7 +127,11 @@ QPixmap MinecraftAccount::getFace() const return QPixmap(); } QPixmap skin = QPixmap(8, 8); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) skin.fill(QColorConstants::Transparent); +#else + skin.fill(QColor(0, 0, 0, 0)); +#endif QPainter painter(&skin); painter.drawPixmap(0, 0, skinTexture.copy(8, 8, 8, 8)); painter.drawPixmap(0, 0, skinTexture.copy(40, 8, 8, 8)); -- cgit