diff --git a/rpcs3/rpcs3qt/gui_settings.cpp b/rpcs3/rpcs3qt/gui_settings.cpp index bd7c53c1fc..aa8bcd9c66 100644 --- a/rpcs3/rpcs3qt/gui_settings.cpp +++ b/rpcs3/rpcs3qt/gui_settings.cpp @@ -141,6 +141,45 @@ QPixmap gui_settings::colorizedPixmap(const QPixmap& old_pixmap, const QColor& o return pixmap; } +QImage gui_settings::GetOpaqueImageArea(const QString& path) +{ + QImage image = QImage(path); + + int w_min = 0; + int w_max = image.width(); + int h_min = 0; + int h_max = image.height(); + + for (int y = 0; y < image.height(); ++y) + { + QRgb *row = (QRgb*)image.scanLine(y); + bool rowFilled = false; + + for (int x = 0; x < image.width(); ++x) + { + if (qAlpha(row[x])) + { + rowFilled = true; + w_min = std::max(w_min, x); + + if (w_max > x) + { + w_max = x; + x = w_min; + } + } + } + + if (rowFilled) + { + h_max = std::min(h_max, y); + h_min = y; + } + } + + return image.copy(QRect(QPoint(w_max, h_max), QPoint(w_min, h_min))); +} + void gui_settings::SetValue(const GUI_SAVE& entry, const QVariant& value) { m_settings.beginGroup(entry.key); diff --git a/rpcs3/rpcs3qt/gui_settings.h b/rpcs3/rpcs3qt/gui_settings.h index b513889d61..651e0c0678 100644 --- a/rpcs3/rpcs3qt/gui_settings.h +++ b/rpcs3/rpcs3qt/gui_settings.h @@ -195,6 +195,7 @@ public: */ static QIcon colorizedIcon(const QIcon& icon, const QColor& oldColor, const QColor& newColor, bool useSpecialMasks = false, bool colorizeAll = false); static QPixmap colorizedPixmap(const QPixmap& old_pixmap, const QColor& oldColor, const QColor& newColor, bool useSpecialMasks = false, bool colorizeAll = false); + static QImage GetOpaqueImageArea(const QString& path); public Q_SLOTS: void Reset(bool removeMeta = false);