diff options
-rw-r--r-- | src/gui/kernel/qopenglwindow.cpp | 6 | ||||
-rw-r--r-- | src/widgets/kernel/qopenglwidget.cpp | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp index c3a264f1e8..8b052d92ae 100644 --- a/src/gui/kernel/qopenglwindow.cpp +++ b/src/gui/kernel/qopenglwindow.cpp @@ -511,7 +511,7 @@ GLuint QOpenGLWindow::defaultFramebufferObject() const extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); /*! - Returns a 32-bit RGB image of the framebuffer. + Returns a copy of the framebuffer. \note This is a potentially expensive operation because it relies on glReadPixels() to read back the pixels. This may be slow and can stall the @@ -531,7 +531,9 @@ QImage QOpenGLWindow::grabFramebuffer() return QImage(); makeCurrent(); - QImage img = qt_gl_read_framebuffer(size() * devicePixelRatio(), false, false); + + const bool hasAlpha = format().hasAlpha(); + QImage img = qt_gl_read_framebuffer(size() * devicePixelRatio(), hasAlpha, hasAlpha); img.setDevicePixelRatio(devicePixelRatio()); return img; } diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index c96b6812c4..51e78ec765 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -938,7 +938,8 @@ QImage QOpenGLWidgetPrivate::grabFramebuffer() q->makeCurrent(); } - QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatioF(), false, false); + const bool hasAlpha = q->format().hasAlpha(); + QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatioF(), hasAlpha, hasAlpha); res.setDevicePixelRatio(q->devicePixelRatioF()); // While we give no guarantees of what is going to be left bound, prefer the |