1
0
Fork 0

Alert when image saving failed

This commit is contained in:
torusrxxx 2024-07-21 23:12:50 +08:00
parent 1363911e47
commit e40d525b8a
No known key found for this signature in database
GPG Key ID: A795C73A0F1CFADD
1 changed files with 7 additions and 3 deletions

View File

@ -2573,10 +2573,11 @@ void DisassemblerGraphView::saveImageSlot()
img.setDevicePixelRatio(scaleFactor);
QPainter painter(&img);
this->viewport()->render(&painter);
if(!path.toLower().endsWith(".webp"))
img.save(path);
bool success;
if(!path.endsWith(".webp", Qt::CaseInsensitive))
success = img.save(path);
else
img.save(path, nullptr, 100);
success = img.save(path, nullptr, 100); //WebP needs this to save in lossless format. But this makes PNG larger than BMP.
//restore changes made to viewport for full render saving
this->viewport()->resize(size);
@ -2586,6 +2587,9 @@ void DisassemblerGraphView::saveImageSlot()
this->horizontalScrollBar()->setValue(scrollbarPos.x());
this->verticalScrollBar()->setValue(scrollbarPos.y());
}
if(!success)
SimpleErrorBox(this, tr("Error"), tr("Image saving failed!"));
}
void DisassemblerGraphView::xrefSlot()