From 61e8fa060b93437a88c4260df4d1dd75b5b65d16 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sat, 7 Jun 2025 11:18:27 +0100 Subject: [PATCH] QtUtils/ImageConverter: simplify --- .../Core/DolphinQt/QtUtils/ImageConverter.cpp | 23 +++---------------- .../Core/DolphinQt/QtUtils/ImageConverter.h | 5 ---- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/Source/Core/DolphinQt/QtUtils/ImageConverter.cpp b/Source/Core/DolphinQt/QtUtils/ImageConverter.cpp index cdd9a1c70b..4d00d82c15 100644 --- a/Source/Core/DolphinQt/QtUtils/ImageConverter.cpp +++ b/Source/Core/DolphinQt/QtUtils/ImageConverter.cpp @@ -3,30 +3,13 @@ #include "DolphinQt/QtUtils/ImageConverter.h" -#include - #include -#include "Common/CommonTypes.h" #include "UICommon/GameFile.h" QPixmap ToQPixmap(const UICommon::GameBanner& banner) { - return ToQPixmap(banner.buffer, banner.width, banner.height); -} - -QPixmap ToQPixmap(const std::vector& buffer, int width, int height) -{ - QImage image(width, height, QImage::Format_RGB888); - for (int y = 0; y < height; y++) - { - for (int x = 0; x < width; x++) - { - const u32 color = buffer[y * width + x]; - image.setPixel( - x, y, qRgb((color & 0xFF0000) >> 16, (color & 0x00FF00) >> 8, (color & 0x0000FF) >> 0)); - } - } - - return QPixmap::fromImage(image); + const auto* ptr = reinterpret_cast(banner.buffer.data()); + QImage image(ptr, banner.width, banner.height, QImage::Format_RGBX8888); + return QPixmap::fromImage(std::move(image).rgbSwapped()); } diff --git a/Source/Core/DolphinQt/QtUtils/ImageConverter.h b/Source/Core/DolphinQt/QtUtils/ImageConverter.h index 917c0a4f56..673bc05eb2 100644 --- a/Source/Core/DolphinQt/QtUtils/ImageConverter.h +++ b/Source/Core/DolphinQt/QtUtils/ImageConverter.h @@ -3,10 +3,6 @@ #pragma once -#include - -#include "Common/CommonTypes.h" - class QPixmap; namespace UICommon @@ -15,4 +11,3 @@ struct GameBanner; } QPixmap ToQPixmap(const UICommon::GameBanner& banner); -QPixmap ToQPixmap(const std::vector& buffer, int width, int height);