2017-12-31 12:33:36 -07:00
|
|
|
// Copyright 2018 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-12-31 12:33:36 -07:00
|
|
|
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/QtUtils/ImageConverter.h"
|
2017-12-31 12:33:36 -07:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <QPixmap>
|
|
|
|
|
|
|
|
#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<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);
|
|
|
|
}
|