This commit is contained in:
2026-05-15 00:46:37 +08:00
parent b4c7697e8a
commit f64e624a39
8 changed files with 190 additions and 100 deletions
+10 -5
View File
@@ -4159,8 +4159,10 @@ void MainWindow::rebuildCentralPages() {
}
});
connect(m_editorCanvas, &EditorCanvas::requestResolveBlackholeCopy, this,
[this](const QString& entityId, const QPoint& sourceOffsetPx) {
if (!m_workspace.resolveBlackholeByCopyBackground(entityId, sourceOffsetPx, true)) {
[this](const QString& entityId, const QRect& targetWorldInBackground,
const QRect& srcWorldInBackground) {
if (!m_workspace.resolveBlackholeByCopyBackground(entityId, targetWorldInBackground,
srcWorldInBackground, true)) {
QMessageBox::warning(
this,
QStringLiteral("黑洞修复"),
@@ -4804,9 +4806,9 @@ void MainWindow::showBlackholeContextMenu(const QPoint& globalPos, const QString
return;
}
const int maxDec = std::clamp(std::max(cropRect.width(), cropRect.height()), 512, 4096);
// 与黑洞/覆盖层逻辑像素严格对齐:必须按 crop 原始分辨率解码,避免 vips maxOutput 缩放导致预览与写盘发糊。
QImage bg;
if (!core::image_file::loadRegionToQImage(bgAbs, cropRect, maxDec, maxDec, &bg) || bg.isNull()) {
if (!core::image_file::loadRegionToQImageExact(bgAbs, cropRect, &bg) || bg.isNull()) {
QMessageBox::warning(this, QStringLiteral("黑洞修复"), QStringLiteral("读取背景失败。"));
return;
}
@@ -5008,6 +5010,9 @@ void MainWindow::showBlackholeContextMenu(const QPoint& globalPos, const QString
QString immediateErr;
const QString inpaintModel = dlg.inpaintModelKey();
const QString prompt = dlg.promptText();
// 后端在不超过 max_side 时保持输入分辨率推理,再缩回原尺寸;此处用裁剪长边避免无谓降采样(上限与 API 一致)。
const int cropMaxSide = std::max(cropRect.width(), cropRect.height());
const int inpaintMaxSide = std::clamp(cropMaxSide, 256, 8192);
QNetworkReply* reply = client->inpaintAsync(
cropPng,
maskPng,
@@ -5015,7 +5020,7 @@ void MainWindow::showBlackholeContextMenu(const QPoint& globalPos, const QString
prompt,
QString(),
0.72,
1024,
inpaintMaxSide,
&immediateErr);
if (!reply) {
QMessageBox::warning(this,