mirror of https://github.com/vitalif/openscad
Merge pull request #1316 from openscad/issue1288
Grab framebuffer before opening file dialog. Should fix #1288master
commit
a1bece5c51
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue