update
This commit is contained in:
@@ -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(®ionPremul);
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user