From cee593c423a63ba8fb47b2fb160303ec87813655 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 21 Apr 2022 15:29:11 +0400 Subject: [PATCH] Check whether notification image has alpha channel --- .../platform/linux/notifications_manager_linux.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 1f4cfe06c..464887bfb 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -679,8 +679,12 @@ void NotificationData::setImage(const QString &imagePath) { return; } - const auto image = QImage(imagePath) - .convertToFormat(QImage::Format_RGBA8888); + const auto image = [&] { + const auto original = QImage(imagePath); + return original.hasAlphaChannel() + ? original.convertToFormat(QImage::Format_RGBA8888) + : original.convertToFormat(QImage::Format_RGB888); + }(); if (image.isNull()) { return; @@ -690,9 +694,9 @@ void NotificationData::setImage(const QString &imagePath) { image.width(), image.height(), int(image.bytesPerLine()), - true, + image.hasAlphaChannel(), 8, - 4, + image.hasAlphaChannel() ? 4 : 3, std::vector( image.constBits(), image.constBits() + image.sizeInBytes()),