Merge pull request #1316 from openscad/issue1288

Grab framebuffer before opening file dialog. Should fix #1288
master
Marius Kintel 2015-04-17 10:14:02 -04:00
commit a1bece5c51
3 changed files with 12 additions and 3 deletions

View File

@ -294,12 +294,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()) {