MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / createPlaceholderImage

Function createPlaceholderImage

pcsx2-qt/GameList/GameListModel.cpp:34–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32static constexpr int MIN_COVER_CACHE_SIZE = 256;
33
34static QPixmap createPlaceholderImage(const QPixmap& placeholder_pixmap, int width, int height, float scale,
35 qreal dpr, const std::string& title)
36{
37 QPixmap pm(placeholder_pixmap.copy());
38 pm.setDevicePixelRatio(dpr);
39 if (pm.isNull())
40 return QPixmap();
41
42 QtUtils::resizeAndScalePixmap(&pm, width, height, dpr, QtUtils::ScalingMode::Fit, 100);
43 QPainter painter;
44 if (painter.begin(&pm))
45 {
46 QFont font;
47 font.setPointSize(std::max(static_cast<int>(32.0f * scale), 1));
48 painter.setFont(font);
49 painter.setPen(Qt::white);
50
51 const QRect text_rc(0, 0, static_cast<int>(static_cast<float>(width)),
52 static_cast<int>(static_cast<float>(height)));
53 painter.drawText(text_rc, Qt::AlignCenter | Qt::TextWordWrap, QString::fromStdString(title));
54 painter.end();
55 }
56
57 return pm;
58}
59
60std::optional<GameListModel::Column> GameListModel::getColumnIdForName(const std::string_view name)
61{

Callers 1

loadOrGenerateCoverMethod · 0.85

Calls 5

resizeAndScalePixmapFunction · 0.85
setDevicePixelRatioMethod · 0.80
maxFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected