Compare commits

...

2 Commits

Author SHA1 Message Date
Tilka
ec5b4ecaac
Merge 61e8fa060b into 1786e34bd3 2025-06-08 01:29:34 +02:00
Tillmann Karras
61e8fa060b QtUtils/ImageConverter: simplify 2025-06-07 23:06:07 +01:00
2 changed files with 3 additions and 25 deletions

View File

@ -3,30 +3,13 @@
#include "DolphinQt/QtUtils/ImageConverter.h" #include "DolphinQt/QtUtils/ImageConverter.h"
#include <vector>
#include <QPixmap> #include <QPixmap>
#include "Common/CommonTypes.h"
#include "UICommon/GameFile.h" #include "UICommon/GameFile.h"
QPixmap ToQPixmap(const UICommon::GameBanner& banner) QPixmap ToQPixmap(const UICommon::GameBanner& banner)
{ {
return ToQPixmap(banner.buffer, banner.width, banner.height); const auto* ptr = reinterpret_cast<const uchar*>(banner.buffer.data());
} QImage image(ptr, banner.width, banner.height, QImage::Format_RGBX8888);
return QPixmap::fromImage(std::move(image).rgbSwapped());
QPixmap ToQPixmap(const std::vector<u32>& 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);
} }

View File

@ -3,10 +3,6 @@
#pragma once #pragma once
#include <vector>
#include "Common/CommonTypes.h"
class QPixmap; class QPixmap;
namespace UICommon namespace UICommon
@ -15,4 +11,3 @@ struct GameBanner;
} }
QPixmap ToQPixmap(const UICommon::GameBanner& banner); QPixmap ToQPixmap(const UICommon::GameBanner& banner);
QPixmap ToQPixmap(const std::vector<u32>& buffer, int width, int height);