This commit is contained in:
2026-05-14 22:12:40 +08:00
parent 334845d732
commit 3ba8ba80b3
6 changed files with 252 additions and 69 deletions
+25
View File
@@ -123,4 +123,29 @@ void applyBlackFillToBackground(QImage& bgCutout, const QVector<QPointF>& polyWo
p.end();
}
void applyBlackHolesToImageRegion(QImage& regionPremul, const QRect& cropWorldRect,
const QVector<QVector<QPointF>>& holePolysWorld) {
if (regionPremul.isNull() || !cropWorldRect.isValid()) {
return;
}
QPainter painter(&regionPremul);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(Qt::NoPen);
painter.setBrush(QColor(0, 0, 0, 255));
const double ox = static_cast<double>(cropWorldRect.left());
const double oy = static_cast<double>(cropWorldRect.top());
for (const QVector<QPointF>& polyWorld : holePolysWorld) {
if (polyWorld.size() < 3) {
continue;
}
QPolygonF local;
local.reserve(polyWorld.size());
for (const QPointF& w : polyWorld) {
local.append(QPointF(w.x() - ox, w.y() - oy));
}
painter.drawPolygon(local);
}
painter.end();
}
} // namespace entity_cutout