ImageConverter.cpp 789 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2018 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "DolphinQt/QtUtils/ImageConverter.h"
  4. #include <vector>
  5. #include <QPixmap>
  6. #include "Common/CommonTypes.h"
  7. #include "UICommon/GameFile.h"
  8. QPixmap ToQPixmap(const UICommon::GameBanner& banner)
  9. {
  10. return ToQPixmap(banner.buffer, banner.width, banner.height);
  11. }
  12. QPixmap ToQPixmap(const std::vector<u32>& buffer, int width, int height)
  13. {
  14. QImage image(width, height, QImage::Format_RGB888);
  15. for (int y = 0; y < height; y++)
  16. {
  17. for (int x = 0; x < width; x++)
  18. {
  19. const u32 color = buffer[y * width + x];
  20. image.setPixel(
  21. x, y, qRgb((color & 0xFF0000) >> 16, (color & 0x00FF00) >> 8, (color & 0x0000FF) >> 0));
  22. }
  23. }
  24. return QPixmap::fromImage(image);
  25. }