From 3014e2bf01ab256531f71dc97efcdaec07cd23cc Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 23 Aug 2016 13:55:08 +0200 Subject: Don't ignore alpha values in grabFramebuffer methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Returns an ARGB32_Premultiplied image when the framebuffer is grabbed on a transparent QOpenGLWidget or QOpenGLWindow. Task-number: QTBUG-55245 Change-Id: I4b7778ecc38275be1ed9fb748c77c7e1f6b65a00 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qopenglwindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gui') 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; } -- cgit v1.2.3