#1288 Grab framebuffer before opening file dialog to avoid the dialog being part of hte grabbed frame

master
Marius Kintel 2015-04-16 11:11:28 -04:00
parent b718a23972
commit 728a114594
3 changed files with 12 additions and 3 deletions

View File

@ -297,12 +297,16 @@ void QGLView::mouseReleaseEvent(QMouseEvent*)
releaseMouse();
}
bool QGLView::save(const char *filename)
void QGLView::grabFrame()
{
// Force reading from front buffer. Some configurations will read from the back buffer here.
glReadBuffer(GL_FRONT);
QImage img = grabFrameBuffer();
return img.save(filename, "PNG");
this->frame = grabFrameBuffer();
}
bool QGLView::save(const char *filename)
{
return this->frame.save(filename, "PNG");
}
void QGLView::wheelEvent(QWheelEvent *event)

View File

@ -42,6 +42,8 @@ public:
#if QT_VERSION >= 0x050100
float getDPI() { return this->devicePixelRatio(); }
#endif
void grabFrame();
bool save(const char *filename);
void resetView();
void viewAll();
@ -58,6 +60,7 @@ private:
bool mouse_drag_active;
QPoint last_mouse;
QImage frame; // Used by grabFrame() and save()
void wheelEvent(QWheelEvent *event);
void mousePressEvent(QMouseEvent *event);

View File

@ -2171,6 +2171,8 @@ void MainWindow::actionExportImage()
{
setCurrentOutput();
// Grab first to make sure dialog box isn't part of the grabbed image
qglview->grabFrame();
QString img_filename = QFileDialog::getSaveFileName(this,
_("Export Image"), "", _("PNG Files (*.png)"));
if (img_filename.isEmpty()) {